num_of_digits() take a size_t instead of a ssize_t, and rename
num_of_digits() to digits()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2479
35c25a1d-7b9e-4130-9fde-
d3aeb78583b8
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)
(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
* 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;
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. */
#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);
}
#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++;