From: Bruno Haible Date: Thu, 13 Aug 2009 20:15:35 +0000 (+0200) Subject: Fix last msgexec.c commit. Add comments. X-Git-Tag: v0.18~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1d8f391b409a3b6d19ae8f953d11ac3ca03e11c;p=thirdparty%2Fgettext.git Fix last msgexec.c commit. Add comments. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 389f5ffcb..debde4dae 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -2,6 +2,8 @@ * msgexec.c: Include msgl-charset.h. (main): Invoke compare_po_locale_charsets. + (process_string): Add comment. + * msgfilter.c (process_message): Likewise. 2009-08-10 Bruno Haible diff --git a/gettext-tools/src/msgexec.c b/gettext-tools/src/msgexec.c index 834190b40..f61130d4d 100644 --- a/gettext-tools/src/msgexec.c +++ b/gettext-tools/src/msgexec.c @@ -210,11 +210,11 @@ There is NO WARRANTY, to the extent permitted by law.\n\ /* Read input file. */ result = read_catalog_file (input_file, input_syntax); - /* Warn if the current locale is not suitable for this PO file. */ - compare_po_locale_charsets (result); - if (strcmp (sub_name, "0") != 0) { + /* Warn if the current locale is not suitable for this PO file. */ + compare_po_locale_charsets (result); + /* Block SIGPIPE for this process and for the subprocesses. The subprogram may have side effects (additionally to producing some output), therefore if there are no readers on stdout, processing of the @@ -353,7 +353,18 @@ process_string (const message_ty *mp, const char *str, size_t len) void (*orig_sigpipe_handler)(int); int exitstatus; - /* Set environment variables for the subprocess. */ + /* Set environment variables for the subprocess. + Note: These environment variables, especially MSGEXEC_MSGCTXT and + MSGEXEC_MSGCTXT, may contain non-ASCII characters. The subprocess + may not interpret these values correctly if the locale encoding is + different from the PO file's encoding. We want about this situation, + above. + On Unix, this problem is often harmless. On Windows, however, - both + native Windows and Cygwin - the values of environment variables *must* + be in the encoding that is the value of GetACP(), because the system + may convert the environment from char** to wchar_t** before spawning + the subprocess and back from wchar_t** to char** in the subprocess, + and it does so using the GetACP() codepage. */ if (mp->msgctxt != NULL) xsetenv ("MSGEXEC_MSGCTXT", mp->msgctxt, 1); else diff --git a/gettext-tools/src/msgfilter.c b/gettext-tools/src/msgfilter.c index 3fe7525e2..4cb2642ae 100644 --- a/gettext-tools/src/msgfilter.c +++ b/gettext-tools/src/msgfilter.c @@ -609,7 +609,18 @@ process_message (message_ty *mp) if (is_header (mp) && keep_header) return; - /* Set environment variables for the subprocess. */ + /* Set environment variables for the subprocess. + Note: These environment variables, especially MSGEXEC_MSGCTXT and + MSGEXEC_MSGCTXT, may contain non-ASCII characters. The subprocess + may not interpret these values correctly if the locale encoding is + different from the PO file's encoding. We want about this situation, + above. + On Unix, this problem is often harmless. On Windows, however, - both + native Windows and Cygwin - the values of environment variables *must* + be in the encoding that is the value of GetACP(), because the system + may convert the environment from char** to wchar_t** before spawning + the subprocess and back from wchar_t** to char** in the subprocess, + and it does so using the GetACP() codepage. */ if (mp->msgctxt != NULL) xsetenv ("MSGFILTER_MSGCTXT", mp->msgctxt, 1); else