tweaks: invert the logic of a variable, and rename it
To get rid of two double negatives.
Этот коммит содержится в:
родитель
4761e00852
Коммит
0c40f87b55
18
src/files.c
18
src/files.c
@ -1522,13 +1522,13 @@ int copy_file(FILE *inn, FILE *out, bool close_out)
|
|||||||
* use it when spell checking or dumping the file on an error. If
|
* use it when spell checking or dumping the file on an error. If
|
||||||
* method is APPEND, it means we are appending instead of overwriting.
|
* method is APPEND, it means we are appending instead of overwriting.
|
||||||
* If method is PREPEND, it means we are prepending instead of
|
* If method is PREPEND, it means we are prepending instead of
|
||||||
* overwriting. If nonamechange is TRUE, we don't change the current
|
* overwriting. If fullbuffer is TRUE, we set the current filename and
|
||||||
* filename. nonamechange is irrelevant when appending or prepending,
|
* stat info. But fullbuffer is irrelevant when appending or prepending,
|
||||||
* or when writing a temporary file.
|
* or when writing a temporary file.
|
||||||
*
|
*
|
||||||
* Return TRUE on success or FALSE on error. */
|
* Return TRUE on success or FALSE on error. */
|
||||||
bool write_file(const char *name, FILE *f_open, bool tmp,
|
bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||||
kind_of_writing_type method, bool nonamechange)
|
kind_of_writing_type method, bool fullbuffer)
|
||||||
{
|
{
|
||||||
bool retval = FALSE;
|
bool retval = FALSE;
|
||||||
/* Instead of returning in this function, you should always
|
/* Instead of returning in this function, you should always
|
||||||
@ -1919,7 +1919,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
|||||||
|
|
||||||
if (method == OVERWRITE && !tmp) {
|
if (method == OVERWRITE && !tmp) {
|
||||||
/* If we must set the filename, and it changed, adjust things. */
|
/* If we must set the filename, and it changed, adjust things. */
|
||||||
if (!nonamechange && strcmp(openfile->filename, realname) != 0) {
|
if (fullbuffer && strcmp(openfile->filename, realname) != 0) {
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
const char *oldname, *newname;
|
const char *oldname, *newname;
|
||||||
|
|
||||||
@ -1950,7 +1950,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (!nonamechange)
|
if (fullbuffer)
|
||||||
/* Get or update the stat info to reflect the current state. */
|
/* Get or update the stat info to reflect the current state. */
|
||||||
stat_with_alloc(realname, &openfile->current_stat);
|
stat_with_alloc(realname, &openfile->current_stat);
|
||||||
#endif
|
#endif
|
||||||
@ -1978,7 +1978,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
|||||||
{
|
{
|
||||||
bool retval;
|
bool retval;
|
||||||
bool old_modified = openfile->modified;
|
bool old_modified = openfile->modified;
|
||||||
/* Save the status, because write_file() unsets the modified flag. */
|
/* Save the status, as writing the file unsets the modified flag. */
|
||||||
bool added_magicline = FALSE;
|
bool added_magicline = FALSE;
|
||||||
/* Whether we added a magicline after filebot. */
|
/* Whether we added a magicline after filebot. */
|
||||||
filestruct *top, *bot;
|
filestruct *top, *bot;
|
||||||
@ -1996,7 +1996,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
|||||||
added_magicline = TRUE;
|
added_magicline = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = write_file(name, f_open, tmp, method, TRUE);
|
retval = write_file(name, f_open, tmp, method, FALSE);
|
||||||
|
|
||||||
/* If we added a magicline, remove it now. */
|
/* If we added a magicline, remove it now. */
|
||||||
if (added_magicline)
|
if (added_magicline)
|
||||||
@ -2225,7 +2225,7 @@ int do_writeout(bool exiting, bool withprompt)
|
|||||||
free(given);
|
free(given);
|
||||||
if (response == 1)
|
if (response == 1)
|
||||||
return write_file(openfile->filename,
|
return write_file(openfile->filename,
|
||||||
NULL, FALSE, OVERWRITE, FALSE);
|
NULL, FALSE, OVERWRITE, TRUE);
|
||||||
else if (response == 0)
|
else if (response == 0)
|
||||||
return 2;
|
return 2;
|
||||||
else
|
else
|
||||||
@ -2247,7 +2247,7 @@ int do_writeout(bool exiting, bool withprompt)
|
|||||||
result = write_marked_file(answer, NULL, FALSE, method);
|
result = write_marked_file(answer, NULL, FALSE, method);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
result = write_file(answer, NULL, FALSE, method, FALSE);
|
result = write_file(answer, NULL, FALSE, method, TRUE);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -651,7 +651,7 @@ void die_save_file(const char *die_filename, struct stat *die_stat)
|
|||||||
targetname = get_next_filename(die_filename, ".save");
|
targetname = get_next_filename(die_filename, ".save");
|
||||||
|
|
||||||
if (*targetname != '\0')
|
if (*targetname != '\0')
|
||||||
failed = !write_file(targetname, NULL, TRUE, OVERWRITE, TRUE);
|
failed = !write_file(targetname, NULL, TRUE, OVERWRITE, FALSE);
|
||||||
|
|
||||||
if (!failed)
|
if (!failed)
|
||||||
fprintf(stderr, _("\nBuffer written to %s\n"), targetname);
|
fprintf(stderr, _("\nBuffer written to %s\n"), targetname);
|
||||||
|
@ -298,7 +298,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
|||||||
#endif
|
#endif
|
||||||
int copy_file(FILE *inn, FILE *out, bool close_out);
|
int copy_file(FILE *inn, FILE *out, bool close_out);
|
||||||
bool write_file(const char *name, FILE *f_open, bool tmp,
|
bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||||
kind_of_writing_type method, bool nonamechange);
|
kind_of_writing_type method, bool fullbuffer);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||||
kind_of_writing_type method);
|
kind_of_writing_type method);
|
||||||
|
@ -3004,7 +3004,7 @@ void do_spell(void)
|
|||||||
status = write_marked_file(temp, temp_file, TRUE, OVERWRITE);
|
status = write_marked_file(temp, temp_file, TRUE, OVERWRITE);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
|
status = write_file(temp, temp_file, TRUE, OVERWRITE, TRUE);
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
@ -3395,7 +3395,7 @@ void do_formatter(void)
|
|||||||
/* We're not supporting partial formatting, oi vey. */
|
/* We're not supporting partial formatting, oi vey. */
|
||||||
openfile->mark = NULL;
|
openfile->mark = NULL;
|
||||||
#endif
|
#endif
|
||||||
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
|
status = write_file(temp, temp_file, TRUE, OVERWRITE, TRUE);
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user