On 10/11/2011 12:54 PM, Charles Wilson wrote:
Consensus does appear to be unanimous on what to do; I just need to
review all the postings and figure out exactly /how/ to do it.

I have uploaded the new packages.  There are three new patches:

1) modified localename.c significantly. No longer "ignores" LANG=C.UTF-8; also does not try to do any parsing of the Windows I18N settings. Basically, acts like linux -- if the value of the locale string isn't supported by the underlying setlocale() implementation, then it is ignored (e.g. default back to "C.UTF-8" or "C") -- libintl doesn't try to 'be smart' -- or to second-guess. Also, relies on cygwin's glibc-like setlocale(LC_*, NULL) behavior -- which has been supported by newlib since the cygwin 1.5 days (even if it always returned "C" back then).

2) Fixes to the test suite related to the above changes. From the CHECK_NOTES file:

NOTE: there were four other failures that arose because of the
      changes to localename.  These were:
         format-c-3
         format-c-4
         plural-1
         plural-2
      but the test suite was patched to avoid these failures.
      The problem is rather complicated; gettext-0.18.1.1 now has a
      libintl_setlocale function that is used by libintl clients,
      instead of the system setlocale.  The localename patch left
      that in place, but ensured that it did far less work -- was less
      obtrusive -- in its interposition between clients and the system
      setlocale.  However, some of that eliminated 'work' also allowed
      the gettext test suite to 'cheat' a bit -- it used non-existent
      locales (like 'fr' rather than 'fr_FR'), and *re-hijacked* the
      setlocale function itself.  None of that works anymore -- and
      *actual* clients are unlikely to need/want to do it -- so the
      test suite was patched to use real locales in all cases, and to
      not re-hijack.

3) Adopted Bruno's upstream changes to relocatable.c, turning off "expensive" relocation support in libintl.

Odds of #1 and #2 being adopted upstream are effectively nil, so...

--
Chuck

diff -u old/gettext-0.18.1.1/gettext-runtime/intl/localename.c 
new/gettext-0.18.1.1/gettext-runtime/intl/localename.c
--- old/gettext-0.18.1.1/gettext-runtime/intl/localename.c      2011-10-15 
00:21:37.853133600 -0400
+++ new/gettext-0.18.1.1/gettext-runtime/intl/localename.c      2011-10-15 
00:29:27.601133600 -0400
@@ -59,7 +59,7 @@
 # define WIN32_NATIVE
 #endif
 
-#if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+#if defined WIN32_NATIVE /* WIN32 */
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 /* List of language codes, sorted by value:
@@ -1407,7 +1407,7 @@
 #endif
 
 
-#if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+#if defined WIN32_NATIVE /* WIN32 */
 
 /* Canonicalize a Win32 native locale name to a Unix locale name.
    NAME is a sufficiently large buffer.
@@ -2770,8 +2770,8 @@
     setting of 'local'."
    However it does not specify the exact format.  Neither do SUSV2 and
    ISO C 99.  So we can use this feature only on selected systems (e.g.
-   those using GNU C Library).  */
-#if defined _LIBC || (defined __GLIBC__ && __GLIBC__ >= 2)
+   those using GNU C Library, or cygwin [1.5 and 1.7+]).  */
+#if defined _LIBC || (defined __GLIBC__ && __GLIBC__ >= 2) || defined 
__CYGWIN__
 # define HAVE_LOCALE_NULL
 #endif
 
@@ -2826,11 +2826,6 @@
          Ignore invalid LANG value set by the Terminal application.  */
       if (strcmp (retval, "UTF-8") != 0)
 #endif
-#if defined __CYGWIN__
-      /* Cygwin.
-         Ignore dummy LANG value set by ~/.profile.  */
-      if (strcmp (retval, "C.UTF-8") != 0)
-#endif
         return retval;
     }
 
@@ -2923,7 +2918,7 @@
 
 # endif
 
-# if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+# if defined WIN32_NATIVE /* WIN32 */
   {
     LCID lcid;
 
@@ -2933,6 +2928,23 @@
     return gl_locale_name_from_win32_LCID (lcid);
   }
 # endif
