]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Hacks to optionally enable backward compatible behaviour.
authorBruno Haible <bruno@clisp.org>
Thu, 19 Apr 2001 18:30:47 +0000 (18:30 +0000)
committerBruno Haible <bruno@clisp.org>
Thu, 19 Apr 2001 18:30:47 +0000 (18:30 +0000)
src/po.c
src/write-po.c

index f60a9f26c7e0f168f9bc0a3806ccab833d682853..6917568287d07f1abd83c4c6c0b77fbffcbf0b52 100644 (file)
--- a/src/po.c
+++ b/src/po.c
@@ -323,89 +323,112 @@ Message conversion to user's charset might not work.\n"),
                "SJIS",
                "JOHAB"
              };
+             const char *envval;
 
              po_lex_charset = standard_charsets[i];
 #if HAVE_ICONV
              if (po_lex_iconv != (iconv_t)(-1))
                iconv_close (po_lex_iconv);
-             /* Avoid glibc-2.1 bug with EUC-KR.  */
-# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION
-             if (strcmp (po_lex_charset, "EUC-KR") == 0)
-               po_lex_iconv = (iconv_t)(-1);
-             else
 #endif
-             po_lex_iconv = iconv_open ("UTF-8", po_lex_charset);
-             if (po_lex_iconv == (iconv_t)(-1))
-               {
-                 const char *note;
-                 char *prefix;
-                 char *msg;
 
-                 for (i = 0; i < SIZEOF (weird_charsets); i++)
-                   if (strcmp (po_lex_charset, weird_charsets[i]) == 0)
-                     break;
-                 if (i < SIZEOF (weird_charsets))
-                   note = _("Continuing anyway, expect parse errors.");
+             /* The old Solaris/openwin msgfmt and GNU msgfmt <= 0.10.35
+                don't know about multibyte encodings, and require a spurious
+                backslash after every multibyte character whose last byte is
+                0x5C.  Some programs, like vim, distribute PO files in this
+                broken format.  GNU msgfmt must continue to support this old
+                PO file format when the Makefile requests it.  */
+             envval = getenv ("OLD_PO_FILE_INPUT");
+             if (envval != NULL && *envval != '\0')
+               {
+                 /* Assume the PO file is in old format, with extraneous
+                    backslashes.  */
+#if HAVE_ICONV
+                 po_lex_iconv = (iconv_t)(-1);
+#endif
+               }
+             else
+               {
+                 /* Use iconv() to parse multibyte characters.  */
+#if HAVE_ICONV
+                 /* Avoid glibc-2.1 bug with EUC-KR.  */
+# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION
+                 if (strcmp (po_lex_charset, "EUC-KR") == 0)
+                   po_lex_iconv = (iconv_t)(-1);
                  else
-                   note = _("Continuing anyway.");
-
-                 asprintf (&prefix, _("%s: warning: "), gram_pos.file_name);
-                 asprintf (&msg, _("\
+# endif
+                 po_lex_iconv = iconv_open ("UTF-8", po_lex_charset);
+                 if (po_lex_iconv == (iconv_t)(-1))
+                   {
+                     const char *note;
+                     char *prefix;
+                     char *msg;
+
+                     for (i = 0; i < SIZEOF (weird_charsets); i++)
+                       if (strcmp (po_lex_charset, weird_charsets[i]) == 0)
+                         break;
+                     if (i < SIZEOF (weird_charsets))
+                       note = _("Continuing anyway, expect parse errors.");
+                     else
+                       note = _("Continuing anyway.");
+
+                     asprintf (&prefix, _("%s: warning: "), gram_pos.file_name);
+                     asprintf (&msg, _("\
 Charset \"%s\" is not supported. %s relies on iconv(),\n\
 and iconv() does not support \"%s\".\n"),
-                           po_lex_charset, basename (program_name),
-                           po_lex_charset);
-                 if (prefix == NULL || msg == NULL)
-                   error (EXIT_FAILURE, 0, _("memory exhausted"));
-                 multiline_warning (prefix, msg);
+                               po_lex_charset, basename (program_name),
+                               po_lex_charset);
+                     if (prefix == NULL || msg == NULL)
+                       error (EXIT_FAILURE, 0, _("memory exhausted"));
+                     multiline_warning (prefix, msg);
 
 # if !defined _LIBICONV_VERSION
-                 asprintf (&msg, _("\
+                     asprintf (&msg, _("\
 Installing GNU libiconv and then reinstalling GNU gettext\n\
 would fix this problem.\n"));
-                 if (msg == NULL)
-                   error (EXIT_FAILURE, 0, _("memory exhausted"));
-                 multiline_warning (NULL, msg);
+                     if (msg == NULL)
+                       error (EXIT_FAILURE, 0, _("memory exhausted"));
+                     multiline_warning (NULL, msg);
 # endif
 
-                 asprintf (&msg, _("%s\n"), note);
-                 if (msg == NULL)
-                   error (EXIT_FAILURE, 0, _("memory exhausted"));
-                 multiline_warning (NULL, msg);
-               }
+                     asprintf (&msg, _("%s\n"), note);
+                     if (msg == NULL)
+                       error (EXIT_FAILURE, 0, _("memory exhausted"));
+                     multiline_warning (NULL, msg);
+                   }
 #else
-             for (i = 0; i < SIZEOF (weird_charsets); i++)
-               if (strcmp (po_lex_charset, weird_charsets[i]) == 0)
-                 break;
-             if (i < SIZEOF (weird_charsets))
-               {
-                 const char *note =
-                   _("Continuing anyway, expect parse errors.");
-                 char *prefix;
-                 char *msg;
-
-                 asprintf (&prefix, _("%s: warning: "), gram_pos.file_name);
-                 asprintf (&msg, _("\
+                 for (i = 0; i < SIZEOF (weird_charsets); i++)
+                   if (strcmp (po_lex_charset, weird_charsets[i]) == 0)
+                     break;
+                 if (i < SIZEOF (weird_charsets))
+                   {
+                     const char *note =
+                       _("Continuing anyway, expect parse errors.");
+                     char *prefix;
+                     char *msg;
+
+                     asprintf (&prefix, _("%s: warning: "), gram_pos.file_name);
+                     asprintf (&msg, _("\
 Charset \"%s\" is not supported. %s relies on iconv().\n\
 This version was built without iconv().\n"),
-                           po_lex_charset, basename (program_name));
-                 if (prefix == NULL || msg == NULL)
-                   error (EXIT_FAILURE, 0, _("memory exhausted"));
-                 multiline_warning (prefix, msg);
+                               po_lex_charset, basename (program_name));
+                     if (prefix == NULL || msg == NULL)
+                       error (EXIT_FAILURE, 0, _("memory exhausted"));
+                     multiline_warning (prefix, msg);
 
-                 asprintf (&msg, _("\
+                     asprintf (&msg, _("\
 Installing GNU libiconv and then reinstalling GNU gettext\n\
 would fix this problem.\n"));
-                 if (msg == NULL)
-                   error (EXIT_FAILURE, 0, _("memory exhausted"));
-                 multiline_warning (NULL, msg);
-
-                 asprintf (&msg, _("%s\n"), note);
-                 if (msg == NULL)
-                   error (EXIT_FAILURE, 0, _("memory exhausted"));
-                 multiline_warning (NULL, msg);
-               }
+                     if (msg == NULL)
+                       error (EXIT_FAILURE, 0, _("memory exhausted"));
+                     multiline_warning (NULL, msg);
+
+                     asprintf (&msg, _("%s\n"), note);
+                     if (msg == NULL)
+                       error (EXIT_FAILURE, 0, _("memory exhausted"));
+                     multiline_warning (NULL, msg);
+                   }
 #endif
+               }
            }
        }
       else
index 5e1459b164df99bd238aa64d13fa739088851fde..48eeb67c4a08778b03eb38df770a853a1d1186f6 100644 (file)
@@ -195,7 +195,24 @@ wrap (fp, line_prefix, name, value, do_wrap, charset)
   const char *s;
   int first_line;
 #if HAVE_ICONV
-  iconv_t conv = iconv_open ("UTF-8", charset);
+  const char *envval;
+  iconv_t conv;
+#endif
+
+#if HAVE_ICONV
+  /* The old Solaris/openwin msgfmt and GNU msgfmt <= 0.10.35 don't know
+     about multibyte encodings, and require a spurious backslash after
+     every multibyte character whose last byte is 0x5C.  Some programs,
+     like vim, distribute PO files in this broken format.  It is important
+     for such programs that GNU msgmerge continues to support this old
+     PO file format when the Makefile requests it.  */
+  envval = getenv ("OLD_PO_FILE_OUTPUT");
+  if (envval != NULL && *envval != '\0')
+    /* Write a PO file in old format, with extraneous backslashes.  */
+    conv = (iconv_t)(-1);
+  else
+    /* Use iconv() to parse multibyte characters.  */
+    conv = iconv_open ("UTF-8", charset);
 #endif
 
   /* Loop over the '\n' delimited portions of value.  */