bug-gawk
[Top][All Lists]
Advanced

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

Re: fatal error not produced for all unknown modifiers in --posix mode


From: arnold
Subject: Re: fatal error not produced for all unknown modifiers in --posix mode
Date: Sat, 09 Jan 2021 13:45:25 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Code fix and test suite update are in Git.

Thanks!

Arnold

Arkadiusz Drabczyk <arkadiusz@drabczyk.org> wrote:

> In gawk.info it says:
>
> "C programmers may be used to supplying additional modifiers ('h',
> 'j', 'l', 'L', 't', and 'z') in 'printf' format strings.  These are
> not valid in 'awk'.  Most 'awk' implementations silently ignore them.
> If '--lint' is provided on the command line (*note Options::), 'gawk'
> warns about their use.  If '--posix' is supplied, their use is a fatal
> error."
>
> But the fatal error is not produced for all unknown modifiers in
> --posix mode:
>
> $ cat modifiers.sh
> #!/usr/bin/env sh
>
> gawk --posix --lint 'BEGIN { printf "%hu\n", 12 }'
> gawk --posix --lint 'BEGIN { printf "%lu\n", 12 }'
> gawk --posix --lint 'BEGIN { printf "%Lu\n", 12 }'
>
> gawk --posix --lint 'BEGIN { printf "%ju\n", 12 }'
> gawk --posix --lint 'BEGIN { printf "%tu\n", 12 }'
> gawk --posix --lint 'BEGIN { printf "%zu\n", 12 }'
> $ ./modifiers.sh
> gawk: cmd. line:1: warning: `h' is meaningless in awk formats; ignored
> gawk: cmd. line:1: fatal: `h' is not permitted in POSIX awk formats
> gawk: cmd. line:1: warning: `l' is meaningless in awk formats; ignored
> gawk: cmd. line:1: fatal: `l' is not permitted in POSIX awk formats
> gawk: cmd. line:1: warning: `L' is meaningless in awk formats; ignored
> gawk: cmd. line:1: fatal: `L' is not permitted in POSIX awk formats
> gawk: cmd. line:1: warning: ignoring unknown format specifier character `j': 
> no argument converted
> gawk: cmd. line:1: warning: [s]printf: format specifier does not have control 
> letter
> gawk: cmd. line:1: warning: too many arguments supplied for format string
> %ju
> gawk: cmd. line:1: warning: ignoring unknown format specifier character `t': 
> no argument converted
> gawk: cmd. line:1: warning: [s]printf: format specifier does not have control 
> letter
> gawk: cmd. line:1: warning: too many arguments supplied for format string
> %tu
> gawk: cmd. line:1: warning: ignoring unknown format specifier character `z': 
> no argument converted
> gawk: cmd. line:1: warning: [s]printf: format specifier does not have control 
> letter
> gawk: cmd. line:1: warning: too many arguments supplied for format string
> %zu
>
> As you can fatal error is produced for h, l and L but it's not
> produced for j, t and z.
>
> I'm not sure I interpret the docs correctly - should the fatal error
> be produced only for types which are explicitly handled in awk or for
> all of them (I believe in that case a new case is needed in
> format_tree())?
>
> -- 
> Arkadiusz Drabczyk <arkadiusz@drabczyk.org>



reply via email to

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