summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcamield <camield@openbsd.org>2002-10-11 12:46:05 +0000
committercamield <camield@openbsd.org>2002-10-11 12:46:05 +0000
commit553e3c2c4376db4ee68eb5b377e75989fea101ba (patch)
treefb1146d428a4e41b3728e362c689f4b66c122015
parentscalb() in vax libm is in fact scalbn(), so change the symbol name. (diff)
downloadwireguard-openbsd-553e3c2c4376db4ee68eb5b377e75989fea101ba.tar.xz
wireguard-openbsd-553e3c2c4376db4ee68eb5b377e75989fea101ba.zip
In lgetc(), compress strings of whitespace to a single space. This makes
macros come out right in verbose mode and is less functional overhead. Also err on whitespace after a backslash. That type of error is hard to find otherwise. ok dhartmei@ henning@
-rw-r--r--sbin/pfctl/parse.y17
1 files changed, 14 insertions, 3 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 74535275300..d3cb35f47ce 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.165 2002/10/08 01:17:43 vincent Exp $ */
+/* $OpenBSD: parse.y,v 1.166 2002/10/11 12:46:05 camield Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -2414,7 +2414,7 @@ lgetc(FILE *fin)
int c, next;
if (parsebuf) {
- /* Reading characters from the parse buffer, instead of input */
+ /* Read character from the parsebuffer instead of input. */
if (parseindex >= 0) {
c = parsebuf[parseindex++];
if (c != '\0')
@@ -2430,12 +2430,23 @@ lgetc(FILE *fin)
while ((c = getc(fin)) == '\\') {
next = getc(fin);
if (next != '\n') {
+ if (isspace(next))
+ yyerror("whitespace after \\");
ungetc(next, fin);
break;
}
yylval.lineno = lineno;
lineno++;
}
+ if (c == '\t' || c == ' ') {
+ /* Compress blanks to a single space. */
+ do {
+ c = getc(fin);
+ } while (c == '\t' || c == ' ');
+ ungetc(c, fin);
+ c = ' ';
+ }
+
return (c);
}
@@ -2485,7 +2496,7 @@ yylex(void)
top:
p = buf;
- while ((c = lgetc(fin)) == ' ' || c == '\t')
+ while ((c = lgetc(fin)) == ' ')
;
yylval.lineno = lineno;