PERFORCE change 145613 for review
Gleb Kurtsou
gk at FreeBSD.org
Tue Jul 22 14:43:52 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=145613
Change 145613 by gk at gk_h1 on 2008/07/22 14:43:20
more strictly parse table file entries (according to man page).
enforce one entry per line. allow spaces on lines (for ether addresses)
Affected files ...
.. //depot/projects/soc2008/gk_l2filter/sbin-pfctl/pfctl_radix.c#2 edit
Differences ...
==== //depot/projects/soc2008/gk_l2filter/sbin-pfctl/pfctl_radix.c#2 (text+ko) ====
@@ -607,12 +607,20 @@
do {
if (i < BUF_SIZE)
buf[i++] = next_ch;
- next_ch = fgetc(fp);
- } while (!feof(fp) && !isspace(next_ch));
+ /* leave only 1 space */
+ if (isspace(next_ch)) {
+ while (isspace(next_ch) && next_ch != '\n' && !feof(fp))
+ next_ch = fgetc(fp);
+ } else {
+ next_ch = fgetc(fp);
+ }
+ } while (!feof(fp) && next_ch != '\n');
if (i >= BUF_SIZE) {
errno = EINVAL;
return (-1);
}
+ if (i > 0 && isspace(buf[i-1]))
+ i--;
buf[i] = '\0';
return (1);
}
More information about the p4-projects
mailing list