From 6a244b689fd4fead7d8fb0f683a11bf4524e428f Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 14 Apr 2005 03:52:28 +0000
Subject: [PATCH] various minor bits: add miscellaneous comment fixes; in
 get_next_filename(), use a long instead of an int for the number prepended to
 the filename; and in num_of_digits(), use a ssize_t instead of an int

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2468 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 9 +++++++++
 src/files.c | 9 +++++----
 src/nano.c  | 5 +++--
 src/proto.h | 2 +-
 src/utils.c | 2 +-
 5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f8e4d581..175eead1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,18 @@
 CVS code -
+- General:
+	- Miscellaneous comment fixes. (DLR)
+- files.c:
+  get_next_filename()
+	- Use a long instead of an int for the number prepended to the
+	  filename. (DLR)
 - nano.c:
   print1opt_full()
 	- If desc should be empty, allow it to be NULL instead of
 	  "", since the latter is not necessarily translated as "".
 	  (DLR, found by Jordi)
+- utils.c:
+  num_of_digits()
+	- Use a ssize_t instead of an int. (DLR)
 
 GNU nano 1.3.7 - 2005.04.10
 - General:
diff --git a/src/files.c b/src/files.c
index cbeb20cd..7db6ab9c 100644
--- a/src/files.c
+++ b/src/files.c
@@ -379,11 +379,11 @@ int open_file(const char *filename, bool newfie, FILE **f)
  * extension exists, we return "". */
 char *get_next_filename(const char *name)
 {
-    int i = 0;
+    long i = 0;
     char *buf;
     size_t namelen = strlen(name);
 
-    buf = charalloc(namelen + num_of_digits(INT_MAX) + 7);
+    buf = charalloc(namelen + num_of_digits(LONG_MAX) + 7);
     strcpy(buf, name);
     strcpy(buf + namelen, ".save");
     namelen += 5;
@@ -393,15 +393,16 @@ char *get_next_filename(const char *name)
 
 	if (stat(buf, &fs) == -1)
 	    return buf;
-	if (i == INT_MAX)
+	if (i == LONG_MAX)
 	    break;
 
 	i++;
-	sprintf(buf + namelen, ".%d", i);
+	sprintf(buf + namelen, ".%ld", i);
     }
 
     /* We get here only if there is no possible save file. */
     null_at(&buf, 0);
+
     return buf;
 }
 
diff --git a/src/nano.c b/src/nano.c
index 89367936..def32d0d 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -165,7 +165,7 @@ void die_save_file(const char *die_filename)
 	return;
 
     /* If we can't save, we have REAL bad problems, but we might as well
-       TRY. */
+     * TRY. */
     if (die_filename[0] == '\0')
 	die_filename = "nano";
 
@@ -176,7 +176,8 @@ void die_save_file(const char *die_filename)
     if (!failed)
 	fprintf(stderr, _("\nBuffer written to %s\n"), ret);
     else
-	fprintf(stderr, _("\nBuffer not written to %s (too many backup files?)\n"), ret);
+	fprintf(stderr,
+		_("\nBuffer not written to %s (too many backup files?)\n"), ret);
 
     free(ret);
 }
diff --git a/src/proto.h b/src/proto.h
index a61bfc76..8a049e37 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -540,7 +540,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(int n);
+int num_of_digits(ssize_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 4d384648..76437d72 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -55,7 +55,7 @@ int regexp_bol_or_eol(const regex_t *preg, const char *string)
 }
 #endif /* HAVE_REGEX_H */
 
-int num_of_digits(int n)
+int num_of_digits(ssize_t n)
 {
     int i = 1;
 
-- 
GitLab