bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] suggestions


From: Aharon Robbins
Subject: Re: [bug-gawk] suggestions
Date: Fri, 27 Jan 2012 11:59:56 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hi. Sorry for the delay in replying.  Re this:

> Date: Mon, 9 Jan 2012 09:46:15 -0500
> From: Graham Ewart <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] suggestions
>
> First comments: I would like to see the sequence "\#" treated differently.
> Instead of "As soon as awk sees the `#' that starts a comment, it ignores *
> everything* on the rest of the line", I would like the rule to be "As soon
> as awk sees the `#' that starts a comment, it ignores *the # and
> everything*on the rest of the line" so that the "\" before the comment
> starter would
> be treated as a line continuation.  This would facilitate commentary in the
> middle of statements.  Today the sequence "\#" gives the error "backslash
> not last character on line", so this would not break working code.

Code to do this has been in gawk for many years, but not enabled. If
you look at awkgram.y, there is an #ifdef RELAXED_CONTINUATION. Try
defining this when you rebuild gawk and see if it works like you would like.

> Second, and the real reason I'm writing, is that I'd like to see
> consecutive constant regular expressions concatenated.

Concatenation is messy in awk.  It already has a defined meaning, as does
the use of an unadorned regex to mean "the result of matching $0 against
the regex".  Thus something like

        a ~ ( /foo/  /bar/ )

has a defined, standardized, meaning, even if it's not all that useful
a meaning.

The point being, it's wwwwwaaaaaayyyyyyy too late to change this.

You can get something like what you want by using string constants and 
concatenation:

        a ~ ("some long regex here part 1" \
             "some long regex here part 2" \
             ....
             "some long regex here part N" )

With the caveat that you have to add extra backslashes as needed inside
the string constants. (More details on string constants instead of regex
constants may be found in the manual.)

> gawk '// {

Why use // here?  It always matches...

Thanks,

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]