Re: Commenting rule sets

2002-08-14 Thread Daniel Hartmeier

On Tue, Aug 13, 2002 at 07:04:16PM -0700, Paul B. Henson wrote:

> If so, I might go ahead and kludge the in line comments into 3.1 (as I
> think that would be easier than backporting string concatenation) and then
> convert to this syntax for 3.2.

The diff below (against 3.1-release src/sbin/pfctl/parse.y) adds support
for # comments after \ backslashes and inside string literals, you can
use either of the two chunks separately, too.

The opposition, especially to the latter, was quite violent, so this
won't go into the tree (again).

Daniel


--- parse.y.origWed Aug 14 08:04:14 2002
+++ parse.y Wed Aug 14 08:07:42 2002
@@ -1438,7 +1438,12 @@
 
c = getc(fin);
if (c == '\\') {
-   next = getc(fin);
+   while ((next = getc(fin)) == ' ')
+   ;
+   if (next == '#')
+   do
+   next = getc(fin);
+   while (next != '\n' && next != EOF);
if (next != '\n') {
ungetc(next, fin);
return (c);
@@ -1539,6 +1544,10 @@
*p = '\0';
break;
}
+   if (c == '#')
+   do
+   c = lgetc(fin);
+   while (c != '\n' && c != EOF);
if (c == '\n')
continue;
if (p + 1 >= buf + sizeof(buf) - 1) {




Re: Commenting rule sets

2002-08-14 Thread Paul B. Henson

On Tue, 13 Aug 2002, Henning Brauer wrote:

> well, I must admit I okay'd that myself... but string concat is a much
> better solution.

if I understand the -current source, string concatenation is achieved by
simply placing two strings next to each other?

foo = "bar" "baz"


As such, the style of comments I seek would be implemented as:

foonets = "{ 10.0.0.0/24," # subnet blah
  "  10.0.1.0/24," # important stuff
  "  10.0.2.0/24 } " # don't forget

is that right?

If so, I might go ahead and kludge the in line comments into 3.1 (as I
think that would be easier than backporting string concatenation) and then
convert to this syntax for 3.2.


-- 
Paul B. Henson  |  (909) 869-3781  |  http://www.csupomona.edu/~henson/
Operating Systems and Network Analyst  |  [EMAIL PROTECTED]
California State Polytechnic University  |  Pomona CA 91768





Re: Commenting rule sets

2002-08-13 Thread Henning Brauer

On Tue, Aug 13, 2002 at 10:28:38AM -0700, Paul B. Henson wrote:
> On Tue, 13 Aug 2002, Philipp Buehler wrote:
> 
> > On 13/08/2002, francisco <[EMAIL PROTECTED]> wrote To Paul B. Henson:
> > > > foonets = "{ 10.0.0.0/24, # subnet blah
> > > >  10.0.1.0/24, # important stuff
> > > >  10.0.2.0/24  # don't forget
> > > >   }"
> > >
> > > it does in -current, since July 19, 2002.
> >
> > And it does not since some hours later.
> 
> Out of curiosity, what style of comment was temporarily supported, 

exactly the one you used above.

> and why
> was it removed from the parser?

because it is bad language design.
well, I must admit I okay'd that myself... but string concat is a much
better solution.



msg00092/pgp0.pgp
Description: PGP signature


Re: Commenting rule sets

2002-08-13 Thread Paul B. Henson

On Tue, 13 Aug 2002, Philipp Buehler wrote:

> On 13/08/2002, francisco <[EMAIL PROTECTED]> wrote To Paul B. Henson:
> > > foonets = "{ 10.0.0.0/24, # subnet blah
> > >  10.0.1.0/24, # important stuff
> > >  10.0.2.0/24  # don't forget
> > >   }"
> >
> > it does in -current, since July 19, 2002.
>
> And it does not since some hours later.

Out of curiosity, what style of comment was temporarily supported, and why
was it removed from the parser?

I do think some way of documenting sets defined in a variable would be
useful.


-- 
Paul B. Henson  |  (909) 869-3781  |  http://www.csupomona.edu/~henson/
Operating Systems and Network Analyst  |  [EMAIL PROTECTED]
California State Polytechnic University  |  Pomona CA 91768




Re: Commenting rule sets

2002-08-13 Thread Philipp Buehler

On 13/08/2002, francisco <[EMAIL PROTECTED]> wrote To Paul B. Henson:
> > foonets = "{ 10.0.0.0/24, # subnet blah
> >  10.0.1.0/24, # important stuff
> >  10.0.2.0/24  # don't forget
> >   }"
> 
> it does in -current, since July 19, 2002.

And it does not since some hours later.




Re: Commenting rule sets

2002-08-13 Thread francisco

On Mon, 12 Aug 2002, Paul B. Henson wrote:

>
> in putting together a rule set, I'm going to have a number of instances of
> variable definitions such as the following:
>
> foonets = "{ 10.0.0.0/24,
>  10.0.1.0/24,
>  10.0.2.0/24 }"
>
> I'd really like to be able to comment these in line, e.g.
>
> foonets = "{ 10.0.0.0/24, # subnet blah
>  10.0.1.0/24, # important stuff
>  10.0.2.0/24  # don't forget
>   }"
>
>
> however, the parser does not currently support this. Is there any way to
> accomplish this type of commenting or achieve a similar documentation
> without using inline comments?

it does in -current, since July 19, 2002.

Check out http://www.openbsd.org/cgi-bin/cvsweb/src/sbin/pfctl/parse.y for
a complete list of changes, like string concatenation.

-f
http://www.blackant.net/




Commenting rule sets

2002-08-13 Thread Paul B. Henson


in putting together a rule set, I'm going to have a number of instances of
variable definitions such as the following:

foonets = "{ 10.0.0.0/24,
 10.0.1.0/24,
 10.0.2.0/24 }"

I'd really like to be able to comment these in line, e.g.

foonets = "{ 10.0.0.0/24, # subnet blah
 10.0.1.0/24, # important stuff
 10.0.2.0/24  # don't forget
  }"


however, the parser does not currently support this. Is there any way to
accomplish this type of commenting or achieve a similar documentation
without using inline comments?

If not, any thoughts on implementing some type of inline comment?
allowing the above syntax? Or perhaps C style?

foonets = "{ 10.0.0.0/24 /* subnet blah */,
 10.0.1.0/24 /* important stuff */,
 10.0.2.0/24 /* don't forget */
  }"


I don't really want to have a comment before the variable definition, as
there will be anywhere from dozens to hundreds of subnets.

Thanks...


-- 
Paul B. Henson  |  (909) 869-3781  |  http://www.csupomona.edu/~henson/
Operating Systems and Network Analyst  |  [EMAIL PROTECTED]
California State Polytechnic University  |  Pomona CA 91768