From 8274e06677ba55532a4e1488b659f0b1e743130e Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 6 Aug 2007 03:41:08 +0000 Subject: sed: fix 'q' command handling ("Nguyen Thai Ngoc Duy" ) add testsuite entry for it. Fix applet order checker. Fix cmp yelling. trylink: fix error file and map file generation applets: fix applet order --- editors/sed.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'editors') 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 #define sed_puts(s, n) (puts_maybe_newline(s, G.nonstdout, &last_puts_char, n)) +static int beg_match(sed_cmd_t *sed_cmd, const char *pattern_space) +{ + int retval = sed_cmd->beg_match && !regexec(sed_cmd->beg_match, pattern_space, 0, NULL, 0); + if (retval) + G.previous_regex_ptr = sed_cmd->beg_match; + return retval; +} + /* Process all the lines in all the files */ static void process_files(void) @@ -880,8 +888,7 @@ restart: /* Or did we match the start of a numerical range? */ || (sed_cmd->beg_line > 0 && (sed_cmd->beg_line == linenum)) /* Or does this line match our begin address regex? */ - || (sed_cmd->beg_match && - !regexec(sed_cmd->beg_match, pattern_space, 0, NULL, 0)) + || (beg_match(sed_cmd, pattern_space)) /* Or did we match last line of input? */ || (sed_cmd->beg_line == -1 && next_line == NULL); -- cgit v1.2.3