fix more problems with strings that contain nulls but shouldn't
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3994 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
43
src/files.c
43
src/files.c
@@ -739,7 +739,7 @@ void do_insertfile(
|
||||
statusbar(_("Cancelled"));
|
||||
break;
|
||||
} else {
|
||||
size_t pww_save = openfile->placewewant, answer_len;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
|
||||
ans = mallocstrcpy(ans, answer);
|
||||
|
||||
@@ -802,11 +802,10 @@ void do_insertfile(
|
||||
}
|
||||
#endif
|
||||
|
||||
answer_len = strlen(answer);
|
||||
|
||||
/* Convert newlines to nulls, just before we insert a file
|
||||
* or execute a command. */
|
||||
/* Convert newlines to nulls, just before we insert the file
|
||||
* or execute the command. */
|
||||
sunder(answer);
|
||||
align(&answer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (execute) {
|
||||
@@ -842,10 +841,6 @@ void do_insertfile(
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Convert nulls to newlines. answer_len is answer's real
|
||||
* length. */
|
||||
unsunder(answer, answer_len);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (ISSET(MULTIBUFFER))
|
||||
/* Update the screen to account for the current
|
||||
@@ -1885,18 +1880,29 @@ int do_writeout(bool exiting)
|
||||
#endif
|
||||
|
||||
if (append == OVERWRITE) {
|
||||
char *full_answer = get_full_path(answer);
|
||||
char *full_filename = get_full_path(openfile->filename);
|
||||
bool different_name = (strcmp(full_answer,
|
||||
full_filename) != 0);
|
||||
size_t answer_len = strlen(answer);
|
||||
bool name_exists, different_name;
|
||||
char *full_answer, *full_filename;
|
||||
struct stat st;
|
||||
bool name_exists;
|
||||
|
||||
/* Convert newlines to nulls, just before we get the
|
||||
* full path. */
|
||||
sunder(answer);
|
||||
|
||||
name_exists = (stat(answer, &st) != -1);
|
||||
full_answer = get_full_path(answer);
|
||||
|
||||
/* Convert nulls to newlines. answer_len is the
|
||||
* string's real length. */
|
||||
unsunder(answer, answer_len);
|
||||
|
||||
full_filename = get_full_path(openfile->filename);
|
||||
different_name = (strcmp(full_answer,
|
||||
full_filename) != 0);
|
||||
|
||||
free(full_filename);
|
||||
free(full_answer);
|
||||
|
||||
name_exists = (stat(answer, &st) != -1);
|
||||
|
||||
if (different_name) {
|
||||
if (name_exists) {
|
||||
/* If we're using restricted mode, we aren't
|
||||
@@ -1927,6 +1933,11 @@ int do_writeout(bool exiting)
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert newlines to nulls, just before we save the
|
||||
* file. */
|
||||
sunder(answer);
|
||||
align(&answer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Here's where we allow the selected text to be written to
|
||||
* a separate file. If we're using restricted mode, this is
|
||||
|
||||
Reference in New Issue
Block a user