summaryrefslogtreecommitdiff
path: root/usr.bin/sed/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/sed/compile.c')
-rw-r--r--usr.bin/sed/compile.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index 7e113823a66f..c1bb8f9e89a9 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -615,7 +615,7 @@ compile_tr(p, transtab)
static char *
compile_text()
{
- int asize, size;
+ int asize, esc_nl, size;
char *text, *p, *op, *s;
char lbuf[_POSIX2_LINE_MAX + 1];
@@ -626,13 +626,13 @@ compile_text()
op = s = text + size;
p = lbuf;
EATSPACE();
- for (; *p != '\0'; p++) {
- if (*p == '\\')
- *p++ = '\0';
+ for (esc_nl = 0; *p != '\0'; p++) {
+ if (*p == '\\' && p[1] != '\0' && *++p == '\n')
+ esc_nl = 1;
*s++ = *p;
}
size += s - op;
- if (p[-2] != '\0') {
+ if (!esc_nl) {
*s = '\0';
break;
}