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]: Handle LC_MESSAGES


Hi,

I applied the below patch which only affects Cygwin.  It adds LC_MESSAGES
handling to loadlocale and changes the calls to Cygwin-specific locale
category loding functions to use the buffer pointer provided by newlib
to store the locale data.


Corinna


	* libc/locale/lmessages.c (__messages_load_locale): Take additional
	parameters for wide char to multibyte conversion.  Call
	__set_lc_messages_from_win on Cygwin.
	* libc/locale/lmessages.h: Make C++-safe.
	(__messages_load_locale): Change declaration.
	* libc/locale/lmonetary.c (__monetary_load_locale): Use
	_monetary_locale_buf as buffer pointer.
	* libc/locale/lnumeric.c (__numeric_load_locale): Use
	_numeric_locale_buf as buffer pointer.
	* libc/locale/timelocal.c (__time_load_locale): Use time_locale_buf
	as buffer pointer.
	* libc/locale/locale.c (loadlocale): Enable loading LC_MESSAGES data
	on Cygwin.


Index: libc/locale/lmessages.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/lmessages.c,v
retrieving revision 1.1
diff -u -p -r1.1 lmessages.c
--- libc/locale/lmessages.c	23 Aug 2002 01:56:03 -0000	1.1
+++ libc/locale/lmessages.c	9 Feb 2010 08:56:37 -0000
@@ -49,8 +49,29 @@ static int	_messages_using_locale;
 static char	*_messages_locale_buf;
 
 int
-__messages_load_locale(const char *name) {
+__messages_load_locale (const char *name, void *f_wctomb, const char *charset)
+{
+#ifdef __CYGWIN__
+	extern int __set_lc_messages_from_win (const char *,
+					       struct lc_messages_T *, char **,
+					       void *, const char *);
+	int ret;
 
+	int old_messages_using_locale = _messages_using_locale;
+	_messages_using_locale = 0;
+	ret = __set_lc_messages_from_win (name, &_messages_locale,
+					  &_messages_locale_buf,
+					  f_wctomb, charset);
+	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */
+	if (ret < 0)
+	  _messages_using_locale = old_messages_using_locale;
+	else
+	  {
+	    _messages_using_locale = ret;
+	    ret = 0;
+	  }
+	return ret;
+#else
 	/*
 	 * Propose that we can have incomplete locale file (w/o "{yes,no}str").
 	 * Initialize them before loading.  In case of complete locale, they'll
@@ -63,6 +84,7 @@ __messages_load_locale(const char *name)
 		_messages_locale_buf, "LC_MESSAGES",
 		LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN,
 		(const char **)&_messages_locale);
+#endif
 }
 
 struct lc_messages_T *
Index: libc/locale/lmessages.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/lmessages.h,v
retrieving revision 1.1
diff -u -p -r1.1 lmessages.h
--- libc/locale/lmessages.h	23 Aug 2002 01:56:03 -0000	1.1
+++ libc/locale/lmessages.h	9 Feb 2010 08:56:37 -0000
@@ -29,6 +29,10 @@
 #ifndef _LMESSAGES_H_
 #define	_LMESSAGES_H_
 
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
 struct	lc_messages_T {
 	const char	*yesexpr;
 	const char	*noexpr;
@@ -37,6 +41,8 @@ struct	lc_messages_T {
 };
 
 struct lc_messages_T *__get_current_messages_locale(void);
-int	__messages_load_locale(const char *);
+int __numeric_load_locale(const char *, void *, const char *);
+
+__END_DECLS
 
 #endif /* !_LMESSAGES_H_ */
Index: libc/locale/lmonetary.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/lmonetary.c,v
retrieving revision 1.2
diff -u -p -r1.2 lmonetary.c
--- libc/locale/lmonetary.c	22 Jan 2010 13:03:42 -0000	1.2
+++ libc/locale/lmonetary.c	9 Feb 2010 08:56:37 -0000
@@ -76,11 +76,12 @@ __monetary_load_locale(const char *name 
 
 #ifdef __CYGWIN__
 	extern int __set_lc_monetary_from_win (const char *,
-					       struct lc_monetary_T *,
+					       struct lc_monetary_T *, char **,
 					       void *, const char *);
 	int old_monetary_using_locale = _monetary_using_locale;
 	_monetary_using_locale = 0;
 	ret = __set_lc_monetary_from_win (name, &_monetary_locale,
+					  &_monetary_locale_buf,
 					  f_wctomb, charset);
 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */
 	if (ret < 0)
Index: libc/locale/lnumeric.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/lnumeric.c,v
retrieving revision 1.2
diff -u -p -r1.2 lnumeric.c
--- libc/locale/lnumeric.c	22 Jan 2010 13:03:42 -0000	1.2
+++ libc/locale/lnumeric.c	9 Feb 2010 08:56:37 -0000
@@ -54,11 +54,12 @@ __numeric_load_locale(const char *name ,
 
 #ifdef __CYGWIN__
 	extern int __set_lc_numeric_from_win (const char *,
-					      struct lc_numeric_T *,
+					      struct lc_numeric_T *, char **,
 					      void *, const char *);
 	int old_numeric_using_locale = _numeric_using_locale;
 	_numeric_using_locale = 0;
 	ret = __set_lc_numeric_from_win (name, &_numeric_locale,
+					 &_numeric_locale_buf,
 					 f_wctomb, charset);
 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */
 	if (ret < 0)
Index: libc/locale/locale.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/locale.c,v
retrieving revision 1.39
diff -u -p -r1.39 locale.c
--- libc/locale/locale.c	7 Feb 2010 13:52:34 -0000	1.39
+++ libc/locale/locale.c	9 Feb 2010 08:56:37 -0000
@@ -817,7 +817,13 @@ restart:
 			      || strncmp (locale, "zh", 2) == 0));
     }
   else if (category == LC_MESSAGES)
-    strcpy (lc_message_charset, charset);
+    {
+#ifdef __CYGWIN__
+      ret = __messages_load_locale (locale, (void *) l_wctomb, charset);
+      if (!ret)
+#endif
+      strcpy (lc_message_charset, charset);
+    }
 #ifdef __CYGWIN__
   else if (category == LC_COLLATE)
     ret = __collate_load_locale (locale, (void *) l_mbtowc, charset);
Index: libc/locale/timelocal.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/timelocal.c,v
retrieving revision 1.2
diff -u -p -r1.2 timelocal.c
--- libc/locale/timelocal.c	22 Jan 2010 13:03:42 -0000	1.2
+++ libc/locale/timelocal.c	9 Feb 2010 08:56:37 -0000
@@ -109,10 +109,11 @@ __time_load_locale(const char *name, voi
 
 #ifdef __CYGWIN__
 	extern int __set_lc_time_from_win (const char *, struct lc_time_T *,
-					   void *, const char *);
+					   char **, void *, const char *);
 	int old_time_using_locale = _time_using_locale;
 	_time_using_locale = 0;
-	ret = __set_lc_time_from_win (name, &_time_locale, f_wctomb, charset);
+	ret = __set_lc_time_from_win (name, &_time_locale, &time_locale_buf,
+				      f_wctomb, charset);
 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */
 	if (ret < 0)
 	  _time_using_locale = old_time_using_locale;


-- 
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]