summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko2014-09-16 01:11:13 +0200
committerDenys Vlasenko2014-09-16 01:11:13 +0200
commit9caea2448e168560de306a1496574dd58c645fea (patch)
tree33c156525649779bfcff3a5f0b9711a23704dbf6 /editors
parent7666fa1d02b4e7e74a83833881caef09b475b88b (diff)
downloadbusybox-9caea2448e168560de306a1496574dd58c645fea.zip
busybox-9caea2448e168560de306a1496574dd58c645fea.tar.gz
sed: fix a buglet in s///NUM handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c
index e18e48a..e1b8352 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -395,7 +395,9 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr)
/* process the flags */
sed_cmd->which_match = 1;
+ dbg("s flags:'%s'", substr + idx + 1);
while (substr[++idx]) {
+ dbg("s flag:'%c'", substr[idx]);
/* Parse match number */
if (isdigit(substr[idx])) {
if (match[0] != '^') {
@@ -403,7 +405,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr)
const char *pos = substr + idx;
/* FIXME: error check? */
sed_cmd->which_match = (unsigned)strtol(substr+idx, (char**) &pos, 10);
- idx = pos - substr;
+ idx = pos - substr - 1;
}
continue;
}
@@ -443,6 +445,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr)
case '}':
goto out;
default:
+ dbg("s bad flags:'%s'", substr + idx);
bb_error_msg_and_die("bad option in substitution expression");
}
}