Skip to content

Commit

Permalink
ed: fix append bug (#916)
Browse files Browse the repository at this point in the history
* It is valid usage to start ed with a filename that doesn't exist; ed is expected to start with an empty buffer and the default filename variable set
* Today I found that commands 0i and 0a were resulting in the first line of input being lost
* When debugging this I discovered lines-list was empty when ed was started with a file argument that doesn't exist
* A placeholder item $lines[0] is expected to be populated
* edEdit() was returning early because the file doesn't exist
* Fix this by initialising $lines[0] at start of program, i.e. before the 1st edEdit() call
  • Loading branch information
mknos authored Jan 9, 2025
1 parent 46f717e commit ce74886
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ my $Error = undef; # saved error string for h command
my $Prompt = undef; # saved prompt string for -p option
my $SearchPat; # saved pattern for repeat search
my $Scripted = 0;
my @lines; # buffer for file being edited.
my @lines = ( 0 ); # buffer for file being edited.
my $command; # single letter command entered by user
my $commandsuf; # single letter modifier of command
my @adrs; # 1 or 2 line numbers for commands to operate on
Expand All @@ -105,7 +105,7 @@ my $NO_QUESTIONS_MODE = 0;
my $PRINT_NUM = 1;
my $PRINT_BIN = 2;

our $VERSION = '0.24';
our $VERSION = '0.25';

my @ESC = (
'\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\a',
Expand Down

0 comments on commit ce74886

Please sign in to comment.