+# if defined __CYGWIN__
+  {
+    /* Rarely arrive here. This function is called only when an earlier
+     * call to gl_locale_name_posix() or gl_locale_name_environ()
+     * returned NULL.  That first function now simply delegates to
+     * setlocale (LC_*, NULL), which never fails on cygwin.  But...for
+     * completeness, or when called after gl_locale_name_environ() and
+     * none are set, go ahead and specify the cygwin default. Cheat a bit
+     * to distinguish old cygwin (1.5 and below) from new cygwin (1.7+).
+     */
+#  if PATH_MAX < 261   /* cygwin 1.5 or below */
+    return "C";
+#  else                /* PATH_MAX = 4096, cygwin 1.7 or above */
+    return "C.UTF-8";
+#  endif
+  }
+# endif
 #endif
 }
 
--- origsrc/gettext-0.18.1.1/gettext-tools/tests/format-c-3-prg.c       
2010-06-06 08:49:58.000000000 -0400
+++ src/gettext-0.18.1.1/gettext-tools/tests/format-c-3-prg.c   2011-10-15 
22:54:48.494133600 -0400
@@ -34,7 +34,7 @@
 /* Disable the override of setlocale that libgnuintl.h activates on MacOS X
    and Windows.  This test relies on the fake setlocale function in
    setlocale.c.  */
-#undef setlocale
+/* #undef setlocale */
 
 #define _(string) gettext (string)
 
--- origsrc/gettext-0.18.1.1/gettext-tools/tests/format-c-4-prg.c       
2010-06-06 08:49:58.000000000 -0400
+++ src/gettext-0.18.1.1/gettext-tools/tests/format-c-4-prg.c   2011-10-15 
21:49:23.028133600 -0400
@@ -34,7 +34,7 @@
 /* Disable the override of setlocale that libgnuintl.h activates on MacOS X
    and Windows.  This test relies on the fake setlocale function in
    setlocale.c.  */
-#undef setlocale
+/* #undef setlocale */
 
 #define _(string) gettext (string)
 
--- origsrc/gettext-0.18.1.1/gettext-tools/tests/plural-1       2010-06-06 
08:49:58.000000000 -0400
+++ src/gettext-0.18.1.1/gettext-tools/tests/plural-1   2011-10-15 
22:32:46.440133600 -0400
@@ -65,15 +65,15 @@ ${DIFF} fr.po.strip fr.po.un || exit 1
 tmpfiles="$tmpfiles cake.ok cake.tmp cake.out"
 : ${DIFF=diff}
 echo 'un morceau de gateau' > cake.ok
-LANGUAGE= ./cake fr 1 > cake.tmp || exit 1
+LANGUAGE= ./cake fr_FR 1 > cake.tmp || exit 1
 LC_ALL=C tr -d '\r' < cake.tmp > cake.out || exit 1
 ${DIFF} cake.ok cake.out || exit 1
 echo '2 morceaux de gateau' > cake.ok
-LANGUAGE= ./cake fr 2 > cake.tmp || exit 1
+LANGUAGE= ./cake fr_FR 2 > cake.tmp || exit 1
 LC_ALL=C tr -d '\r' < cake.tmp > cake.out || exit 1
 ${DIFF} cake.ok cake.out || exit 1
 echo '10 morceaux de gateau' > cake.ok
-LANGUAGE= ./cake fr 10 > cake.tmp || exit 1
+LANGUAGE= ./cake fr_FR 10 > cake.tmp || exit 1
 LC_ALL=C tr -d '\r' < cake.tmp > cake.out || exit 1
 ${DIFF} cake.ok cake.out || exit 1
 
--- origsrc/gettext-0.18.1.1/gettext-tools/tests/plural-1-prg.c 2010-06-06 
08:49:58.000000000 -0400
+++ src/gettext-0.18.1.1/gettext-tools/tests/plural-1-prg.c     2011-10-15 
23:00:57.110133600 -0400
@@ -30,7 +30,7 @@
 /* Disable the override of setlocale that libgnuintl.h activates on MacOS X
    and Windows.  This test relies on the fake setlocale function in
    setlocale.c.  */
-#undef setlocale
+/* #undef setlocale */
 
 int
 main (int argc, char *argv[])
--- origsrc/gettext-0.18.1.1/gettext-tools/tests/plural-2       2010-06-06 
08:49:58.000000000 -0400
+++ src/gettext-0.18.1.1/gettext-tools/tests/plural-2   2011-10-15 
22:51:09.838133600 -0400
@@ -3,10 +3,10 @@
 tmpfiles=""
 trap 'rm -fr $tmpfiles' 1 2 3 15
 
