make write_marked() always call write_file() with nonamechange set to
TRUE (and hence no longer take a namechange parameter itself) to fix a bug where writing a selection would change the current filename, and make die_save_file() do the same since we don't need to change the current filename if we're writing emergency backup files git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1770 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
228148b87a
commit
2f0d03b4a2
|
@ -70,6 +70,11 @@ CVS code -
|
|||
- Rearrange the NANO_SMALL #ifdef so that the code to set the
|
||||
MODIFIED flag in open_files->flags is included only once.
|
||||
(DLR)
|
||||
write_marked()
|
||||
- Call write_file() with nonamechange set to TRUE so that we
|
||||
don't erroneously change the current filename when writing a
|
||||
selection, and don't take a nonamechange parameter anymore
|
||||
since we don't use it. (DLR)
|
||||
do_writeout()
|
||||
- Refactor so that no recursion is needed if we try to exit with
|
||||
a modified file that has no name when TEMP_OPT is set. (DLR)
|
||||
|
@ -86,6 +91,10 @@ CVS code -
|
|||
- Since all of the calls to finish() use 0 for the value of
|
||||
sigage, and the return value of finish() is never used, make
|
||||
it accept and return void. (David Benbennick)
|
||||
die_save_file()
|
||||
- Call write_file() with nonamechange set to TRUE since we don't
|
||||
need to change the current filename if we're writing emergency
|
||||
backup files. (DLR)
|
||||
do_early_abort()
|
||||
- Removed, as it's no longer called anywhere. (David Benbennick)
|
||||
open_pipe()
|
||||
|
|
18
src/files.c
18
src/files.c
|
@ -1395,8 +1395,8 @@ int copy_file(FILE *inn, FILE *out)
|
|||
* append == 1 means we are appending instead of overwriting.
|
||||
* append == 2 means we are prepending instead of overwriting.
|
||||
*
|
||||
* nonamechange means don't change the current filename, it is ignored
|
||||
* if tmp is nonzero or if we're appending/prepending.
|
||||
* nonamechange means don't change the current filename. It is ignored
|
||||
* if tmp is FALSE or if we're appending/prepending.
|
||||
*
|
||||
* Return -1 on error, 1 on success. */
|
||||
int write_file(const char *name, int tmp, int append, int nonamechange)
|
||||
|
@ -1737,11 +1737,11 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
|
|||
#ifndef NANO_SMALL
|
||||
/* Write a marked selection from a file out. First, set fileage and
|
||||
* filebot as the top and bottom of the mark, respectively. Then call
|
||||
* write_file() with the values of name, temp, append, and nonamechange.
|
||||
* Finally, set fileage and filebot back to their old values and
|
||||
* return. */
|
||||
int write_marked(const char *name, int tmp, int append, int
|
||||
nonamechange)
|
||||
* write_file() with the values of name, temp, and append, and with
|
||||
* nonamechange set to TRUE so that we don't change the current
|
||||
* filename. Finally, set fileage and filebot back to their old values
|
||||
* and return. */
|
||||
int write_marked(const char *name, int tmp, int append)
|
||||
{
|
||||
int retval = -1;
|
||||
filestruct *fileagebak = fileage;
|
||||
|
@ -1783,7 +1783,7 @@ int write_marked(const char *name, int tmp, int append, int
|
|||
if (filebot->data[0] != '\0' && filebot->next != NULL)
|
||||
filebot = filebot->next;
|
||||
|
||||
retval = write_file(name, tmp, append, nonamechange);
|
||||
retval = write_file(name, tmp, append, TRUE);
|
||||
|
||||
/* Now restore everything. */
|
||||
fileage->data -= topx;
|
||||
|
@ -1945,7 +1945,7 @@ int do_writeout(int exiting)
|
|||
/* Here's where we allow the selected text to be written to
|
||||
* a separate file. */
|
||||
if (!ISSET(RESTRICTED) && !exiting && ISSET(MARK_ISSET))
|
||||
i = write_marked(answer, FALSE, append, FALSE);
|
||||
i = write_marked(answer, FALSE, append);
|
||||
else
|
||||
#endif /* !NANO_SMALL */
|
||||
i = write_file(answer, FALSE, append, FALSE);
|
||||
|
|
|
@ -172,7 +172,7 @@ void die_save_file(const char *die_filename)
|
|||
free(buf);
|
||||
}
|
||||
if (ret[0] != '\0')
|
||||
i = write_file(ret, 1, 0, 0);
|
||||
i = write_file(ret, TRUE, FALSE, TRUE);
|
||||
|
||||
if (i != -1)
|
||||
fprintf(stderr, _("\nBuffer written to %s\n"), ret);
|
||||
|
@ -1808,10 +1808,10 @@ int do_spell(void)
|
|||
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(MARK_ISSET))
|
||||
i = write_marked(temp, 1, 0, 0);
|
||||
i = write_marked(temp, TRUE, FALSE);
|
||||
else
|
||||
#endif
|
||||
i = write_file(temp, 1, 0, 0);
|
||||
i = write_file(temp, TRUE, FALSE, FALSE);
|
||||
|
||||
if (i == -1) {
|
||||
statusbar(_("Unable to write temp file: %s"), strerror(errno));
|
||||
|
|
|
@ -188,8 +188,7 @@ void init_backup_dir(void);
|
|||
#endif
|
||||
int write_file(const char *name, int tmp, int append, int nonamechange);
|
||||
#ifndef NANO_SMALL
|
||||
int write_marked(const char *name, int tmp, int append, int
|
||||
nonamechange);
|
||||
int write_marked(const char *name, int tmp, int append);
|
||||
#endif
|
||||
int do_writeout(int exiting);
|
||||
int do_writeout_void(void);
|
||||
|
|
Loading…
Reference in New Issue