]> git.wh0rd.org Git - nano.git/commitdiff
in get_full_path(), fix problem where only paths would be returned when
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Wed, 8 Nov 2006 02:48:15 +0000 (02:48 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Wed, 8 Nov 2006 02:48:15 +0000 (02:48 +0000)
both paths and filenames should have been

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3944 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index 2bdf16d2ed800bf37f96b0137f5f25dfd96dea98..47c45251639045c1a3c9f645dfd7e7e8077dc38f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@ CVS code -
 - files.c:
   get_full_path()
        - Remove unneeded assert. (DLR)
+       - Fix problem where only paths would be returned when both paths
+         and filenames should have been. (DLR)
   do_writeout()
        - For consistency, when saving a file with no name, don't
          allow overwriting an existing file when in restricted
index 1358a95fd5520d35754d614ed88fb5001d229d9a..2f370469151d268fa7029e83386b1d8ffbe125a6 100644 (file)
@@ -986,8 +986,7 @@ char *get_full_path(const char *origpath)
        if (!path_only)
            d_there_file = mallocstrcpy(NULL, last_slash + 1);
 
-       /* And remove the filename portion of the answer from
-        * d_there. */
+       /* Remove the filename portion of the answer from d_there. */
        null_at(&d_there, last_slash - d_there + 1);
 
        /* Go to the path specified in d_there. */
@@ -1019,27 +1018,28 @@ char *get_full_path(const char *origpath)
 
            /* Finally, go back to the path specified in d_here,
             * 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);
 
            /* Free d_here, since we're done using it. */
            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) +
+    /* 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);
-       }
+       strcat(d_there, d_there_file);
+    }
 
-       /* Free d_there_file, since we're done using it. */
+    /* Free d_there_file, since we're done using it. */
+    if (d_there_file != NULL)
        free(d_there_file);
-    }
 
     return d_there;
 }
@@ -1883,14 +1883,10 @@ int do_writeout(bool exiting)
                    if (name_exists) {
                        /* If we're using restricted mode, we aren't
                         * allowed to save a new file under the name of
-                        * an existing file.  In this case, show a "File
-                        * exists" error. */
-                       if (ISSET(RESTRICTED)) {
-                           statusbar(_("Error writing %s: %s"), answer,
-                               strerror(EEXIST));
-                           retval = -1;
-                           break;
-                       } else {
+                        * an existing file. */
+                       if (ISSET(RESTRICTED))
+                           continue;
+                       else {
                            i = do_yesno_prompt(FALSE,
                                _("File exists, OVERWRITE ? "));
                            if (i == 0 || i == -1)
@@ -1899,9 +1895,7 @@ int do_writeout(bool exiting)
                    /* If we're using restricted mode, we aren't allowed
                     * to change the name of a file once it has one,
                     * because that would allow reading from or writing
-                    * to files not specified on the command line.  In
-                    * this case, don't bother showing the "Different
-                    * Name" prompt. */
+                    * to files not specified on the command line. */
                    } else if (!ISSET(RESTRICTED) &&
                        openfile->filename[0] != '\0'
 #ifndef NANO_TINY