tweaks: adjust indentation after previous change
parent
77d24300f3
commit
7c3c942097
246
src/files.c
246
src/files.c
|
@ -2092,165 +2092,163 @@ int do_writeout(bool exiting, bool withprompt)
|
||||||
|
|
||||||
func = func_from_key(&i);
|
func = func_from_key(&i);
|
||||||
|
|
||||||
/* Upon request, abandon the buffer. */
|
/* Upon request, abandon the buffer. */
|
||||||
if (func == discard_buffer) {
|
if (func == discard_buffer) {
|
||||||
free(given);
|
free(given);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
given = mallocstrcpy(given, answer);
|
given = mallocstrcpy(given, answer);
|
||||||
|
|
||||||
#ifdef ENABLE_BROWSER
|
#ifdef ENABLE_BROWSER
|
||||||
if (func == to_files_void) {
|
if (func == to_files_void) {
|
||||||
char *chosen = do_browse_from(answer);
|
char *chosen = do_browse_from(answer);
|
||||||
|
|
||||||
if (chosen == NULL)
|
if (chosen == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
free(answer);
|
free(answer);
|
||||||
answer = chosen;
|
answer = chosen;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (func == dos_format_void) {
|
if (func == dos_format_void) {
|
||||||
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE :
|
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE : DOS_FILE;
|
||||||
DOS_FILE;
|
continue;
|
||||||
continue;
|
} else if (func == mac_format_void) {
|
||||||
} else if (func == mac_format_void) {
|
openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE : MAC_FILE;
|
||||||
openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE :
|
continue;
|
||||||
MAC_FILE;
|
} else if (func == backup_file_void) {
|
||||||
continue;
|
TOGGLE(BACKUP_FILE);
|
||||||
} else if (func == backup_file_void) {
|
continue;
|
||||||
TOGGLE(BACKUP_FILE);
|
} else if (func == prepend_void) {
|
||||||
continue;
|
method = (method == PREPEND) ? OVERWRITE : PREPEND;
|
||||||
} else if (func == prepend_void) {
|
continue;
|
||||||
method = (method == PREPEND) ? OVERWRITE : PREPEND;
|
} else if (func == append_void) {
|
||||||
continue;
|
method = (method == APPEND) ? OVERWRITE : APPEND;
|
||||||
} else if (func == append_void) {
|
continue;
|
||||||
method = (method == APPEND) ? OVERWRITE : APPEND;
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
if (func == do_help_void) {
|
if (func == do_help_void) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_EXTRA
|
#ifdef ENABLE_EXTRA
|
||||||
/* If the current file has been modified, we've pressed
|
/* If the current file has been modified, we've pressed
|
||||||
* Ctrl-X at the edit window to exit, we've pressed "y" at
|
* Ctrl-X at the edit window to exit, we've pressed "y" at
|
||||||
* the "Save modified buffer" prompt to save, we've entered
|
* the "Save modified buffer" prompt to save, we've entered
|
||||||
* "zzy" as the filename to save under (hence "xyzzy"), and
|
* "zzy" as the filename to save under (hence "xyzzy"), and
|
||||||
* this is the first time we've done this, show an Easter
|
* this is the first time we've done this, show an Easter
|
||||||
* egg. Display the credits. */
|
* egg. Display the credits. */
|
||||||
if (!did_credits && exiting && !ISSET(TEMP_FILE) &&
|
if (!did_credits && exiting && !ISSET(TEMP_FILE) &&
|
||||||
strcasecmp(answer, "zzy") == 0) {
|
strcasecmp(answer, "zzy") == 0) {
|
||||||
do_credits();
|
do_credits();
|
||||||
did_credits = TRUE;
|
did_credits = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (method == OVERWRITE) {
|
if (method == OVERWRITE) {
|
||||||
bool name_exists, do_warning;
|
bool name_exists, do_warning;
|
||||||
char *full_answer, *full_filename;
|
char *full_answer, *full_filename;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
full_answer = get_full_path(answer);
|
full_answer = get_full_path(answer);
|
||||||
full_filename = get_full_path(openfile->filename);
|
full_filename = get_full_path(openfile->filename);
|
||||||
name_exists = (stat((full_answer == NULL) ?
|
name_exists = (stat((full_answer == NULL) ?
|
||||||
answer : full_answer, &st) != -1);
|
answer : full_answer, &st) != -1);
|
||||||
if (openfile->filename[0] == '\0')
|
if (openfile->filename[0] == '\0')
|
||||||
do_warning = name_exists;
|
do_warning = name_exists;
|
||||||
else
|
else
|
||||||
do_warning = (strcmp((full_answer == NULL) ?
|
do_warning = (strcmp((full_answer == NULL) ?
|
||||||
answer : full_answer, (full_filename == NULL) ?
|
answer : full_answer, (full_filename == NULL) ?
|
||||||
openfile->filename : full_filename) != 0);
|
openfile->filename : full_filename) != 0);
|
||||||
|
|
||||||
free(full_filename);
|
free(full_filename);
|
||||||
free(full_answer);
|
free(full_answer);
|
||||||
|
|
||||||
if (do_warning) {
|
if (do_warning) {
|
||||||
/* When in restricted mode, we aren't allowed to overwrite
|
/* When in restricted mode, we aren't allowed to overwrite
|
||||||
* an existing file with the current buffer, nor to change
|
* an existing file with the current buffer, nor to change
|
||||||
* the name of the current file if it already has one. */
|
* the name of the current file if it already has one. */
|
||||||
if (ISSET(RESTRICTED)) {
|
if (ISSET(RESTRICTED)) {
|
||||||
/* TRANSLATORS: Restricted mode forbids overwriting. */
|
/* TRANSLATORS: Restricted mode forbids overwriting. */
|
||||||
warn_and_shortly_pause(_("File exists -- "
|
warn_and_shortly_pause(_("File exists -- "
|
||||||
"cannot overwrite"));
|
"cannot overwrite"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!maychange) {
|
if (!maychange) {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (exiting || !openfile->mark)
|
if (exiting || !openfile->mark)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (do_yesno_prompt(FALSE, _("Save file under "
|
if (do_yesno_prompt(FALSE, _("Save file under "
|
||||||
"DIFFERENT NAME? ")) < 1)
|
"DIFFERENT NAME? ")) < 1)
|
||||||
continue;
|
|
||||||
maychange = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name_exists) {
|
|
||||||
char *question = _("File \"%s\" exists; OVERWRITE? ");
|
|
||||||
char *message = charalloc(strlen(question) +
|
|
||||||
strlen(answer) + 1);
|
|
||||||
sprintf(message, question, answer);
|
|
||||||
|
|
||||||
i = do_yesno_prompt(FALSE, message);
|
|
||||||
free(message);
|
|
||||||
|
|
||||||
if (i < 1)
|
|
||||||
continue;
|
continue;
|
||||||
|
maychange = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (name_exists) {
|
||||||
|
char *question = _("File \"%s\" exists; OVERWRITE? ");
|
||||||
|
char *message = charalloc(strlen(question) +
|
||||||
|
strlen(answer) + 1);
|
||||||
|
sprintf(message, question, answer);
|
||||||
|
|
||||||
|
i = do_yesno_prompt(FALSE, message);
|
||||||
|
free(message);
|
||||||
|
|
||||||
|
if (i < 1)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* Complain if the file exists, the name hasn't changed,
|
/* Complain if the file exists, the name hasn't changed,
|
||||||
* and the stat information we had before does not match
|
* and the stat information we had before does not match
|
||||||
* what we have now. */
|
* what we have now. */
|
||||||
else if (name_exists && openfile->current_stat &&
|
else if (name_exists && openfile->current_stat &&
|
||||||
(openfile->current_stat->st_mtime < st.st_mtime ||
|
(openfile->current_stat->st_mtime < st.st_mtime ||
|
||||||
openfile->current_stat->st_dev != st.st_dev ||
|
openfile->current_stat->st_dev != st.st_dev ||
|
||||||
openfile->current_stat->st_ino != st.st_ino)) {
|
openfile->current_stat->st_ino != st.st_ino)) {
|
||||||
int response;
|
int response;
|
||||||
|
|
||||||
warn_and_shortly_pause(_("File on disk has changed"));
|
warn_and_shortly_pause(_("File on disk has changed"));
|
||||||
|
|
||||||
response = do_yesno_prompt(FALSE, _("File was modified "
|
response = do_yesno_prompt(FALSE, _("File was modified "
|
||||||
"since you opened it; continue saving? "));
|
"since you opened it; continue saving? "));
|
||||||
blank_statusbar();
|
blank_statusbar();
|
||||||
|
|
||||||
/* When in tool mode and not called by 'savefile',
|
/* When in tool mode and not called by 'savefile',
|
||||||
* overwrite the file right here when requested. */
|
* overwrite the file right here when requested. */
|
||||||
if (ISSET(TEMP_FILE) && withprompt) {
|
if (ISSET(TEMP_FILE) && 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, FALSE);
|
||||||
else if (response == 0)
|
else if (response == 0)
|
||||||
return 2;
|
return 2;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
} else if (response != 1) {
|
} else if (response != 1) {
|
||||||
free(given);
|
free(given);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Here's where we allow the selected text to be written to
|
|
||||||
* a separate file. If we're using restricted mode, this
|
|
||||||
* function is disabled, since it allows reading from or
|
|
||||||
* writing to files not specified on the command line. */
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
if (openfile->mark && !exiting && !ISSET(RESTRICTED))
|
|
||||||
result = write_marked_file(answer, NULL, FALSE, method);
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
result = write_file(answer, NULL, FALSE, method, FALSE);
|
}
|
||||||
|
|
||||||
break;
|
/* Here's where we allow the selected text to be written to
|
||||||
|
* a separate file. If we're using restricted mode, this
|
||||||
|
* function is disabled, since it allows reading from or
|
||||||
|
* writing to files not specified on the command line. */
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
if (openfile->mark && !exiting && !ISSET(RESTRICTED))
|
||||||
|
result = write_marked_file(answer, NULL, FALSE, method);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
result = write_file(answer, NULL, FALSE, method, FALSE);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(given);
|
free(given);
|
||||||
|
|
Loading…
Reference in New Issue