diff --git a/ChangeLog b/ChangeLog
index 7bf06ff48c0fe5f29d8e95179c29e26fe85bcb9e..c110d6f86b4ca2bc6b3ff4c4b5879b3ed75c5aa7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,8 +9,8 @@ CVS code -
   load_open_file()
 	- Remove an unneeded clearok(FALSE). (DLR)
   get_next_filename()
-	- Use a long instead of an int for the number prepended to the
-	  filename. (DLR)
+	- Use an unsigned long instead of an int for the number
+	  prepended to the filename. (DLR)
   do_browser()
 	- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
 	  consistency. (DLR)
@@ -27,7 +27,7 @@ CVS code -
 	  (DLR)
 - utils.c:
   num_of_digits()
-	- Use a ssize_t instead of an int. (DLR)
+	- Use a size_t instead of an int, and rename to digits(). (DLR)
 - winio.c:
   do_help()
 	- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
diff --git a/src/files.c b/src/files.c
index 4e550fdd8255f39300dcebaf12d736c7243c1565..df105cd055097990cb08200ee819f90091c88a56 100644
--- a/src/files.c
+++ b/src/files.c
@@ -378,11 +378,11 @@ int open_file(const char *filename, bool newfie, FILE **f)
  * extension exists, we return "". */
 char *get_next_filename(const char *name)
 {
-    long i = 0;
+    unsigned long i = 0;
     char *buf;
     size_t namelen = strlen(name);
 
-    buf = charalloc(namelen + num_of_digits(LONG_MAX) + 7);
+    buf = charalloc(namelen + digits(ULONG_MAX) + 7);
     strcpy(buf, name);
     strcpy(buf + namelen, ".save");
     namelen += 5;
@@ -392,11 +392,11 @@ char *get_next_filename(const char *name)
 
 	if (stat(buf, &fs) == -1)
 	    return buf;
-	if (i == LONG_MAX)
+	if (i == ULONG_MAX)
 	    break;
 
 	i++;
-	sprintf(buf + namelen, ".%ld", i);
+	sprintf(buf + namelen, ".%lu", i);
     }
 
     /* We get here only if there is no possible save file. */
diff --git a/src/proto.h b/src/proto.h
index 2b4654a736e7f35e6f100d565983638b7875598f..c22c37f9dc5bd05082ff8f5f46c7eaa77208da8d 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -543,7 +543,7 @@ int safe_regexec(const regex_t *preg, const char *string, size_t nmatch,
 #endif
 int regexp_bol_or_eol(const regex_t *preg, const char *string);
 #endif
-int num_of_digits(ssize_t n);
+int digits(size_t n);
 void get_homedir(void);
 bool parse_num(const char *str, ssize_t *val);
 void align(char **strp);
diff --git a/src/utils.c b/src/utils.c
index 450dd78ab9300c84b621a6b4227e6facb6b200cd..1ada993374202de1d04d68a5b38f823bb3710bb3 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -54,13 +54,10 @@ int regexp_bol_or_eol(const regex_t *preg, const char *string)
 }
 #endif /* HAVE_REGEX_H */
 
-int num_of_digits(ssize_t n)
+int digits(size_t n)
 {
     int i = 1;
 
-    if (n < 0)
-	n = -n;
-
     while (n > 10) {
 	n /= 10;
 	i++;