miscellaneous bits: make get_next_filename() use an unsigned long, make

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
This commit is contained in:
David Lawrence Ramsey 2005-04-19 16:32:08 +00:00
parent 9cf1df1f06
commit c596c0c4da
4 changed files with 9 additions and 12 deletions

View File

@ -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

View File

@ -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. */

View File

@ -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);

View File

@ -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++;