From acb6234263e2a43af5201b613ec136f3ab65e903 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Fri, 21 Jul 2000 22:42:46 +0000 Subject: [PATCH] Added code to check to see if using -l and the file is not fact a link. Please test git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@111 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- BUGS | 2 +- ChangeLog | 6 ++++++ files.c | 7 ++++++- po/nano.pot | 24 ++++++++++++------------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/BUGS b/BUGS index 418a027c..d377b979 100644 --- a/BUGS +++ b/BUGS @@ -28,7 +28,7 @@ - If nano opens a read-only file with the --tempfile option, and a change is made to the buffer, and a write is attempted, nano will not give you a dialog about not being able to write the file, and it will not let the - user exit (29, discovered by Joshua Jensen) [FIXED mostly] + user exit (29, discovered by Joshua Jensen) [FIXED] ** Open BUGS ** diff --git a/ChangeLog b/ChangeLog index e381a870..77c79c55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,12 @@ Current CVS: read_file(): - Added init of buf variable, hopefully this will stop the "bleeding" of text seen with mutt and using i18n. + write_file(): + - Added code to check to see if using -l and the file is not + in fact a link. This should fix the behavior where a file + that does not have write permission but could be removed and + rewritten is saved without error. Please test this feature + and give feedback. - search.c: search_init(): - Added " (to replace)" statement to end of search string if diff --git a/files.c b/files.c index a4198ffb..57f5c1b3 100644 --- a/files.c +++ b/files.c @@ -300,8 +300,13 @@ int write_file(char *name, int tmp) fileptr = fileage; + /* Check to see if the file is a regular file and FOLLOW_SYMLINKS is + set. If so then don't do the delete and recreate code which would + cause unexpected behavior */ + lstat(name, &st); + /* Open the file and truncate it. Trust the symlink. */ - if (ISSET(FOLLOW_SYMLINKS) && !tmp) { + 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 diff --git a/po/nano.pot b/po/nano.pot index 4520fc63..1ad92f6c 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-18 21:16-0400\n" +"POT-Creation-Date: 2000-07-21 18:43-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -55,55 +55,55 @@ msgstr "" msgid "File to insert [from ./] " msgstr "" -#: files.c:272 files.c:296 files.c:483 nano.c:1147 +#: files.c:272 files.c:296 files.c:488 nano.c:1147 msgid "Cancelled" msgstr "" -#: files.c:326 files.c:346 files.c:359 files.c:376 files.c:382 +#: files.c:331 files.c:351 files.c:364 files.c:381 files.c:387 #, c-format msgid "Could not open file for writing: %s" msgstr "" -#: files.c:334 +#: files.c:339 msgid "Could not open file: Path length exceeded." msgstr "" -#: files.c:364 +#: files.c:369 #, c-format msgid "Wrote >%s\n" msgstr "" -#: files.c:391 +#: files.c:396 #, c-format msgid "Could not close %s: %s" msgstr "" #. Try a rename?? -#: files.c:412 files.c:423 files.c:428 +#: files.c:417 files.c:428 files.c:433 #, c-format msgid "Could not open %s for writing: %s" msgstr "" -#: files.c:434 +#: files.c:439 #, c-format msgid "Could not set permissions %o on %s: %s" msgstr "" -#: files.c:441 +#: files.c:446 #, c-format msgid "Wrote %d lines" msgstr "" -#: files.c:462 +#: files.c:467 msgid "File Name to write" msgstr "" -#: files.c:467 +#: files.c:472 #, c-format msgid "filename is %s" msgstr "" -#: files.c:472 +#: files.c:477 msgid "File exists, OVERWRITE ?" msgstr ""