aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-10-01 06:45:11 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-10-01 06:45:11 +0000
commit738fb33994dd60ccbb33b328bd6028836a463490 (patch)
tree5dbb7fe21f0461f268ed1742ed53712759beca19
parentaa5a602689265a4351c890efe5d8e7793e777e3c (diff)
downloadbusybox-738fb33994dd60ccbb33b328bd6028836a463490.tar.gz
Patch by Rob Landley, fix "newline after edit command"
-rw-r--r--editors/sed.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 6452a321c..3d6d72c68 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -176,8 +176,8 @@ static void parse_escapes(char *dest, const char *string, int len, char from, ch
while(i<len) {
if(string[i] == '\\') {
- if(string[i+1] == from) {
- *(dest++) = to;
+ if(!to || string[i+1] == from) {
+ *(dest++) = to ? to : string[i+1];
i+=2;
continue;
} else *(dest++)=string[i++];
@@ -403,6 +403,7 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr)
("only a beginning address can be specified for edit commands");
while(isspace(*cmdstr)) cmdstr++;
sed_cmd->string = bb_xstrdup(cmdstr);
+ parse_escapes(sed_cmd->string,sed_cmd->string,strlen(cmdstr),0,0);
cmdstr += strlen(cmdstr);
/* handle file cmds: (r)ead */
} else if(strchr("rw", sed_cmd->cmd)) {