From: David Lawrence Ramsey Date: Sat, 28 May 2005 23:21:30 +0000 (+0000) Subject: miscellaneous minor fixes X-Git-Tag: v1.3.8~241 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=15aaa2c31acb5ea50f48a9b5ceefba1b623253a4;p=nano.git miscellaneous minor fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2562 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 859195d6..49ead8d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,7 @@ CVS code - write_file() - Since lineswritten is a size_t, print its value as an unsigned long instead of an unsigned int. (DLR) + - Declare the size_t i only in the loop where it's used. (DLR) cwd_tab_completion(), browser_init() - Rename variable next to nextdir to avoid confusion. (DLR) input_tab() @@ -81,6 +82,8 @@ CVS code - - Add additional checks for variables' not being NULL before we try to free them, to avoid assertion failures. (DLR) - nano.c: + die() + - Rename variable ret to retval for consistency. (DLR) copy_filestruct() - Rename variable prev to copy to avoid confusion. (DLR) print1opt_full() diff --git a/src/files.c b/src/files.c index b141e23e..6bb4b4bf 100644 --- a/src/files.c +++ b/src/files.c @@ -626,7 +626,8 @@ void do_insertfile( execute_command(answer); else { #endif - answer = mallocstrassn(answer, real_dir_from_tilde(answer)); + answer = mallocstrassn(answer, + real_dir_from_tilde(answer)); load_buffer(answer); #ifndef NANO_SMALL } @@ -1411,13 +1412,12 @@ int write_file(const char *name, bool tmp, int append, bool } /* If backup_dir is set, we set backupname to - * backup_dir/backupname~, where backupnae is the canonicalized + * backup_dir/backupname~, where backupname is the canonicalized * absolute pathname of realname with every '/' replaced with a * '!'. This means that /home/foo/file is backed up in * backup_dir/!home!foo!file~. */ if (backup_dir != NULL) { char *canon_realname = get_full_path(realname); - size_t i; if (canon_realname == NULL) /* If get_full_path() failed, we don't have a @@ -1428,7 +1428,9 @@ int write_file(const char *name, bool tmp, int append, bool * backupdir/../backupname~. */ canon_realname = mallocstrcpy(NULL, tail(realname)); else { - for (i = 0; canon_realname[i] != '\0'; i++) { + size_t i = 0; + + for (; canon_realname[i] != '\0'; i++) { if (canon_realname[i] == '/') canon_realname[i] = '!'; } diff --git a/src/nano.c b/src/nano.c index cb872902..d3ed6b2d 100644 --- a/src/nano.c +++ b/src/nano.c @@ -155,7 +155,7 @@ void die(const char *msg, ...) void die_save_file(const char *die_filename) { - char *ret; + char *retval; bool failed = TRUE; /* If we're using restricted mode, don't write any emergency backup @@ -169,17 +169,18 @@ void die_save_file(const char *die_filename) if (die_filename[0] == '\0') die_filename = "nano"; - ret = get_next_filename(die_filename); - if (ret[0] != '\0') - failed = (write_file(ret, TRUE, FALSE, TRUE) == -1); + retval = get_next_filename(die_filename); + if (retval[0] != '\0') + failed = (write_file(retval, TRUE, FALSE, TRUE) == -1); if (!failed) - fprintf(stderr, _("\nBuffer written to %s\n"), ret); + fprintf(stderr, _("\nBuffer written to %s\n"), retval); else fprintf(stderr, - _("\nBuffer not written to %s (too many backup files?)\n"), ret); + _("\nBuffer not written to %s (too many backup files?)\n"), + retval); - free(ret); + free(retval); } /* Die with an error message that the screen was too small if, well, the