diff options
| author | Xin LI <delphij@FreeBSD.org> | 2015-08-05 22:04:54 +0000 |
|---|---|---|
| committer | Xin LI <delphij@FreeBSD.org> | 2015-08-05 22:04:54 +0000 |
| commit | 3fd78bfab2cdb03bf9a701097e68c8ead33722a2 (patch) | |
| tree | e02ca29c6fa37b9abbd5a409a9a376cd3cc11eab /usr.bin/patch/pch.c | |
| parent | f2a20b166a1efde194b39d8fae5841b843819f4d (diff) | |
Notes
Diffstat (limited to 'usr.bin/patch/pch.c')
| -rw-r--r-- | usr.bin/patch/pch.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index e731ca1f9e8f..5fadf6292f67 100644 --- a/usr.bin/patch/pch.c +++ b/usr.bin/patch/pch.c @@ -1,4 +1,3 @@ - /*- * Copyright 1986, Larry Wall * @@ -1410,13 +1409,14 @@ do_ed_script(void) char *t; off_t beginning_of_this_line; FILE *pipefp = NULL; + int continuation; if (!skip_rest_of_patch) { if (copy_file(filearg[0], TMPOUTNAME) < 0) { unlink(TMPOUTNAME); fatal("can't create temp file %s", TMPOUTNAME); } - snprintf(buf, buf_size, "%s%s%s", _PATH_ED, + snprintf(buf, buf_size, "%s%s%s", _PATH_RED, verbose ? " " : " -s ", TMPOUTNAME); pipefp = popen(buf, "w"); } @@ -1434,7 +1434,19 @@ do_ed_script(void) (*t == 'a' || *t == 'c' || *t == 'd' || *t == 'i' || *t == 's')) { if (pipefp != NULL) fputs(buf, pipefp); - if (*t != 'd') { + if (*t == 's') { + for (;;) { + continuation = 0; + t = strchr(buf, '\0') - 1; + while (--t >= buf && *t == '\\') + continuation = !continuation; + if (!continuation || + pgets(true) == 0) + break; + if (pipefp != NULL) + fputs(buf, pipefp); + } + } else if (*t != 'd') { while (pgets(true)) { p_input_line++; if (pipefp != NULL) |
