bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] [PATCH] gawk: Comply with IEEE Std 1003.1


From: Samy Mahmoudi
Subject: Re: [bug-gawk] [PATCH] gawk: Comply with IEEE Std 1003.1
Date: Tue, 31 Jul 2018 12:07:27 +0200

Hello Arnold,

Thank you for your attention.

$ nawk -v x='abc\
> def' 'BEGIN { print x }'
abc
def
----> Does this mean nawk does not fully comply with the standard ?

What I have not noticed before submitting the patch, is that both nawk and gawk behaved differently depending on quoting type. With single-quotes and before your recent changes, we got:

$ nawk -v x='abc\
> def' 'BEGIN { print x }'
abc
def

$ gawk (--posix|--traditional|<nothing>) -v x='abc\
> def' 'BEGIN {print x}'
abc\def

With double-quotes (the first newline is ignored by the shell as stated by the standard, section 2.2.1 and 2.2.3and before your recent changes, we got:

$ nawk -v x="abc\
> def" 'BEGIN { print x }'
nawk: newline in string abc
def... at source line 1

$ gawk (--posix|--traditional|<nothing>) -v x="abc\
> def" 'BEGIN {print x}'
abc
def

I tried to make gawk --traditional mimic the behavior of nawk (with respect to double-quoting) but, as you stated, I got gawk --traditional to be more restrictive than nawk (with respect to single-quoting).

I just had a look to your (massive) changes. I will test and experiment today.

Thank you very much for your work.

Best regards,
Samy Mahmoudi

Le mar. 31 juil. 2018 à 08:51, <address@hidden> a écrit :
Hi.

I have just pushed code and doc updates related to this. In short:

- In POSIX mode gawk rejects any physical newline in strings, even
  escaped ones.
- The -v option now handles \-<newline> like the scanner does.

Thanks for bringing this issue to my attention.

Arnold

address@hidden wrote:

> Samy Mahmoudi <address@hidden> wrote:
>
> > Hello,
> >
> > When using the option -v *assignment*, POSIX awk "shall ensure
> > that the assignment argument is in the same form as an assignment
> > operand", in which "the characters following the equal sign shall
> > be interpreted as ... a *STRING* token".
> >
> > Moreover, lexical conventions demand that the *STRING* token "shall
> > represent a string constant" in which "a <newline> shall not occur".
> >
> > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html
> >
> > Best regards,
> > Samy Mahmoudi
>
> Thanks for the pointer and the patch. Unfortunately, your code
> doesn't quite match what Brian's awk does, since \-<newline> is
> allowed inside strings:
>
> $ nawk -v x='abc\
> > def' 'BEGIN { print x }'
> abc
> def
>
> I will look into adapting your patch to match his code. nawk and gawk
> are less picky about newlines.
>
> Thanks
>
> Arnold

reply via email to

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