nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0293eac1d1747b45c8e1e20d9c6b7e27a5e272ca
parent 0172cb0e83acd1424314a8104149ce258b01a731
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sun, 29 May 2016 14:43:26 +0200

files: report an unwritable file in a separate message

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.

Diffstat:
Msrc/files.c | 32+++++---------------------------
1 file changed, 5 insertions(+), 27 deletions(-)

diff --git 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;