sync with OpenBSD -current
This commit is contained in:
parent
a7acbdeab0
commit
c22b8a6120
202 changed files with 3004 additions and 4921 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: b.c,v 1.45 2023/10/30 17:52:54 millert Exp $ */
|
||||
/* $OpenBSD: b.c,v 1.47 2023/11/15 18:56:53 millert Exp $ */
|
||||
/****************************************************************
|
||||
Copyright (C) Lucent Technologies 1997
|
||||
All Rights Reserved
|
||||
|
@ -861,13 +861,15 @@ bool fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum)
|
|||
j = i++;
|
||||
do {
|
||||
r = getrune(f);
|
||||
if ((++j + r.len) >= k) {
|
||||
if (k >= bufsize)
|
||||
if (!adjbuf(&buf, &bufsize, bufsize+1, quantum, 0, "fnematch"))
|
||||
FATAL("stream '%.30s...' too long", buf);
|
||||
if (r.len == 0) {
|
||||
r.len = 1; // store NUL byte for EOF
|
||||
}
|
||||
j += r.len;
|
||||
if (j >= bufsize) {
|
||||
if (!adjbuf(&buf, &bufsize, j+1, quantum, 0, "fnematch"))
|
||||
FATAL("stream '%.30s...' too long", buf);
|
||||
}
|
||||
memcpy(buf + k, r.bytes, r.len);
|
||||
j += r.len - 1; // incremented next time around the loop
|
||||
k += r.len;
|
||||
|
||||
if ((ns = get_gototab(pfa, s, r.rune)) != 0)
|
||||
|
@ -903,13 +905,10 @@ bool fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum)
|
|||
* (except for EOF's nullbyte, if present) and null
|
||||
* terminate the buffer.
|
||||
*/
|
||||
do {
|
||||
int ii;
|
||||
for (ii = r.len; ii > 0; ii--)
|
||||
if (buf[--k] && ungetc(buf[k], f) == EOF)
|
||||
FATAL("unable to ungetc '%c'", buf[k]);
|
||||
} while (k > i + patlen);
|
||||
buf[k] = '\0';
|
||||
for (; r.len > 0; r.len--)
|
||||
if (buf[--k] && ungetc(buf[k], f) == EOF)
|
||||
FATAL("unable to ungetc '%c'", buf[k]);
|
||||
buf[k-patlen] = '\0';
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue