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-d3aeb78583b8master
parent
9cf1df1f06
commit
c596c0c4da
|
@ -9,8 +9,8 @@ CVS code -
|
||||||
load_open_file()
|
load_open_file()
|
||||||
- Remove an unneeded clearok(FALSE). (DLR)
|
- Remove an unneeded clearok(FALSE). (DLR)
|
||||||
get_next_filename()
|
get_next_filename()
|
||||||
- Use a long instead of an int for the number prepended to the
|
- Use an unsigned long instead of an int for the number
|
||||||
filename. (DLR)
|
prepended to the filename. (DLR)
|
||||||
do_browser()
|
do_browser()
|
||||||
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
|
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
|
||||||
consistency. (DLR)
|
consistency. (DLR)
|
||||||
|
@ -27,7 +27,7 @@ CVS code -
|
||||||
(DLR)
|
(DLR)
|
||||||
- utils.c:
|
- utils.c:
|
||||||
num_of_digits()
|
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:
|
- winio.c:
|
||||||
do_help()
|
do_help()
|
||||||
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
|
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
|
||||||
|
|
|
@ -378,11 +378,11 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
||||||
* extension exists, we return "". */
|
* extension exists, we return "". */
|
||||||
char *get_next_filename(const char *name)
|
char *get_next_filename(const char *name)
|
||||||
{
|
{
|
||||||
long i = 0;
|
unsigned long i = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t namelen = strlen(name);
|
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, name);
|
||||||
strcpy(buf + namelen, ".save");
|
strcpy(buf + namelen, ".save");
|
||||||
namelen += 5;
|
namelen += 5;
|
||||||
|
@ -392,11 +392,11 @@ char *get_next_filename(const char *name)
|
||||||
|
|
||||||
if (stat(buf, &fs) == -1)
|
if (stat(buf, &fs) == -1)
|
||||||
return buf;
|
return buf;
|
||||||
if (i == LONG_MAX)
|
if (i == ULONG_MAX)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
sprintf(buf + namelen, ".%ld", i);
|
sprintf(buf + namelen, ".%lu", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We get here only if there is no possible save file. */
|
/* We get here only if there is no possible save file. */
|
||||||
|
|
|
@ -543,7 +543,7 @@ int safe_regexec(const regex_t *preg, const char *string, size_t nmatch,
|
||||||
#endif
|
#endif
|
||||||
int regexp_bol_or_eol(const regex_t *preg, const char *string);
|
int regexp_bol_or_eol(const regex_t *preg, const char *string);
|
||||||
#endif
|
#endif
|
||||||
int num_of_digits(ssize_t n);
|
int digits(size_t n);
|
||||||
void get_homedir(void);
|
void get_homedir(void);
|
||||||
bool parse_num(const char *str, ssize_t *val);
|
bool parse_num(const char *str, ssize_t *val);
|
||||||
void align(char **strp);
|
void align(char **strp);
|
||||||
|
|
|
@ -54,13 +54,10 @@ int regexp_bol_or_eol(const regex_t *preg, const char *string)
|
||||||
}
|
}
|
||||||
#endif /* HAVE_REGEX_H */
|
#endif /* HAVE_REGEX_H */
|
||||||
|
|
||||||
int num_of_digits(ssize_t n)
|
int digits(size_t n)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
if (n < 0)
|
|
||||||
n = -n;
|
|
||||||
|
|
||||||
while (n > 10) {
|
while (n > 10) {
|
||||||
n /= 10;
|
n /= 10;
|
||||||
i++;
|
i++;
|
||||||
|
|
Loading…
Reference in New Issue