From 962c3c9c212d6687952b436382bdd2a81de58961 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Mon, 24 Jul 2000 21:52:17 +0000
Subject: [PATCH] Fix for bug #30, I hope it doesn't break anything else

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@123 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 10 ++++++++--
 files.c     | 31 +++++++++++++------------------
 po/nano.pot | 24 ++++++++++++------------
 3 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b4dce83..21769157 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,15 @@
-Changes in CVS
+Changes in CVS - 
 - nano.h:
 	- Set CUT_TO_END to a different bit than TEMP_OPT.  Fixes bug #32.
 - cut.c:
-  do_cut_text():
+  do_cut_text()
 	- Added check for MARK_ISSET when using CUT_TO_END.  Fixes bug #31.
+- files.c:
+  write_file()
+	- Removed (redundant) check for writing out files with -t.
+  do_writeout()
+	- Changed check for filename to filename[0].  Added some code, 
+	  overall fixes bug #30 =-)
 
 nano-0.9.13 - 07/23/2000
 - Implemented Pico's -k mode.  New flag CUT_TO_END, option (-k, --cut), 
diff --git a/files.c b/files.c
index 57f5c1b3..5feed987 100644
--- a/files.c
+++ b/files.c
@@ -307,20 +307,7 @@ int write_file(char *name, int tmp)
 
     /* Open the file and truncate it.  Trust the symlink. */
     if ((ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(st.st_mode)) && !tmp) {
-	/*
-	 * If TEMP_OPT == 1, check to see if we can append to the file
-	 * first, i.e. to see if we can at least write to the file (stops
-	 * people from getting "locked in" to editor when write fails 
-	 */
-	if (ISSET(TEMP_OPT)) { 
-	    if ((fd = open(name, O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP |
-		S_IWGRP | S_IROTH | S_IWOTH)) == -1) {
-		UNSET(TEMP_OPT);
-		return do_writeout(1);
-	    }
-	    else
-		close(fd);
-	}
+
 	if ((fd = open(name, O_WRONLY | O_CREAT | O_TRUNC,
 		       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
 		       S_IWOTH)) == -1) {
@@ -456,10 +443,18 @@ int do_writeout(int exiting)
 
     strncpy(answer, filename, 132);
 
-    if ((exiting) && (ISSET(TEMP_OPT)) && (filename)) {
-	i = write_file(answer, 0);
-	display_main_list();
-	return i;
+    if ((exiting) && (ISSET(TEMP_OPT))) {
+	if (filename[0])
+	{
+	    i = write_file(answer, 0);
+	    display_main_list();
+	    return i;
+	}
+	else
+	{
+	   UNSET(TEMP_OPT);
+	   return do_exit();
+	}
     }
 
     while (1) {
diff --git a/po/nano.pot b/po/nano.pot
index 1eb51aff..a33f1f2e 100644
--- a/po/nano.pot
+++ b/po/nano.pot
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2000-07-24 14:32-0400\n"
+"POT-Creation-Date: 2000-07-24 17:53-0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -55,55 +55,55 @@ msgstr ""
 msgid "File to insert [from ./] "
 msgstr ""
 
-#: files.c:272 files.c:296 files.c:488 nano.c:1147
+#: files.c:272 files.c:296 files.c:483 nano.c:1147
 msgid "Cancelled"
 msgstr ""
 
-#: files.c:331 files.c:351 files.c:364 files.c:381 files.c:387
+#: files.c:318 files.c:338 files.c:351 files.c:368 files.c:374
 #, c-format
 msgid "Could not open file for writing: %s"
 msgstr ""
 
-#: files.c:339
+#: files.c:326
 msgid "Could not open file: Path length exceeded."
 msgstr ""
 
-#: files.c:369
+#: files.c:356
 #, c-format
 msgid "Wrote >%s\n"
 msgstr ""
 
-#: files.c:396
+#: files.c:383
 #, c-format
 msgid "Could not close %s: %s"
 msgstr ""
 
 #. Try a rename??
-#: files.c:417 files.c:428 files.c:433
+#: files.c:404 files.c:415 files.c:420
 #, c-format
 msgid "Could not open %s for writing: %s"
 msgstr ""
 
-#: files.c:439
+#: files.c:426
 #, c-format
 msgid "Could not set permissions %o on %s: %s"
 msgstr ""
 
-#: files.c:446
+#: files.c:433
 #, c-format
 msgid "Wrote %d lines"
 msgstr ""
 
-#: files.c:467
+#: files.c:462
 msgid "File Name to write"
 msgstr ""
 
-#: files.c:472
+#: files.c:467
 #, c-format
 msgid "filename is %s"
 msgstr ""
 
-#: files.c:477
+#: files.c:472
 msgid "File exists, OVERWRITE ?"
 msgstr ""
 
-- 
GitLab