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
This commit is contained in:
David Lawrence Ramsey 2005-04-14 03:52:28 +00:00
parent c2b07472e2
commit 6a244b689f
5 changed files with 19 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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

View File

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