mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-23 01:53:46 +01:00
Yet^2 another fix for the line continuation bug.
The fundamental problem with the original code is that it accesses p[-2] which is one before the beginning of the input buffer for empty lines. rev.1.6 just moved the problem from failures when p[-2] happens to be '\\' to failures when it happens to be '\0'. rev.1.5 was confused about the trailing newline and other things. I went back to rev.1.5 and fixed it. The result is the same as Keith Bostic's final version in PR 1356 except it loses more gracefully for excessively long input lines.
This commit is contained in:
parent
65d98215ea
commit
49e6559936
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17195
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user