Package: gawk
Version: 1:4.1.4+dfsg-1
Severity: normal

Hello,

https://www.gnu.org/software/gawk/manual/html_node/Gory-Details.html#Gory-Details
states:

        At the runtime level, whenever gawk sees a ‘\’ [in the
        replacement text], if the following character is a digit, then
        the text that matched the corresponding parenthesized
        subexpression is placed in the generated output.  Otherwise, no
        matter what character follows the ‘\’, it appears in the
        generated text and the ‘\’ does not [...].

this however isn't true when there are several backslashes:

        uwe@taurus:~$ echo 'a' | awk '{ gsub("a", "\\\\"); print }'
        \\
        uwe@taurus:~$ echo 'a' | awk '{ gsub("a", "\\\\\\"); print }'
        \\\
        uwe@taurus:~$ echo 'a' | awk '{ gsub("a", "\\\\\\\\"); print }'
        \\

The first two instances are still ok, but in the third I expect four
backslashes, not two. With GNU Awk 4.0.2 (found on a Centos 7 machine) I get
actually four; with gawk 1:4.2.1+dfsg-1 from sid there are also only two.

When I pass n backslashes as replacement text it seems to output

        2 * (n // 8) + (n % 8) / 2

backslashes instead of

        n // 2

(where "//" is integer division).

Best regards
Uwe

-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (700, 'testing'), (600, 'unstable'), (500, 'unstable-debug'), 
(500, 'stable'), (499, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.18.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages gawk depends on:
ii  libc6         2.27-6
ii  libgmp10      2:6.1.2+dfsg-3
ii  libmpfr6      4.0.1-1
ii  libreadline7  7.0-5
ii  libsigsegv2   2.12-2

gawk recommends no packages.

Versions of packages gawk suggests:
pn  gawk-doc  <none>

-- no debconf information

Reply via email to