From 73535010d72d1a7d46e4f5c6c98f41fab90df489 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 15 May 2009 11:30:18 +0000 Subject: [PATCH] * cygpath.cc (main): Only setlocale for LC_CTYPE category. Fallback to UTF-8 if locale is "C". * ldd.cc (main): Ditto. * mkgroup.c (main): Ditto. * mkpasswd.c (main): Ditto. * passwd.c (main): Ditto. --- winsup/utils/ChangeLog | 9 +++++++++ winsup/utils/cygpath.cc | 5 ++++- winsup/utils/ldd.cc | 6 +++++- winsup/utils/mkgroup.c | 5 +++++ winsup/utils/mkpasswd.c | 5 +++++ winsup/utils/passwd.c | 6 ++++-- 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 7024e29f3..ea7fb223b 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,12 @@ +2009-05-15 Corinna Vinschen + + * cygpath.cc (main): Only setlocale for LC_CTYPE category. Fallback + to UTF-8 if locale is "C". + * ldd.cc (main): Ditto. + * mkgroup.c (main): Ditto. + * mkpasswd.c (main): Ditto. + * passwd.c (main): Ditto. + 2009-05-13 Corinna Vinschen Christopher Faylor diff --git a/winsup/utils/cygpath.cc b/winsup/utils/cygpath.cc index ade86f7f2..c993ccd0a 100644 --- a/winsup/utils/cygpath.cc +++ b/winsup/utils/cygpath.cc @@ -982,7 +982,10 @@ main (int argc, char **argv) { int o; - setlocale (LC_ALL, ""); + /* Use locale from environment. If not set or set to "C", use UTF-8. */ + setlocale (LC_CTYPE, ""); + if (!strcmp (setlocale (LC_CTYPE, NULL), "C")) + setlocale (LC_CTYPE, "en_US.UTF-8"); prog_name = strrchr (argv[0], '/'); if (!prog_name) prog_name = strrchr (argv[0], '\\'); diff --git a/winsup/utils/ldd.cc b/winsup/utils/ldd.cc index 7a7e04ab9..b2d6f7b92 100644 --- a/winsup/utils/ldd.cc +++ b/winsup/utils/ldd.cc @@ -327,7 +327,11 @@ main (int argc, char **argv) { int optch; int index; - setlocale (LC_ALL, ""); + + /* Use locale from environment. If not set or set to "C", use UTF-8. */ + setlocale (LC_CTYPE, ""); + if (!strcmp (setlocale (LC_CTYPE, NULL), "C")) + setlocale (LC_CTYPE, "en_US.UTF-8"); while ((optch = getopt_long (argc, argv, "dru", longopts, &index)) != -1) switch (optch) { diff --git a/winsup/utils/mkgroup.c b/winsup/utils/mkgroup.c index 74de36c21..07d15fe5f 100644 --- a/winsup/utils/mkgroup.c +++ b/winsup/utils/mkgroup.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -749,6 +750,10 @@ main (int argc, char **argv) if (!isatty (1)) setmode (1, O_BINARY); + /* Use locale from environment. If not set or set to "C", use UTF-8. */ + setlocale (LC_CTYPE, ""); + if (!strcmp (setlocale (LC_CTYPE, NULL), "C")) + setlocale (LC_CTYPE, "en_US.UTF-8"); load_dsgetdcname (); in_domain = fetch_primary_domain (); fetch_current_pgrp_sid (); diff --git a/winsup/utils/mkpasswd.c b/winsup/utils/mkpasswd.c index 0ba88bf75..3947309dd 100644 --- a/winsup/utils/mkpasswd.c +++ b/winsup/utils/mkpasswd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -708,6 +709,10 @@ main (int argc, char **argv) if (!isatty (1)) setmode (1, O_BINARY); + /* Use locale from environment. If not set or set to "C", use UTF-8. */ + setlocale (LC_CTYPE, ""); + if (!strcmp (setlocale (LC_CTYPE, NULL), "C")) + setlocale (LC_CTYPE, "en_US.UTF-8"); load_dsgetdcname (); in_domain = fetch_primary_domain (); fetch_current_user_sid (); diff --git a/winsup/utils/passwd.c b/winsup/utils/passwd.c index 3ea91a4e5..188f39f17 100644 --- a/winsup/utils/passwd.c +++ b/winsup/utils/passwd.c @@ -408,8 +408,10 @@ main (int argc, char **argv) if (c) *c = '\0'; - setlocale (LC_ALL, ""); - + /* Use locale from environment. If not set or set to "C", use UTF-8. */ + setlocale (LC_CTYPE, ""); + if (!strcmp (setlocale (LC_CTYPE, NULL), "C")) + setlocale (LC_CTYPE, "en_US.UTF-8"); while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != EOF) switch (opt) {