[Top][All Lists]

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

Re: quotearg improvements

From: Eric Blake
Subject: Re: quotearg improvements
Date: Wed, 13 Feb 2008 06:40:11 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

Hash: SHA1

According to Jim Meyering on 2/13/2008 4:00 AM:
| I noticed that something about these changes causes
| trouble with coreutils builds (albeit merely because it
| runs the new test-quotearg program from gnulib):

Aargh.  I tested ENABLE_NLS on cygwin, and while I tested on Linux, I
guess I never quite triggered ENABLE_NLS testing there.

| ../../gnulib-tests/test-quotearg.c:218: error: conflicting types for

OK, I see it now.  On Linux, <libintl.h> includes:

#if defined __OPTIMIZE__ && !defined __cplusplus
# define gettext(msgid) dgettext (NULL, msgid)
# define dgettext(domainname, msgid) \
~  dcgettext (domainname, msgid, LC_MESSAGES)

| I used the following patch to fix those and a couple other warnings,
| but even with that, when the test actually runs, it gets a failed
| assertion.  I'll look into that later.

Your patch isn't quite right.

|  /* True if the locale should be faked.  */
|  static bool fake_locale;
| +#undef gettext
| +#define dgettext(a,b) tq_dgettext(a,b)

This breaks the test on cygwin, where <libintl.h> comes from gettext, and
does #define gettext libintl_gettext.  By undefining it, cygwin then gets
either a link error when quotearg.o tries to use libintl_gettext (or if
gnulib-tool's --po-domain was in effect, when it tries to use
libintl_dgettext), or gets a runtime assertion since we no longer did the
desired override.

Meanwhile, on Linux, since quotearg.o ends up calling dcgettext, but
test-quotearg did not supply it, we are not getting the desired fake
translation (the final two rounds of testing get C behavior rather than
locale behavior, explaining the assertion you saw).

The trick is coming up with the right declarations so that we satisfy
quotearg.o's link dependencies, in spite of all the macro declarations
present in <libintl.h>.  When coupled with your warning fixes, does this
work for you instead?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

>From 52bee5725bf5a38f83e8113b21ec9c9a71893738 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 13 Feb 2008 06:36:15 -0700
Subject: [PATCH] tmp

 ChangeLog             |    6 ++++++
 tests/test-quotearg.c |   11 +++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9059b31..be37f9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-13  Eric Blake  <address@hidden>
+       Fix test-quotearg on Linux.
+       * tests/test-quotearg.c [ENABLE_NLS]: Work with Linux'
+       <libintl.h>.
 2008-02-12  Eric Blake  <address@hidden>
        Silence warning in last patch.
diff --git a/tests/test-quotearg.c b/tests/test-quotearg.c
index 86ffd7c..3679f84 100644
--- a/tests/test-quotearg.c
+++ b/tests/test-quotearg.c
@@ -29,6 +29,11 @@
 #include <string.h>
+/* Disable optimizations, so that we don't pick up the macro
+   definitions for gettext or dgettext that forward to dcgettext.  But
+   on platforms that require -lintl, we cannot #undef gettext, since
+   we need the entry point libintl_gettext defined instead. */
+# undef __OPTIMIZE__
 # include <libintl.h>
 /* These quotes are borrowed from a pt_PT.utf8 translation.  */
@@ -231,6 +236,12 @@ dgettext (char const *d, char const *str)
   return gettext (str);
+char *
+dcgettext (char const *d, char const *str, int c)
+  return gettext (str);
 #endif /* ENABLE_NLS */

reply via email to

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