diff options
Diffstat (limited to 'editors/sed.c')
-rw-r--r-- | editors/sed.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/editors/sed.c b/editors/sed.c index 2127301d5..ed12e4336 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -894,12 +894,13 @@ static void process_files(void) | |||
894 | || (!sed_cmd->beg_line && !sed_cmd->end_line | 894 | || (!sed_cmd->beg_line && !sed_cmd->end_line |
895 | && !sed_cmd->beg_match && !sed_cmd->end_match) | 895 | && !sed_cmd->beg_match && !sed_cmd->end_match) |
896 | /* Or did we match the start of a numerical range? */ | 896 | /* Or did we match the start of a numerical range? */ |
897 | || (sed_cmd->beg_line > 0 && (sed_cmd->beg_line == linenum | 897 | || (sed_cmd->beg_line > 0 |
898 | /* "shadowed beginning" case: "1d;1,ENDp" - p still matches at line 2 | 898 | && (sed_cmd->beg_line == linenum |
899 | * even though 1d skipped line 1 which is a start line for p */ | 899 | /* GNU sed compat: |
900 | || (sed_cmd->end_line && sed_cmd->beg_line < linenum && sed_cmd->end_line >= linenum) | 900 | * "shadowed beginning" case: "1d;1,ENDp" - p still matches at line 2 |
901 | || (sed_cmd->end_match && sed_cmd->beg_line < linenum) | 901 | * even though 1d skipped line 1 which is a start line for p */ |
902 | ) | 902 | || (sed_cmd->beg_line < linenum && (sed_cmd->end_line > 0 || sed_cmd->end_match)) |
903 | ) | ||
903 | ) | 904 | ) |
904 | /* Or does this line match our begin address regex? */ | 905 | /* Or does this line match our begin address regex? */ |
905 | || (beg_match(sed_cmd, pattern_space)) | 906 | || (beg_match(sed_cmd, pattern_space)) |
@@ -928,12 +929,10 @@ static void process_files(void) | |||
928 | && (regexec(sed_cmd->end_match, | 929 | && (regexec(sed_cmd->end_match, |
929 | pattern_space, 0, NULL, 0) == 0) | 930 | pattern_space, 0, NULL, 0) == 0) |
930 | ); | 931 | ); |
931 | if (n && sed_cmd->beg_line > 0) { | 932 | } |
932 | /* Once matched, "n,regex" range is dead, disabling it */ | 933 | if (n && sed_cmd->beg_line > 0) { |
933 | regfree(sed_cmd->end_match); | 934 | /* once matched, "n,xxx" range is dead, disabling it */ |
934 | free(sed_cmd->end_match); | 935 | sed_cmd->beg_line = -2; |
935 | sed_cmd->end_match = NULL; | ||
936 | } | ||
937 | } | 936 | } |
938 | sed_cmd->in_match = !n; | 937 | sed_cmd->in_match = !n; |
939 | } | 938 | } |