aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-03-18 01:19:23 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-03-18 01:19:23 +0000
commit2971ef1730db326e20e84ae8882d326f5aa09235 (patch)
treea2fa6b71f3fbaa1e3b783a703160e810fdc71134
parent737f5fb890738ab9c28201768f26fa6b42409284 (diff)
downloadbusybox-2971ef1730db326e20e84ae8882d326f5aa09235.tar.gz
Fix a bug that corrupted the string followed commands that had no arguments (Closes #1304)
-rw-r--r--editors/sed.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/editors/sed.c b/editors/sed.c
index e1242671e..7ff81da79 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -377,16 +377,13 @@ static int parse_file_cmd(sed_cmd_t *sed_cmd, const char *filecmdstr)
return idx + filenamelen;
}
-
+/*
+ * Process the commands arguments
+ */
static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr)
{
- /* if it was a single-letter command that takes no arguments (such as 'p'
- * or 'd') all we need to do is increment the index past that command */
- if (strchr("nNpPqd=", sed_cmd->cmd)) {
- cmdstr++;
- }
/* handle (s)ubstitution command */
- else if (sed_cmd->cmd == 's') {
+ if (sed_cmd->cmd == 's') {
cmdstr += parse_subst_cmd(sed_cmd, cmdstr);
}
/* handle edit cmds: (a)ppend, (i)nsert, and (c)hange */
@@ -401,7 +398,10 @@ static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr)
error_msg_and_die("Command only uses one address");
cmdstr += parse_file_cmd(sed_cmd, cmdstr);
}
- else {
+ /* if it wasnt a single-letter command that takes no arguments
+ * then it must be an invalid command.
+ */
+ else if (strchr("nNpPqd=", sed_cmd->cmd) == 0) {
error_msg_and_die("Unsupported command %c", sed_cmd->cmd);
}