This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH/cygwin]: Return correct charset in nl_langinfo


Hi,

I just applied the below patch, which only affects Cygwin.  Right now,
nl_langinfo(CODESET) always returns "US-ASCII" for the C locale and
it returns charsets based on the language/territory setting, which is
wrong for Cygwin.  Therefore the patch always returns the value of
__locale_charset() on Cygwin.


Corinna

	* libc/locale/nl_langinfo.c (nl_langinfo): Just return current locale
	charset on Cygwin.


Index: libc/locale/nl_langinfo.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/nl_langinfo.c,v
retrieving revision 1.2
diff -u -p -r1.2 nl_langinfo.c
--- libc/locale/nl_langinfo.c	6 Jun 2003 19:57:51 -0000	1.2
+++ libc/locale/nl_langinfo.c	7 Oct 2009 16:44:54 -0000
@@ -37,10 +37,14 @@
 #include "lmonetary.h"
 #include "lmessages.h"
 
+#ifndef __CYGWIN__
 #define TRANSITION_PERIOD_HACK
+#endif
 
 #define _REL(BASE) ((int)item-BASE)
 
+extern char *__locale_charset ();
+
 char *
 _DEFUN(nl_langinfo, (item), 
        nl_item item) {
@@ -54,6 +58,9 @@ _DEFUN(nl_langinfo, (item), 
 
    switch (item) {
 	case CODESET:
+#ifdef __CYGWIN__
+		ret = __locale_charset ();
+#else
 		ret = "";
 		if ((s = setlocale(LC_CTYPE, NULL)) != NULL) {
 			if ((cs = strchr(s, '.')) != NULL) {
@@ -92,6 +99,7 @@ _DEFUN(nl_langinfo, (item), 
 				  )
 				ret = "US-ASCII";
 		}
+#endif /* __CYGWIN__ */
 		break;
 	case D_T_FMT:
 		ret = (char *) __get_current_time_locale()->c_fmt;

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]