in get_full_path(), fix problem where only paths would be returned when
both paths and filenames should have been git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3944 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
b31b128a78
commit
a93023f14b
|
@ -4,6 +4,8 @@ CVS code -
|
||||||
- files.c:
|
- files.c:
|
||||||
get_full_path()
|
get_full_path()
|
||||||
- Remove unneeded assert. (DLR)
|
- Remove unneeded assert. (DLR)
|
||||||
|
- Fix problem where only paths would be returned when both paths
|
||||||
|
and filenames should have been. (DLR)
|
||||||
do_writeout()
|
do_writeout()
|
||||||
- For consistency, when saving a file with no name, don't
|
- For consistency, when saving a file with no name, don't
|
||||||
allow overwriting an existing file when in restricted
|
allow overwriting an existing file when in restricted
|
||||||
|
|
50
src/files.c
50
src/files.c
|
@ -986,8 +986,7 @@ char *get_full_path(const char *origpath)
|
||||||
if (!path_only)
|
if (!path_only)
|
||||||
d_there_file = mallocstrcpy(NULL, last_slash + 1);
|
d_there_file = mallocstrcpy(NULL, last_slash + 1);
|
||||||
|
|
||||||
/* And remove the filename portion of the answer from
|
/* Remove the filename portion of the answer from d_there. */
|
||||||
* d_there. */
|
|
||||||
null_at(&d_there, last_slash - d_there + 1);
|
null_at(&d_there, last_slash - d_there + 1);
|
||||||
|
|
||||||
/* Go to the path specified in d_there. */
|
/* Go to the path specified in d_there. */
|
||||||
|
@ -1019,28 +1018,29 @@ char *get_full_path(const char *origpath)
|
||||||
|
|
||||||
/* Finally, go back to the path specified in d_here,
|
/* Finally, go back to the path specified in d_here,
|
||||||
* where we were before. We don't check for a chdir()
|
* where we were before. We don't check for a chdir()
|
||||||
* error, since we can do nothing then. */
|
* error, since we can do nothing if we get one. */
|
||||||
chdir(d_here);
|
chdir(d_here);
|
||||||
|
|
||||||
/* Free d_here, since we're done using it. */
|
/* Free d_here, since we're done using it. */
|
||||||
free(d_here);
|
free(d_here);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At this point, if path_only is FALSE and d_there isn't NULL,
|
|
||||||
* d_there contains the path portion of the answer and
|
|
||||||
* d_there_file contains the filename portion of the answer. If
|
|
||||||
* this is the case, tack the latter onto the end of the former.
|
|
||||||
* d_there will then contain the complete answer. */
|
|
||||||
if (!path_only && d_there != NULL) {
|
|
||||||
d_there = charealloc(d_there, strlen(d_there) +
|
|
||||||
strlen(d_there_file) + 1);
|
|
||||||
strcat(d_there, d_there_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free d_there_file, since we're done using it. */
|
|
||||||
free(d_there_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* At this point, if path_only is FALSE and d_there isn't NULL,
|
||||||
|
* d_there contains the path portion of the answer and d_there_file
|
||||||
|
* contains the filename portion of the answer. If this is the
|
||||||
|
* case, tack the latter onto the end of the former. d_there will
|
||||||
|
* then contain the complete answer. */
|
||||||
|
if (!path_only && d_there != NULL) {
|
||||||
|
d_there = charealloc(d_there, strlen(d_there) +
|
||||||
|
strlen(d_there_file) + 1);
|
||||||
|
strcat(d_there, d_there_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free d_there_file, since we're done using it. */
|
||||||
|
if (d_there_file != NULL)
|
||||||
|
free(d_there_file);
|
||||||
|
|
||||||
return d_there;
|
return d_there;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1883,14 +1883,10 @@ int do_writeout(bool exiting)
|
||||||
if (name_exists) {
|
if (name_exists) {
|
||||||
/* If we're using restricted mode, we aren't
|
/* If we're using restricted mode, we aren't
|
||||||
* allowed to save a new file under the name of
|
* allowed to save a new file under the name of
|
||||||
* an existing file. In this case, show a "File
|
* an existing file. */
|
||||||
* exists" error. */
|
if (ISSET(RESTRICTED))
|
||||||
if (ISSET(RESTRICTED)) {
|
continue;
|
||||||
statusbar(_("Error writing %s: %s"), answer,
|
else {
|
||||||
strerror(EEXIST));
|
|
||||||
retval = -1;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
i = do_yesno_prompt(FALSE,
|
i = do_yesno_prompt(FALSE,
|
||||||
_("File exists, OVERWRITE ? "));
|
_("File exists, OVERWRITE ? "));
|
||||||
if (i == 0 || i == -1)
|
if (i == 0 || i == -1)
|
||||||
|
@ -1899,9 +1895,7 @@ int do_writeout(bool exiting)
|
||||||
/* If we're using restricted mode, we aren't allowed
|
/* If we're using restricted mode, we aren't allowed
|
||||||
* to change the name of a file once it has one,
|
* to change the name of a file once it has one,
|
||||||
* because that would allow reading from or writing
|
* because that would allow reading from or writing
|
||||||
* to files not specified on the command line. In
|
* to files not specified on the command line. */
|
||||||
* this case, don't bother showing the "Different
|
|
||||||
* Name" prompt. */
|
|
||||||
} else if (!ISSET(RESTRICTED) &&
|
} else if (!ISSET(RESTRICTED) &&
|
||||||
openfile->filename[0] != '\0'
|
openfile->filename[0] != '\0'
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
|
Loading…
Reference in New Issue