diff options
author | Mark Whitley <markw@lineo.com> | 2000-07-14 00:49:59 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2000-07-14 00:49:59 +0000 |
commit | 34623db61895ab5575f7851c9313ab2bf4fecc03 (patch) | |
tree | 577d93df5005b4187cd30aa025bb258bee40b850 | |
parent | 02008346c0e278701945652cd5fac5239c96891c (diff) | |
download | busybox-w32-34623db61895ab5575f7851c9313ab2bf4fecc03.tar.gz busybox-w32-34623db61895ab5575f7851c9313ab2bf4fecc03.tar.bz2 busybox-w32-34623db61895ab5575f7851c9313ab2bf4fecc03.zip |
It dawned on me that I would need to grow a char buffer one extra char bigger
to accomodate a trailing '\n'ewline that I append to it later one. This is
only necessary for the case of one inserted, appended, or changed line, but
it's still necessary.
-rw-r--r-- | editors/sed.c | 5 | ||||
-rw-r--r-- | sed.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c index 115783f09..770a56eeb 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -309,7 +309,10 @@ static void parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr) | |||
309 | fatalError("bad format in edit expression\n"); | 309 | fatalError("bad format in edit expression\n"); |
310 | 310 | ||
311 | /* store the edit line text */ | 311 | /* store the edit line text */ |
312 | sed_cmd->editline = strdup(&editstr[3]); | 312 | /* make editline big enough to accomodate the extra '\n' we will tack on |
313 | * to the end */ | ||
314 | sed_cmd->editline = xmalloc(strlen(&editstr[3]) + 2); | ||
315 | strcpy(sed_cmd->editline, &editstr[3]); | ||
313 | ptr = sed_cmd->editline; | 316 | ptr = sed_cmd->editline; |
314 | 317 | ||
315 | /* now we need to go through * and: s/\\[\r\n]$/\n/g on the edit line */ | 318 | /* now we need to go through * and: s/\\[\r\n]$/\n/g on the edit line */ |
@@ -309,7 +309,10 @@ static void parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr) | |||
309 | fatalError("bad format in edit expression\n"); | 309 | fatalError("bad format in edit expression\n"); |
310 | 310 | ||
311 | /* store the edit line text */ | 311 | /* store the edit line text */ |
312 | sed_cmd->editline = strdup(&editstr[3]); | 312 | /* make editline big enough to accomodate the extra '\n' we will tack on |
313 | * to the end */ | ||
314 | sed_cmd->editline = xmalloc(strlen(&editstr[3]) + 2); | ||
315 | strcpy(sed_cmd->editline, &editstr[3]); | ||
313 | ptr = sed_cmd->editline; | 316 | ptr = sed_cmd->editline; |
314 | 317 | ||
315 | /* now we need to go through * and: s/\\[\r\n]$/\n/g on the edit line */ | 318 | /* now we need to go through * and: s/\\[\r\n]$/\n/g on the edit line */ |