Commit 6a244b68 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
No related merge requests found
Showing with 19 additions and 8 deletions
+19 -8
CVS code - 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: - nano.c:
print1opt_full() print1opt_full()
- If desc should be empty, allow it to be NULL instead of - If desc should be empty, allow it to be NULL instead of
"", since the latter is not necessarily translated as "". "", since the latter is not necessarily translated as "".
(DLR, found by Jordi) (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 GNU nano 1.3.7 - 2005.04.10
- General: - General:
......
...@@ -379,11 +379,11 @@ int open_file(const char *filename, bool newfie, FILE **f) ...@@ -379,11 +379,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)
{ {
int i = 0; long i = 0;
char *buf; char *buf;
size_t namelen = strlen(name); 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, name);
strcpy(buf + namelen, ".save"); strcpy(buf + namelen, ".save");
namelen += 5; namelen += 5;
...@@ -393,15 +393,16 @@ char *get_next_filename(const char *name) ...@@ -393,15 +393,16 @@ char *get_next_filename(const char *name)
if (stat(buf, &fs) == -1) if (stat(buf, &fs) == -1)
return buf; return buf;
if (i == INT_MAX) if (i == LONG_MAX)
break; break;
i++; i++;
sprintf(buf + namelen, ".%d", i); sprintf(buf + namelen, ".%ld", i);
} }
/* We get here only if there is no possible save file. */ /* We get here only if there is no possible save file. */
null_at(&buf, 0); null_at(&buf, 0);
return buf; return buf;
} }
......
...@@ -165,7 +165,7 @@ void die_save_file(const char *die_filename) ...@@ -165,7 +165,7 @@ void die_save_file(const char *die_filename)
return; return;
/* If we can't save, we have REAL bad problems, but we might as well /* If we can't save, we have REAL bad problems, but we might as well
TRY. */ * TRY. */
if (die_filename[0] == '\0') if (die_filename[0] == '\0')
die_filename = "nano"; die_filename = "nano";
...@@ -176,7 +176,8 @@ void die_save_file(const char *die_filename) ...@@ -176,7 +176,8 @@ void die_save_file(const char *die_filename)
if (!failed) if (!failed)
fprintf(stderr, _("\nBuffer written to %s\n"), ret); fprintf(stderr, _("\nBuffer written to %s\n"), ret);
else 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); free(ret);
} }
......
...@@ -540,7 +540,7 @@ int safe_regexec(const regex_t *preg, const char *string, size_t nmatch, ...@@ -540,7 +540,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(int n); int num_of_digits(ssize_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);
......
...@@ -55,7 +55,7 @@ int regexp_bol_or_eol(const regex_t *preg, const char *string) ...@@ -55,7 +55,7 @@ int regexp_bol_or_eol(const regex_t *preg, const char *string)
} }
#endif /* HAVE_REGEX_H */ #endif /* HAVE_REGEX_H */
int num_of_digits(int n) int num_of_digits(ssize_t n)
{ {
int i = 1; int i = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment