[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nano-devel
Subject:    [Nano-devel] [PATCH] files: report an unwritable file in a separate message
From:       Benno Schulenberg <bensberg () justemail ! net>
Date:       2016-05-29 12:53:55
Message-ID: 1464526435-2999-1-git-send-email-bensberg () justemail ! net
[Download RAW message or body]

That is: don't mix the number of lines read with a warning about the
file being unwritable -- the former is just convenience information,
the latter is a must-see.

This fixes https://savannah.gnu.org/bugs/?48047.
---
 src/files.c | 32 +++++---------------------------
 1 file changed, 5 insertions(+), 27 deletions(-)

diff --git a/src/files.c b/src/files.c
index c76ac90..6fe4fcb 100644
--- a/src/files.c
+++ b/src/files.c
@@ -904,52 +904,30 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
     if (undoable)
 	update_undo(INSERT);
 
-    if (format == 3) {
-	if (writable)
+    if (!writable)
+	statusline(ALERT, "File '%s' is unwritable", filename);
+    else if (format == 3) {
 	    statusline(HUSH,
+	    /* TRANSLATORS: Keep the next four messages at most 76 characters. */
 		P_("Read %lu line (Converted from DOS and Mac format)",
 		"Read %lu lines (Converted from DOS and Mac format)",
 		(unsigned long)num_lines), (unsigned long)num_lines);
-	else
-	    /* TRANSLATORS: Keep the next handful of messages at most 76 characters long. */
-	    statusline(ALERT,
-		P_("Read %lu line (Converted from DOS and Mac format - NO write permission)",
-		"Read %lu lines (Converted from DOS and Mac format - NO write permission)",
-		(unsigned long)num_lines), (unsigned long)num_lines);
     } else if (format == 2) {
 	openfile->fmt = MAC_FILE;
-	if (writable)
 	    statusline(HUSH,
 		P_("Read %lu line (Converted from Mac format)",
 		"Read %lu lines (Converted from Mac format)",
 		(unsigned long)num_lines), (unsigned long)num_lines);
-	else
-	    statusline(ALERT,
-		P_("Read %lu line (Converted from Mac format - Warning: No write permission)",
-		"Read %lu lines (Converted from Mac format - Warning: No write permission)",
-		(unsigned long)num_lines), (unsigned long)num_lines);
     } else if (format == 1) {
 	openfile->fmt = DOS_FILE;
-	if (writable)
 	    statusline(HUSH,
 		P_("Read %lu line (Converted from DOS format)",
 		"Read %lu lines (Converted from DOS format)",
 		(unsigned long)num_lines), (unsigned long)num_lines);
-	else
-	    statusline(ALERT,
-		P_("Read %lu line (Converted from DOS format - Warning: No write permission)",
-		"Read %lu lines (Converted from DOS format - Warning: No write permission)",
-		(unsigned long)num_lines), (unsigned long)num_lines);
     } else
-#endif
-	if (writable)
+#endif /* !NANO_TINY */
 	    statusline(HUSH, P_("Read %lu line", "Read %lu lines",
 		(unsigned long)num_lines), (unsigned long)num_lines);
-	else
-	    statusline(ALERT,
-		P_("Read %lu line (Warning: No write permission)",
-		"Read %lu lines (Warning: No write permission)",
-		(unsigned long)num_lines), (unsigned long)num_lines);
 
     if (num_lines < editwinrows)
 	focusing = FALSE;
-- 
2.8.1


_______________________________________________
Nano-devel mailing list
Nano-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/nano-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic