[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] print statement problem with hexadecimal escape sequence
From: |
Manuel Collado |
Subject: |
Re: [bug-gawk] print statement problem with hexadecimal escape sequence |
Date: |
Thu, 3 May 2018 15:20:33 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
El 03/05/2018 a las 2:15, Hyunho Cho escribió:
There is a erroneous print result with "\xHH" escape sequence that is
immediately followed by hexadecimal value (0-9a-f)
Not an erroneous result, but a problematic code:
$ awk --lint 'BEGIN { print "\x41\x42\x43FFF" }' | od -a
awk: cmd. line:1: warning: POSIX does not allow `\x' escapes
awk: cmd. line:1: warning: hex escape \x43FFF of 5 characters probably
not interpreted the way you expect
0000000 A B del nl
0000004
$ gawk --version
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 3.1.6, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2016 Free Software Foundation.
# there is no problem because "K" is not hex character.
$awk 'BEGIN { print "\x41\x42\x43KKK" }' | od -a
0000000 A B C K K K nl
0000007
# There is a problem because "F" is hex character that immediately following
"\xHH" escape sequence.
$ awk 'BEGIN { print "\x41\x42\x43FFF" }' | od -a
0000000 A B del nl
0000004
# if i insert a space in front of "F" then problem disappear.
$ awk 'BEGIN { print "\x41\x42\x43 FFF" }' | od -a
0000000 A B C sp F F F nl
0000010
Regards.
--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado