From owner-freebsd-hackers Thu Dec 4 22:04:17 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id WAA18909 for hackers-outgoing; Thu, 4 Dec 1997 22:04:17 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from dog.farm.org (gw-hssi-2.farm.org [209.66.103.33]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id WAA18903 for ; Thu, 4 Dec 1997 22:04:09 -0800 (PST) (envelope-from dog.farm.org!dk) Received: (from dk@localhost) by dog.farm.org (8.7.5/dk#3) id WAA23987; Thu, 4 Dec 1997 22:06:37 -0800 (PST) Date: Thu, 4 Dec 1997 22:06:37 -0800 (PST) From: Dmitry Kohmanyuk Message-Id: <199712050606.WAA23987@dog.farm.org> To: archie@whistle.com (Archie Cobbs) Cc: freebsd-hackers@freebsd.org Subject: Re: Teeny-weeny /usr/src/sbin/ipfw/ipfw.c patch Newsgroups: cs-monolit.gated.lists.freebsd.hackers Organization: FARM Computing Association Reply-To: dk+@ua.net X-Newsreader: TIN [version 1.2 PL2] Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In article <199712050142.RAA11543@bubba.whistle.com> you wrote: > Jos Backus writes: > > *** ipfw.c.dist Fri Dec 5 01:29:49 1997 > > --- ipfw.c Fri Dec 5 01:30:20 1997 > > *************** > > *** 1197,1202 **** > > --- 1197,1203 ---- > > while (fgets(buf, BUFSIZ, f)) { > > > > lineno++; > > + if (buf[0]=='#'||buf[0]=='\n') continue; > > sprintf(linename, "Line %d", lineno); > > args[0] = linename; > > > > This allows comments/empty lines in a firewall rule file (when using the > > ``ipfw rulefile'' syntax), which seems pretty handy (at least to me -- > > documenting rules and all that). > Good idea! But may I suggest this tweak? So a blank line with extra > white space is OK too... > *** ipfw.c.orig Fri Dec 5 01:39:35 1997 > --- ipfw.c Fri Dec 5 01:40:33 1997 > *************** > *** 1200,1208 **** > --- 1200,1212 ---- > sprintf(linename, "Line %d", lineno); > args[0] = linename; > > + if (*buf == '#') > + continue; should probably become char *p; if ((p = strchr(buf, '#') != NULL) *p = 0; to handle lines like #indented comment or ipfw deny .... ... #end-of-line comment > for (i = 1, a = strtok(buf, WHITESP); > a && i < MAX_ARGS; a = strtok(NULL, WHITESP), i++) > args[i] = a; > + if (i == 1) > + continue; > if (i == MAX_ARGS) > errx(1, "%s: too many arguments", linename); > args[i] = NULL; -- "'Programming' is a four-letter word." --Craig Bruce