* [zsh-2.6-b18] signames.awk and the backslash treatment bug
@ 1996-05-22 19:53 Mark Borges
1996-05-22 21:16 ` Johan Danielsson
0 siblings, 1 reply; 2+ messages in thread
From: Mark Borges @ 1996-05-22 19:53 UTC (permalink / raw)
To: ZSH mailing list; +Cc: Zoltan Hidvegi
I wrote the author of mawk, Michael Brennan, concerning the behavior
of mawk w.r.t. the backslashes introduced into the signames.awk script
in beta18. Appended is his take on the matter.
This is probably more than anyone ever wanted to know, but in case you
are curious...
------- start of forwarded message (RFC 934 encapsulation) -------
Content-Type: text
content-length: 891
From: brennan@amc.com (Michael Brennan)
Subject: Re: [mawk-1.2.2] backslash treatment
Date: Wed, 22 May 1996 12:36:00 -0700 (PDT)
To: mdb@cdc.noaa.gov (Mark Borges)
>
> Is this a bug in mawk?
>
> Apparently the use of a `\' preceding a character that need not be
> escaped in a print statement is ambiguous. Some awks remove it, others
> (like mawk) leave it verbatim.
>
The posix answer is "\z" has undefined meaning which implies that it is
not portable to use it. The posix standard says it is explicitly
undefined. Note that the same thing is true for ansi C. See K&R
(ansi version) page 193.
I discuss this issue in the portability section of the mawk man pages
(near the back).
[man page excerpt]
With mawk, the following are all equivalent,
x ~ /a\+b/ x ~ "a\+b" x ~ "a\\+b"
The strings get scanned twice, once as string and once as
regular expression. On the string scan, mawk ignores the
escape on non-escape characters while the AWK book advocates
\c be recognized as c which necessitates the double escaping
of meta-characters in strings. Posix explicitly declines to
define the behavior which passively forces programs that
must run under a variety of awks to use the more portable
but less readable, double escape.
[end man page excerpt]
In mawk, I wanted
x ~ /c\+/
x ~ "c\+"
to work the same. Note with nawk or gawk, you need to
x ~ "c\\+"
to escape + once for the string scan and once for the regexp scan.
With mawk
x ~ "c\\+"
works correctly too.
- --
Mike
brennan@amc.com
------- end -------
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [zsh-2.6-b18] signames.awk and the backslash treatment bug
1996-05-22 19:53 [zsh-2.6-b18] signames.awk and the backslash treatment bug Mark Borges
@ 1996-05-22 21:16 ` Johan Danielsson
0 siblings, 0 replies; 2+ messages in thread
From: Johan Danielsson @ 1996-05-22 21:16 UTC (permalink / raw)
To: Mark Borges; +Cc: ZSH mailing list, Zoltan Hidvegi
Mark Borges <mdb@cdc.noaa.gov> writes:
> This is probably more than anyone ever wanted to know, but in case
> you are curious...
Seems like a lot of fun.
My suggestion: change the relevant strings to "# else".
Still no clue what Crays awk is doing - anyone with source out there?
/Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-05-22 21:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-22 19:53 [zsh-2.6-b18] signames.awk and the backslash treatment bug Mark Borges
1996-05-22 21:16 ` Johan Danielsson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).