bug-ed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-ed] Reading something into an empty file should set "changed" flag


From: Martin Guy
Subject: [Bug-ed] Reading something into an empty file should set "changed" flag
Date: Sun, 27 Mar 2011 08:17:17 +0200

Hi again
  Editing an empty file and reading something into it doesn't set the
"changed" flag.  For example

$ true > foo
$ echo "word" > bar
$ ed foo
0
r bar
5
q
$

since the default file is still "foo", and the buffer now has
different contents from the disk file, this should probably refuse to
quit.

The fix seems to be in the main_loop command 'r' clause:

--- ed-1.5.orig/main_loop.c     2011-03-27 08:08:57.930673137 +0200
+++ ed-1.5/main_loop.c  2011-03-27 08:09:25.202673149 +0200
@@ -544,7 +544,7 @@
                 { set_error_msg( "No current filename" ); return ERR; }
               addr = read_file( fnp[0] ? fnp : def_filename, second_addr );
               if( addr < 0 ) return ERR;
-              if( addr && addr != last_addr() ) set_modified( true );
+              if( addr ) set_modified( true );
               break;
     case 's': if( !command_s( ibufpp, &gflags, addr_cnt, isglobal ) )
                 return ERR;

Sorry about all this mail - I'm reimplementing "ed" in another
language, so am involved in a lot of code inspection.

Cheers

    M



reply via email to

[Prev in Thread] Current Thread [Next in Thread]