sed: remove now-redundant backslash-newline handling

4b0bb9e0fd added this code in 2007,
then in a2215b98f7 more general fix
was added.

function                                             old     new   delta
add_cmd_block                                         98      58     -40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
1_22_stable
Denys Vlasenko 2013-07-08 02:04:44 +02:00
parent e93d15613e
commit 40ab27a225
1 changed files with 2 additions and 16 deletions

View File

@ -1377,7 +1377,7 @@ static void process_files(void)
/* It is possible to have a command line argument with embedded /* It is possible to have a command line argument with embedded
* newlines. This counts as multiple command lines. * newlines. This counts as multiple command lines.
* However, newline can be escaped: 's/e/z\<newline>z/' * However, newline can be escaped: 's/e/z\<newline>z/'
* We check for this. * add_cmd() handles this.
*/ */
static void add_cmd_block(char *cmdstr) static void add_cmd_block(char *cmdstr)
@ -1387,22 +1387,8 @@ static void add_cmd_block(char *cmdstr)
cmdstr = sv = xstrdup(cmdstr); cmdstr = sv = xstrdup(cmdstr);
do { do {
eol = strchr(cmdstr, '\n'); eol = strchr(cmdstr, '\n');
next: if (eol)
if (eol) {
/* Count preceding slashes */
int slashes = 0;
char *sl = eol;
while (sl != cmdstr && *--sl == '\\')
slashes++;
/* Odd number of preceding slashes - newline is escaped */
if (slashes & 1) {
overlapping_strcpy(eol - 1, eol);
eol = strchr(eol, '\n');
goto next;
}
*eol = '\0'; *eol = '\0';
}
add_cmd(cmdstr); add_cmd(cmdstr);
cmdstr = eol + 1; cmdstr = eol + 1;
} while (eol); } while (eol);