-tmpfiles="$tmpfiles ll ll.po dataout"
+tmpfiles="$tmpfiles es ll.po dataout"
 : ${MSGFMT=msgfmt}
-test -d ll || mkdir ll
-test -d ll/LC_MESSAGES || mkdir ll/LC_MESSAGES
+test -d es || mkdir es
+test -d es/LC_MESSAGES || mkdir es/LC_MESSAGES
 
 tmpfiles="$tmpfiles plural-2.data"
 cat <<EOF > plural-2.data
@@ -68,10 +68,10 @@ msgstr[7] "7"
 msgstr[8] "8"
 msgstr[9] "9"
 EOF
-  ${MSGFMT} -o ll/LC_MESSAGES/plural.mo ll.po || exit 1
+  ${MSGFMT} -o es/LC_MESSAGES/plural.mo ll.po || exit 1
   (for i in '' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
      LANGUAGE= TEXTDOMAIN=plural TEXTDOMAINDIR=. \
-       $NGETTEXT --env LC_ALL=ll X Y ${i}0 ${i}1 ${i}2 ${i}3 ${i}4 ${i}5 ${i}6 
${i}7 ${i}8 ${i}9
+       $NGETTEXT --env LC_ALL=es_ES X Y ${i}0 ${i}1 ${i}2 ${i}3 ${i}4 ${i}5 
${i}6 ${i}7 ${i}8 ${i}9
    done) > dataout
   test "$dataok" = `cat dataout` || {
     echo "Formula evaluation error for language $lang" 1>&2
diff -u old/gettext-0.18.1.1/gettext-runtime/gnulib-lib/relocatable.c 
new/gettext-0.18.1.1/gettext-runtime/gnulib-lib/relocatable.c
--- old/gettext-0.18.1.1/gettext-runtime/gnulib-lib/relocatable.c
+++ new/gettext-0.18.1.1/gettext-runtime/gnulib-lib/relocatable.c
@@ -85,6 +85,19 @@
 # define FILE_SYSTEM_PREFIX_LEN(P) 0
 #endif
 
+/* Whether to enable the more costly support for relocatable libraries.
+   It allows libraries to be have been installed with a different original
+   prefix than the program.  But it is quite costly, especially on Cygwin
+   platforms, see below.  Therefore we enable it by default only on native
+   Win32 platforms.  */
+#ifndef ENABLE_COSTLY_RELOCATABLE
+# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+#  define ENABLE_COSTLY_RELOCATABLE 1
+# else
+#  define ENABLE_COSTLY_RELOCATABLE 0
+# endif
+#endif
+
 /* Original installation prefix.  */
 static char *orig_prefix;
 static size_t orig_prefix_len;
@@ -154,7 +167,7 @@ set_relocation_prefix (const char *orig_prefix_arg, const 
char *curr_prefix_arg)
 #endif
 }
 
-#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR)
+#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR && 
ENABLE_COSTLY_RELOCATABLE)
 
 /* Convenience function:
    Computes the current installation prefix, based on the original
@@ -284,7 +297,7 @@ compute_curr_prefix (const char *orig_installprefix,
 
 #endif /* !IN_LIBRARY || PIC */
 
-#if defined PIC && defined INSTALLDIR
+#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE
 
 /* Full pathname of shared library, or NULL.  */
 static char *shared_library_fullname;
@@ -330,7 +343,9 @@ find_shared_library_fullname ()
 #if (defined __linux__ && (__GLIBC__ >= 2 || defined __UCLIBC__)) || defined 
__CYGWIN__
   /* Linux has /proc/self/maps. glibc 2 and uClibc have the getline()
      function.
-     Cygwin >= 1.5 has /proc/self/maps and the getline() function too.  */
+     Cygwin >= 1.5 has /proc/self/maps and the getline() function too.
+     But it is costly: ca. 0.3 ms on Linux, 3 ms on Cygwin 1.5, and 5 ms on
+     Cygwin 1.7.  */
   FILE *fp;
 
   /* Open the current process' maps file.  It describes one VMA per line.  */
@@ -403,7 +418,7 @@ get_shared_library_fullname ()
 const char *
 relocate (const char *pathname)
 {
-#if defined PIC && defined INSTALLDIR
+#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE
   static int initialized;
 
   /* Initialization code for a shared library.  */
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to