aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/sed.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/editors/sed.c b/editors/sed.c
index f90bc5449..e625a0965 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1377,7 +1377,7 @@ static void process_files(void)
1377/* It is possible to have a command line argument with embedded 1377/* It is possible to have a command line argument with embedded
1378 * newlines. This counts as multiple command lines. 1378 * newlines. This counts as multiple command lines.
1379 * However, newline can be escaped: 's/e/z\<newline>z/' 1379 * However, newline can be escaped: 's/e/z\<newline>z/'
1380 * We check for this. 1380 * add_cmd() handles this.
1381 */ 1381 */
1382 1382
1383static void add_cmd_block(char *cmdstr) 1383static void add_cmd_block(char *cmdstr)
@@ -1387,22 +1387,8 @@ static void add_cmd_block(char *cmdstr)
1387 cmdstr = sv = xstrdup(cmdstr); 1387 cmdstr = sv = xstrdup(cmdstr);
1388 do { 1388 do {
1389 eol = strchr(cmdstr, '\n'); 1389 eol = strchr(cmdstr, '\n');
1390 next: 1390 if (eol)
1391 if (eol) {
1392 /* Count preceding slashes */
1393 int slashes = 0;
1394 char *sl = eol;
1395
1396 while (sl != cmdstr && *--sl == '\\')
1397 slashes++;
1398 /* Odd number of preceding slashes - newline is escaped */
1399 if (slashes & 1) {
1400 overlapping_strcpy(eol - 1, eol);
1401 eol = strchr(eol, '\n');
1402 goto next;
1403 }
1404 *eol = '\0'; 1391 *eol = '\0';
1405 }
1406 add_cmd(cmdstr); 1392 add_cmd(cmdstr);
1407 cmdstr = eol + 1; 1393 cmdstr = eol + 1;
1408 } while (eol); 1394 } while (eol);