]> git.wh0rd.org Git - nano.git/commitdiff
simplify do_writeout()
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Sat, 21 Apr 2007 18:23:06 +0000 (18:23 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Sat, 21 Apr 2007 18:23:06 +0000 (18:23 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_0_branch/nano@4090 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index 99997d4bfcbdacf439fe4b64c548951bd6153393..ade7b617bb2786743b6c67a4691d6ae290812446 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@ CVS code -
          with no name under an existing file's name. (DLR)
        - Rename variable different_name to do_warning, for clarity.
          (DLR)
+       - Simplify. (DLR)
   input_tab()
        - Don't bother checking if num_matches is less than zero, as
          it's a size_t and hence unsigned. (DLR)
index 1492c9c8c8d73f64da8e91df5121a5d6fbfbdaf4..5e07880a080126dca50691847c03c819d241560e 100644 (file)
@@ -1921,27 +1921,25 @@ bool do_writeout(bool exiting)
                    free(full_answer);
 
                if (do_warning) {
-                   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. */
-                       if (ISSET(RESTRICTED))
-                           continue;
+                   /* If we're using restricted mode, we aren't allowed
+                    * to overwrite an existing file with the current
+                    * file.  We also aren't allowed to change the name
+                    * of the current file if it has one, because that
+                    * would allow reading from or writing to files not
+                    * specified on the command line. */
+                   if (ISSET(RESTRICTED))
+                       continue;
 
+                   if (name_exists) {
                        i = do_yesno_prompt(FALSE,
                                _("File exists, OVERWRITE ? "));
                        if (i == 0 || i == -1)
                            continue;
-                   /* 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. */
-                   } else if (!ISSET(RESTRICTED) &&
-                       openfile->filename[0] != '\0'
+                   } else
 #ifndef NANO_TINY
-                       && (exiting || !openfile->mark_set)
+                   if (exiting || !openfile->mark_set)
 #endif
-                       ) {
+                   {
                        i = do_yesno_prompt(FALSE,
                                _("Save file under DIFFERENT NAME ? "));
                        if (i == 0 || i == -1)