tweaks: reshuffle a few declarations, and reduce the scope of one
This commit is contained in:
14
src/files.c
14
src/files.c
@@ -1515,10 +1515,6 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
|||||||
bool retval = FALSE;
|
bool retval = FALSE;
|
||||||
/* Instead of returning in this function, you should always
|
/* Instead of returning in this function, you should always
|
||||||
* set retval and then goto cleanup_and_exit. */
|
* set retval and then goto cleanup_and_exit. */
|
||||||
size_t lineswritten = 0;
|
|
||||||
const linestruct *fileptr = openfile->filetop;
|
|
||||||
int fd;
|
|
||||||
/* The file descriptor we use. */
|
|
||||||
mode_t original_umask = 0;
|
mode_t original_umask = 0;
|
||||||
/* Our umask, from when nano started. */
|
/* Our umask, from when nano started. */
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
@@ -1533,6 +1529,10 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
|||||||
/* The actual file, realname, we are writing to. */
|
/* The actual file, realname, we are writing to. */
|
||||||
char *tempname = NULL;
|
char *tempname = NULL;
|
||||||
/* The name of the temporary file we write to on prepend. */
|
/* The name of the temporary file we write to on prepend. */
|
||||||
|
const linestruct *fileptr = openfile->filetop;
|
||||||
|
/* An iterator for moving through the lines of the buffer. */
|
||||||
|
size_t lineswritten = 0;
|
||||||
|
/* The number of lines written, for feedback on the status bar. */
|
||||||
|
|
||||||
if (*name == '\0')
|
if (*name == '\0')
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1610,13 +1610,10 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
|||||||
if (backuptemp == NULL)
|
if (backuptemp == NULL)
|
||||||
backuptemp = copy_of(tail(realname));
|
backuptemp = copy_of(tail(realname));
|
||||||
else {
|
else {
|
||||||
size_t i = 0;
|
for (int i = 0; backuptemp[i] != '\0'; i++)
|
||||||
|
|
||||||
for (; backuptemp[i] != '\0'; i++) {
|
|
||||||
if (backuptemp[i] == '/')
|
if (backuptemp[i] == '/')
|
||||||
backuptemp[i] = '!';
|
backuptemp[i] = '!';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
backupname = charalloc(strlen(backup_dir) + strlen(backuptemp) + 1);
|
backupname = charalloc(strlen(backup_dir) + strlen(backuptemp) + 1);
|
||||||
sprintf(backupname, "%s%s", backup_dir, backuptemp);
|
sprintf(backupname, "%s%s", backup_dir, backuptemp);
|
||||||
@@ -1785,6 +1782,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
|||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
|
||||||
if (f_open == NULL) {
|
if (f_open == NULL) {
|
||||||
|
int fd;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
block_sigwinch(TRUE);
|
block_sigwinch(TRUE);
|
||||||
install_handler_for_Ctrl_C();
|
install_handler_for_Ctrl_C();
|
||||||
|
|||||||
Reference in New Issue
Block a user