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
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:
* 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;
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;
}
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";
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);
}
#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);
}
#endif /* HAVE_REGEX_H */
-int num_of_digits(int n)
+int num_of_digits(ssize_t n)
{
int i = 1;