aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c
index d0c2ca742..4647079aa 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -836,6 +836,14 @@ static void puts_maybe_newline(char *s, FILE *file, char *last_puts_char, char l
836 836
837#define sed_puts(s, n) (puts_maybe_newline(s, G.nonstdout, &last_puts_char, n)) 837#define sed_puts(s, n) (puts_maybe_newline(s, G.nonstdout, &last_puts_char, n))
838 838
839static int beg_match(sed_cmd_t *sed_cmd, const char *pattern_space)
840{
841 int retval = sed_cmd->beg_match && !regexec(sed_cmd->beg_match, pattern_space, 0, NULL, 0);
842 if (retval)
843 G.previous_regex_ptr = sed_cmd->beg_match;
844 return retval;
845}
846
839/* Process all the lines in all the files */ 847/* Process all the lines in all the files */
840 848
841static void process_files(void) 849static void process_files(void)
@@ -880,8 +888,7 @@ restart:
880 /* Or did we match the start of a numerical range? */ 888 /* Or did we match the start of a numerical range? */
881 || (sed_cmd->beg_line > 0 && (sed_cmd->beg_line == linenum)) 889 || (sed_cmd->beg_line > 0 && (sed_cmd->beg_line == linenum))
882 /* Or does this line match our begin address regex? */ 890 /* Or does this line match our begin address regex? */
883 || (sed_cmd->beg_match && 891 || (beg_match(sed_cmd, pattern_space))
884 !regexec(sed_cmd->beg_match, pattern_space, 0, NULL, 0))
885 /* Or did we match last line of input? */ 892 /* Or did we match last line of input? */
886 || (sed_cmd->beg_line == -1 && next_line == NULL); 893 || (sed_cmd->beg_line == -1 && next_line == NULL);
887 894