{"thread":{"id":"35393","subject":"gettext CTYPE for libc","startedAt":"2013-11-23T02:15:50Z","lastAt":"2013-11-25T19:31:02Z","messageCount":5,"participants":["Trần Ngọc Quân","Thomas Rast","Duy Nguyen","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"230985","messageId":"52900FD6.5020202@gmail.com","threadId":"35393","inReplyTo":null,"subject":"gettext CTYPE for libc","fromName":"Trần Ngọc Quân","fromEmail":"vnwildman@gmail.com","sentAt":"2013-11-23T02:15:50Z","receivedAt":"2013-11-23T02:15:50Z","isPatch":false,"sender":{"key":"vnwildman@gmail.com","avatar":"https://avatars.githubusercontent.com/u/508758?v=4"},"body":"Hello,\n\n$ mkdir xyz\n$ cd xyz\n$ rmdir ../xyz\n$ git status\nfatal: Unable to read current working directory: Kh?ng c? t?p tin ho?c\nth? m?c nh? v?y\n\nSo, somthing wrong with our charset.\n\n$ strace git status 2>&1 | grep open\nopen(\"/etc/ld.so.cache\", O_RDONLY|O_CLOEXEC) = 3\nopen(\"/lib/i386-linux-gnu/libz.so.1\", O_RDONLY|O_CLOEXEC) = 3\nopen(\"/lib/i386-linux-gnu/libcrypto.so.1.0.0\", O_RDONLY|O_CLOEXEC) = 3\nopen(\"/lib/i386-linux-gnu/libpthread.so.0\", O_RDONLY|O_CLOEXEC) = 3\nopen(\"/lib/i386-linux-gnu/libc.so.6\", O_RDONLY|O_CLOEXEC) = 3\nopen(\"/lib/i386-linux-gnu/libdl.so.2\", O_RDONLY|O_CLOEXEC) = 3\nopen(\"/dev/null\", O_RDWR|O_LARGEFILE)   = 3\nopen(\"/usr/lib/locale/locale-archive\", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3\nopen(\"/usr/share/locale/locale.alias\", O_RDONLY|O_CLOEXEC) = 3\nopen(\"/usr/share/locale/vi_VN/LC_MESSAGES/libc.mo\", O_RDONLY) = -1\nENOENT (No such file or directory)\nopen(\"/usr/share/locale/vi/LC_MESSAGES/libc.mo\", O_RDONLY) = -1 ENOENT\n(No such file or directory)\nopen(\"/usr/share/locale-langpack/vi_VN/LC_MESSAGES/libc.mo\", O_RDONLY) =\n-1 ENOENT (No such file or directory)\nopen(\"/usr/share/locale-langpack/vi/LC_MESSAGES/libc.mo\", O_RDONLY) = 3\nopen(\"/usr/lib/i386-linux-gnu/gconv/gconv-modules.cache\", O_RDONLY) = 3\n\nWe will see, this string come from libc.mo\n$ gettext --domain=libc \"No such file or directory\"\nKhông có tập tin hoặc thư mục như vậy\n\nin git's gettext.c, it not allow CTYPE=\"\" for all domain, so we will set\nthis one individually. In this ex. I set it for libc:\n\n$ git diff\ndiff --git a/gettext.c b/gettext.c\nindex 71e9545..abd3978 100644\n--- a/gettext.c\n+++ b/gettext.c\n@@ -115,6 +115,7 @@ static void init_gettext_charset(const char *domain)\n        setlocale(LC_CTYPE, \"\");\n        charset = locale_charset();\n        bind_textdomain_codeset(domain, charset);\n+       bind_textdomain_codeset(\"libc\", charset);\n        setlocale(LC_CTYPE, \"C\");\n }\n\nAnd it work as I expect!\n\n-- \nTrần Ngọc Quân.\n"},{"id":"231010","messageId":"874n72goem.fsf@linux-k42r.v.cablecom.net","threadId":"35393","inReplyTo":"52900FD6.5020202@gmail.com","subject":"Re: gettext CTYPE for libc","fromName":"Thomas Rast","fromEmail":"tr@thomasrast.ch","sentAt":"2013-11-24T09:05:53Z","receivedAt":"2013-11-24T09:05:53Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Trần Ngọc Quân <vnwildman@gmail.com> writes:\n\n> $ git status\n> fatal: Unable to read current working directory: Kh?ng c? t?p tin ho?c\n> th? m?c nh? v?y\n>\n> So, somthing wrong with our charset.\n[...]\n> $ gettext --domain=libc \"No such file or directory\"\n> Không có tập tin hoặc thư mục như vậy\n>\n> in git's gettext.c, it not allow CTYPE=\"\" for all domain, so we will set\n> this one individually. In this ex. I set it for libc:\n>\n> $ git diff\n> diff --git a/gettext.c b/gettext.c\n> index 71e9545..abd3978 100644\n> --- a/gettext.c\n> +++ b/gettext.c\n> @@ -115,6 +115,7 @@ static void init_gettext_charset(const char *domain)\n>         setlocale(LC_CTYPE, \"\");\n>         charset = locale_charset();\n>         bind_textdomain_codeset(domain, charset);\n> +       bind_textdomain_codeset(\"libc\", charset);\n>         setlocale(LC_CTYPE, \"C\");\n>  }\n\nDo you know why this \"suddenly\" broke?  The long comment in\ninit_gettext_charset() suggests that the *existing* code is there to\nhandle exactly this problem, and apparently it doesn't.  Why?  Has libc\nmoved the perror() strings into a separate domain in some version?\n\n-- \nThomas Rast\ntr@thomasrast.ch\n"},{"id":"231026","messageId":"5292A8A1.2040903@gmail.com","threadId":"35393","inReplyTo":"874n72goem.fsf@linux-k42r.v.cablecom.net","subject":"Re: gettext CTYPE for libc","fromName":"Trần Ngọc Quân","fromEmail":"vnwildman@gmail.com","sentAt":"2013-11-25T01:32:17Z","receivedAt":"2013-11-25T01:32:17Z","isPatch":false,"sender":{"key":"vnwildman@gmail.com","avatar":"https://avatars.githubusercontent.com/u/508758?v=4"},"body":"On 24/11/2013 16:05, Thomas Rast wrote:\n> Trần Ngọc Quân <vnwildman@gmail.com> writes:\n>\n>> $ git status\n>> fatal: Unable to read current working directory: Kh?ng c? t?p tin ho?c\n>> th? m?c nh? v?y\n>>\n>> So, somthing wrong with our charset.\n> [...]\n> Do you know why this \"suddenly\" broke?\nI think git set CTYPE=\"C\" for libc, so charset become  7-bit ASCII, but\nit don't set LC_MESSAGES=\"C\" for libc and libc will get this one from\nsystem variable.\n> The long comment in\n> init_gettext_charset() suggests that the *existing* code is there to\n> handle exactly this problem, and apparently it doesn't.  Why?  Has libc\n> moved the perror() strings into a separate domain in some version?\nSee setlocale(3) [1]\nI'm a newbie in GIT. I'm not sure about git work correctly [2] if set\ngit's charset to same with system.\nI don't think libc moved perror() string in separate domain. It use its\nown domain.\n\n[1]  http://man7.org/linux/man-pages/man3/setlocale.3.html\n[2]  incorrect if some function need work in ASCII mode\n\n-- \nTrần Ngọc Quân.\n"},{"id":"231058","messageId":"CACsJy8CMUMdzJyDABFj47oY8j8kKr5K88niXoM0o4dVQkWvkqA@mail.gmail.com","threadId":"35393","inReplyTo":"52900FD6.5020202@gmail.com","subject":"Re: gettext CTYPE for libc","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-11-25T07:20:38Z","receivedAt":"2013-11-25T07:20:38Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Jonathan I see you participated in bug 6530, mentioned in the big\ncomment block in init_gettext_charset(). The bug seems fixed since\nglibc 2.17. Do you think it's ok to revert the workaround if we detect\nthe running glibc is fixed (or if it does not run glibc at all)? I\nthink we could use gnu_get_libc_version() to detect it.\n\n[1] https://sourceware.org/bugzilla/show_bug.cgi?id=6530\n\nOn Sat, Nov 23, 2013 at 9:15 AM, Trần Ngọc Quân <vnwildman@gmail.com> wrote:\n> Hello,\n>\n> $ mkdir xyz\n> $ cd xyz\n> $ rmdir ../xyz\n> $ git status\n> fatal: Unable to read current working directory: Kh?ng c? t?p tin ho?c\n> th? m?c nh? v?y\n>\n> So, somthing wrong with our charset.\n>\n> $ strace git status 2>&1 | grep open\n> open(\"/etc/ld.so.cache\", O_RDONLY|O_CLOEXEC) = 3\n> open(\"/lib/i386-linux-gnu/libz.so.1\", O_RDONLY|O_CLOEXEC) = 3\n> open(\"/lib/i386-linux-gnu/libcrypto.so.1.0.0\", O_RDONLY|O_CLOEXEC) = 3\n> open(\"/lib/i386-linux-gnu/libpthread.so.0\", O_RDONLY|O_CLOEXEC) = 3\n> open(\"/lib/i386-linux-gnu/libc.so.6\", O_RDONLY|O_CLOEXEC) = 3\n> open(\"/lib/i386-linux-gnu/libdl.so.2\", O_RDONLY|O_CLOEXEC) = 3\n> open(\"/dev/null\", O_RDWR|O_LARGEFILE)   = 3\n> open(\"/usr/lib/locale/locale-archive\", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3\n> open(\"/usr/share/locale/locale.alias\", O_RDONLY|O_CLOEXEC) = 3\n> open(\"/usr/share/locale/vi_VN/LC_MESSAGES/libc.mo\", O_RDONLY) = -1\n> ENOENT (No such file or directory)\n> open(\"/usr/share/locale/vi/LC_MESSAGES/libc.mo\", O_RDONLY) = -1 ENOENT\n> (No such file or directory)\n> open(\"/usr/share/locale-langpack/vi_VN/LC_MESSAGES/libc.mo\", O_RDONLY) =\n> -1 ENOENT (No such file or directory)\n> open(\"/usr/share/locale-langpack/vi/LC_MESSAGES/libc.mo\", O_RDONLY) = 3\n> open(\"/usr/lib/i386-linux-gnu/gconv/gconv-modules.cache\", O_RDONLY) = 3\n>\n> We will see, this string come from libc.mo\n> $ gettext --domain=libc \"No such file or directory\"\n> Không có tập tin hoặc thư mục như vậy\n>\n> in git's gettext.c, it not allow CTYPE=\"\" for all domain, so we will set\n> this one individually. In this ex. I set it for libc:\n>\n> $ git diff\n> diff --git a/gettext.c b/gettext.c\n> index 71e9545..abd3978 100644\n> --- a/gettext.c\n> +++ b/gettext.c\n> @@ -115,6 +115,7 @@ static void init_gettext_charset(const char *domain)\n>         setlocale(LC_CTYPE, \"\");\n>         charset = locale_charset();\n>         bind_textdomain_codeset(domain, charset);\n> +       bind_textdomain_codeset(\"libc\", charset);\n>         setlocale(LC_CTYPE, \"C\");\n>  }\n>\n> And it work as I expect!\n>\n> --\n> Trần Ngọc Quân.\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n\n\n-- \nDuy\n"},{"id":"231085","messageId":"20131125193102.GM4212@google.com","threadId":"35393","inReplyTo":"CACsJy8CMUMdzJyDABFj47oY8j8kKr5K88niXoM0o4dVQkWvkqA@mail.gmail.com","subject":"Re: gettext CTYPE for libc","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-11-25T19:31:02Z","receivedAt":"2013-11-25T19:31:02Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Duy Nguyen wrote:\n\n>             Do you think it's ok to revert the workaround if we detect\n> the running glibc is fixed (or if it does not run glibc at all)? I\n> think we could use gnu_get_libc_version() to detect it.\n\nThat would be wonderful.\n\nThanks,\nJonathan\n"}]}