diff options
-rw-r--r-- | editors/sed.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c index d49627ff4..b6218446f 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -830,6 +830,14 @@ static void puts_maybe_newline(char *s, FILE *file, char *last_puts_char, char l | |||
830 | 830 | ||
831 | #define sed_puts(s, n) (puts_maybe_newline(s, G.nonstdout, &last_puts_char, n)) | 831 | #define sed_puts(s, n) (puts_maybe_newline(s, G.nonstdout, &last_puts_char, n)) |
832 | 832 | ||
833 | static inline int beg_match(sed_cmd_t *sed_cmd, const char *pattern_space) | ||
834 | { | ||
835 | int retval = sed_cmd->beg_match && !regexec(sed_cmd->beg_match, pattern_space, 0, NULL, 0); | ||
836 | if (retval) | ||
837 | G.previous_regex_ptr = sed_cmd->beg_match; | ||
838 | return retval; | ||
839 | } | ||
840 | |||
833 | /* Process all the lines in all the files */ | 841 | /* Process all the lines in all the files */ |
834 | 842 | ||
835 | static void process_files(void) | 843 | static void process_files(void) |
@@ -874,8 +882,7 @@ restart: | |||
874 | /* Or did we match the start of a numerical range? */ | 882 | /* Or did we match the start of a numerical range? */ |
875 | || (sed_cmd->beg_line > 0 && (sed_cmd->beg_line == linenum)) | 883 | || (sed_cmd->beg_line > 0 && (sed_cmd->beg_line == linenum)) |
876 | /* Or does this line match our begin address regex? */ | 884 | /* Or does this line match our begin address regex? */ |
877 | || (sed_cmd->beg_match && | 885 | || (beg_match(sed_cmd, pattern_space)) |
878 | !regexec(sed_cmd->beg_match, pattern_space, 0, NULL, 0)) | ||
879 | /* Or did we match last line of input? */ | 886 | /* Or did we match last line of input? */ |
880 | || (sed_cmd->beg_line == -1 && next_line == NULL); | 887 | || (sed_cmd->beg_line == -1 && next_line == NULL); |
881 | 888 | ||