diff --git a/editors/sed.c b/editors/sed.c index ae8d9832e..db364e3ee 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -34,7 +34,10 @@ resulting sed_cmd_t structures are appended to a linked list (sed_cmd_head/sed_cmd_tail). - process_file() does actual sedding, reading data lines from an input FILE * + add_input_file() adds a FILE * to the list of input files. We need to + know them all ahead of time to find the last line for the $ match. + + process_files() does actual sedding, reading data lines from each input FILE * (which could be stdin) and applying the sed command list (sed_cmd_head) to each of the resulting lines. @@ -116,6 +119,9 @@ static int be_quiet, in_place, regex_type; FILE *nonstdout; char *outname,*hold_space; +/* List of input files */ +int input_file_count,current_input_file; +FILE **input_file_list; static const char bad_format_in_subst[] = "bad format in substitution expression"; @@ -171,6 +177,9 @@ static void free_and_close_stuff(void) } if(hold_space) free(hold_space); + + while(current_input_filecurrent_input_file) process_files(); } return status;