bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] _ function (gettext) broken in gawk 4.2.0


From: Bruno Haible
Subject: [bug-gawk] _ function (gettext) broken in gawk 4.2.0
Date: Sat, 06 Jan 2018 08:36:50 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-101-generic; KDE/5.18.0; x86_64; ; )

Hi,

The following test case (from GNU gettext) works fine with
gawk versions 3.1.6 to 4.1.4, but is now broken in some
circumstances in gawk 4.2.0.


How to reproduce:

1) Make sure you have a French locale installed.
$ locale -a | grep fr_FR
If not, create one:
$ sudo localedef -i fr_FR -f UTF-8 fr_FR.UTF-8

2) Save the follwing files:
============================ prog.awk ============================
BEGIN {
  TEXTDOMAIN = "prog"
  bindtextdomain ("./")

  printf dcngettext ("a piece of cake", "%d pieces of cake", n) "\n", n

  print _"%s is replaced by %s."
  print _"%s is replaced by %s." "\n"
  printf _"%s is replaced by %s." "\n", "FF", "EUR"
}
==================================================================
============================= fr.po ============================
msgid ""
msgstr ""
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

# Les gateaux allemands sont les meilleurs du monde.
#, awk-format
msgid "a piece of cake"
msgid_plural "%d pieces of cake"
msgstr[0] "un morceau de gateau"
msgstr[1] "%d morceaux de gateau"

# Reverse the arguments.
#, awk-format
msgid "%s is replaced by %s."
msgstr "%2$s remplace %1$s."
================================================================

3) Compile the PO file:
$ mkdir -p fr/LC_MESSAGES
$ msgfmt -o fr/LC_MESSAGES/prog.mo fr.po

4) Verify that gawk is internationalized:
$ LANGUAGE= LC_ALL=fr_FR.UTF-8 gawk --version | grep logiciel

5) Run the program:

$ LANGUAGE= LC_ALL=fr_FR.UTF-8 gawk -v n=2 -f prog.awk

Expected output (seen with versions 4.1.3, 4.1.4):
--------------------------
2 morceaux de gateau
%2$s remplace %1$s.
%2$s remplace %1$s.

EUR remplace FF.
--------------------------

Actual output with version 4.2.0 (on Linux and Mac OS X):
--------------------------
2 morceaux de gateau
%2$s remplace %1$s.
%s is replaced by %s.

FF is replaced by EUR.
--------------------------


The NEWS file does not mention a related intended change
regarding the _ (gettext) functions between 4.1.4 and 4.2.0.


Among the ChangeLogs between versions 4.1.4 and 4.2.0, I can see these:

2017-04-12         Arnold D. Robbins     <address@hidden>

        * builtin.c (do_dcgettext): Move declaration of reslen to
        outside the ifdefs. Thanks to Hermann Peifer for the report.

2017-01-27         Andrew J. Schorr     <address@hidden>

        * builtin.c (do_strftime): Use str_terminate and str_restore.
        (do_dcgettext): Ditto, and remove saved_end flag since equivalent
        to testing (t2 != NULL). Fix overrun bug in calculating result
        length when !ENABLE_NLS.
        (do_dcngettext, do_bindtextdomain): Use str_terminate and str_restore.

2017-01-26         Andrew J. Schorr     <address@hidden>

        * builtin.c (do_dcgettext): First argument also needs protection
        from string overrun.
        (do_dcngettext): Need to terminate string1 and string2 also,
        and replace strlen(the_result), which could overrun.

2016-11-17         Arnold D. Robbins     <address@hidden>

        General cleanup for zero termination of strings.

        * builtin.c (do_fflush): Use %.*s.
        (locale_category_from_argument, do_dcgettext, do_dcngettext,
        do_bindtextdomain): Save and restore character after end.

Probably some of these is relevant.


Best regards,

          Bruno




reply via email to

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