• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得windowscocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

POSIX.1 National Language Support API for MinGW


Commit MetaInfo

Revisionf3ec94b49f6b96292eb02172ba22ebf75b70a530 (tree)
Zeit2007-08-17 20:07:55
AutorKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Make catopen' respect LC_ALL, overriding LC_MESSAGES environment variable, as required by POSIX, when opening message catalogues in NL_CAT_LOCALE mode.

Ändern Zusammenfassung

Diff

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
1+2007-08-16 Keith Marshall <keithmarshall@users.sourceforge.net>
2+
3+ Make `catopen' respect LC_ALL, overriding LC_MESSAGES environment
4+ variable, as required by POSIX, when opening message catalogues in
5+ NL_CAT_LOCALE mode.
6+
7+ * catopen.c (mc_nlspath_open): Use ...
8+ (mc_nl_cat_locale_getenv): this new static function.
9+ (NLS_LOCALE_STRING): Defunct macro; deleted.
10+
111 2007-07-16 Keith Marshall <keithmarshall@users.sourceforge.net>
212
313 Add manpage sources.
--- a/catopen.c
+++ b/catopen.c
@@ -9,7 +9,7 @@
99 * POSIX compatible national language message catalogues in MinGW.
1010 *
1111 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
12- * Last modification: 29-Dec-2006
12+ * Last modification: 08-Aug-2007
1313 *
1414 *
1515 * This is free software. It is provided AS IS, in the hope that it may
@@ -153,9 +153,37 @@ int mc_check_break_code( wchar_t chk, wchar_t *break_code )
153153 }
154154
155155 static
156+char *mc_nl_cat_locale_getenv( int flags )
157+{
158+ char *retptr;
159+
160+ /* Retrieve any appropriate LC_MESSAGES or LANG setting string
161+ * from the process environment, for use in interpreting NLSPATH.
162+ */
163+ if( flags & NL_CAT_LOCALE )
164+ {
165+ /* When this flag is set, then we use the LC_MESSAGES setting,
166+ * if any, noting that this may be overridden by LC_ALL.
167+ */
168+ if( (((retptr = getenv( "LC_ALL" )) != NULL) && (*retptr != '\0'))
169+ || (((retptr = getenv( "LC_MESSAGES" )) != NULL) && (*retptr != '\0')) )
170+ return retptr;
171+ }
172+ /* When NL_CAT_LOCALE is not set, or if LC_MESSAGES is not defined,
173+ * fall back to using the LANG specification.
174+ */
175+ if( ((retptr = getenv( "LANG" )) != NULL) && (*retptr != '\0') )
176+ return retptr;
177+
178+ /* Fall through, if there is no appropriate specification
179+ * in the process environment, returning NULL.
180+ */
181+ return NULL;
182+}
183+
184+static
156185 int mc_nlspath_open( __const char *msgcat, unsigned flags )
157186 {
158-# define NLS_LOCALE_STRING (flags & NL_CAT_LOCALE) ? "LC_MESSAGES" : "LANG"
159187 # define mc_select(PREF, ALT) (mblen((PREF), MB_CUR_MAX) > 0) ? (PREF) : (ALT)
160188
161189 int fd, step, copy_index, headroom;
@@ -299,8 +327,8 @@ int mc_nlspath_open( __const char *msgcat, unsigned flags )
299327 * present, otherwise for the system locale.
300328 */
301329 if( (nls_locale != NULL)
302- || ((nls_locale = getenv( NLS_LOCALE_STRING )) != NULL)
303- || ((nls_locale = setlocale( LC_MESSAGES, NULL )) != NULL) )
330+ || ((nls_locale = mc_nl_cat_locale_getenv( flags )) != NULL)
331+ || ((nls_locale = setlocale( LC_MESSAGES, NULL )) != NULL) )
304332 {
305333 subst = nls_locale;
306334 wchar_t *break_code = L"_.@";
@@ -468,4 +496,4 @@ nl_catd catopen( __const char *name, int flags )
468496 return (nl_catd)_mctab_( mc_open, name, flags );
469497 }
470498
471-/* $RCSfile$Revision: 1.2 $: end of file */
499+/* $RCSfile$Revision: 1.3 $: end of file */