aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-07-14 01:02:57 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-07-14 01:02:57 +0200
commit8e96b5b5314c3f2c3fdb6fd04abfa3e73ac27a5a (patch)
tree52a023e31acf6314c2a7ce8d5d3a807b31781298 /editors
parent2907e7974924e7e8f1a64874b5c3cb48ebd25d5d (diff)
downloadbusybox-8e96b5b5314c3f2c3fdb6fd04abfa3e73ac27a5a.tar.gz
sed: simpler fix for recent GNU compat stuff (by Rob Landley)
function old new delta process_files 2120 2102 -18 Signed-off-by: Rob Landley <rob@landley.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/editors/sed.c b/editors/sed.c
index ed12e4336..de18996b8 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -888,53 +888,44 @@ static void process_files(void)
old_matched = sed_cmd->in_match;
/* Determine if this command matches this line: */
- /* Are we continuing a previous multi-line match? */
+
+ /* Are we continuing a previous multi-line match? */
sed_cmd->in_match = sed_cmd->in_match
/* Or is no range necessary? */
|| (!sed_cmd->beg_line && !sed_cmd->end_line
&& !sed_cmd->beg_match && !sed_cmd->end_match)
/* Or did we match the start of a numerical range? */
- || (sed_cmd->beg_line > 0
- && (sed_cmd->beg_line == linenum
- /* GNU sed compat:
- * "shadowed beginning" case: "1d;1,ENDp" - p still matches at line 2
- * even though 1d skipped line 1 which is a start line for p */
- || (sed_cmd->beg_line < linenum && (sed_cmd->end_line > 0 || sed_cmd->end_match))
- )
- )
+ || (sed_cmd->beg_line > 0 && (sed_cmd->beg_line <= linenum))
/* Or does this line match our begin address regex? */
|| (beg_match(sed_cmd, pattern_space))
/* Or did we match last line of input? */
|| (sed_cmd->beg_line == -1 && next_line == NULL);
+ /* Snapshot the value */
matched = sed_cmd->in_match;
//bb_error_msg("cmd:'%c' matched:%d beg_line:%d end_line:%d linenum:%d",
//sed_cmd->cmd, matched, sed_cmd->beg_line, sed_cmd->end_line, linenum);
/* Is this line the end of the current match? */
+
if (matched) {
- int n = (
+ /* once matched, "n,xxx" range is dead, disabling it */
+ if (sed_cmd->beg_line > 0)
+ sed_cmd->beg_line = -2;
+ sed_cmd->in_match = !(
/* has the ending line come, or is this a single address command? */
- sed_cmd->end_line ?
+ (sed_cmd->end_line ?
sed_cmd->end_line == -1 ?
!next_line
: (sed_cmd->end_line <= linenum)
: !sed_cmd->end_match
- );
- if (!n) {
+ )
/* or does this line matches our last address regex */
- n = (sed_cmd->end_match
- && old_matched
+ || (sed_cmd->end_match && old_matched
&& (regexec(sed_cmd->end_match,
- pattern_space, 0, NULL, 0) == 0)
- );
- }
- if (n && sed_cmd->beg_line > 0) {
- /* once matched, "n,xxx" range is dead, disabling it */
- sed_cmd->beg_line = -2;
- }
- sed_cmd->in_match = !n;
+ pattern_space, 0, NULL, 0) == 0))
+ );
}
/* Skip blocks of commands we didn't match */