diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/sed.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/editors/sed.c b/editors/sed.c index 70be2e824..bf40877e4 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -422,8 +422,10 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr) | |||
422 | if (sed_cmd->end_line || sed_cmd->end_match) | 422 | if (sed_cmd->end_line || sed_cmd->end_match) |
423 | bb_error_msg_and_die("command only uses one address"); | 423 | bb_error_msg_and_die("command only uses one address"); |
424 | cmdstr += parse_file_cmd(sed_cmd, cmdstr, &sed_cmd->string); | 424 | cmdstr += parse_file_cmd(sed_cmd, cmdstr, &sed_cmd->string); |
425 | if (sed_cmd->cmd == 'w') | 425 | if (sed_cmd->cmd == 'w') { |
426 | sed_cmd->sw_file = xfopen(sed_cmd->string, "w"); | 426 | sed_cmd->sw_file = xfopen(sed_cmd->string, "w"); |
427 | sed_cmd->sw_last_char = '\n'; | ||
428 | } | ||
427 | /* handle branch commands */ | 429 | /* handle branch commands */ |
428 | } else if (strchr(":btT", sed_cmd->cmd)) { | 430 | } else if (strchr(":btT", sed_cmd->cmd)) { |
429 | int length; | 431 | int length; |
@@ -726,7 +728,8 @@ enum { | |||
726 | static char *get_next_line(char *gets_char) | 728 | static char *get_next_line(char *gets_char) |
727 | { | 729 | { |
728 | char *temp = NULL; | 730 | char *temp = NULL; |
729 | int len, gc; | 731 | int len; |
732 | char gc; | ||
730 | 733 | ||
731 | flush_append(); | 734 | flush_append(); |
732 | 735 | ||
@@ -744,9 +747,11 @@ static char *get_next_line(char *gets_char) | |||
744 | char c = temp[len-1]; | 747 | char c = temp[len-1]; |
745 | if (c == '\n' || c == '\0') { | 748 | if (c == '\n' || c == '\0') { |
746 | temp[len-1] = '\0'; | 749 | temp[len-1] = '\0'; |
747 | gc = (unsigned char)c; | 750 | gc = c; |
748 | break; | ||
749 | } | 751 | } |
752 | /* else we put NO_EOL_CHAR into *gets_char */ | ||
753 | break; | ||
754 | |||
750 | /* NB: I had the idea of peeking next file(s) and returning | 755 | /* NB: I had the idea of peeking next file(s) and returning |
751 | * NO_EOL_CHAR only if it is the *last* non-empty | 756 | * NO_EOL_CHAR only if it is the *last* non-empty |
752 | * input file. But there is a case where this won't work: | 757 | * input file. But there is a case where this won't work: |
@@ -754,8 +759,6 @@ static char *get_next_line(char *gets_char) | |||
754 | * file2: "c no\nd no" | 759 | * file2: "c no\nd no" |
755 | * sed -ne 's/woo/bang/p' input1 input2 => "a bang\nb bang" | 760 | * sed -ne 's/woo/bang/p' input1 input2 => "a bang\nb bang" |
756 | * (note: *no* newline after "b bang"!) */ | 761 | * (note: *no* newline after "b bang"!) */ |
757 | |||
758 | break; | ||
759 | } | 762 | } |
760 | /* Close this file and advance to next one */ | 763 | /* Close this file and advance to next one */ |
761 | fclose(bbg.input_file_list[bbg.current_input_file++]); | 764 | fclose(bbg.input_file_list[bbg.current_input_file++]); |