• 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

Revisionce6b5c9df2e8ed8b624cae3aece7614c43846601 (tree)
Zeit2007-05-12 04:35:35
AutorKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Avoid calling iconv' with unintialised codeset converter.

Ändern Zusammenfassung

Diff

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
1+2007-05-11 Keith Marshall <keithmarshall@users.sourceforge.net>
2+
3+ Avoid calling `iconv' with unintialised codeset converter.
4+
5+ * mcsource.c (mc_default_codeset): New static function.
6+ (mc_source): Use it, before each `iconv' call, to initialise the
7+ codeset converters, if `codeset' has not been assigned.
8+
19 2007-05-09 Keith Marshall <keithmarshall@users.sourceforge.net>
210
311 Provide more robust handling of possibly incomplete LC_MESSAGES macro
--- a/mcsource.c
+++ b/mcsource.c
@@ -130,6 +130,25 @@ int mc_directive( int status, const char *keyword )
130130 }
131131
132132 static
133+char *mc_default_codeset( void )
134+{
135+ /* Helper function, called when the message definition file for a
136+ * catalogue doesn't explicitly specify a codeset for the messages;
137+ * establish the default codeset for the message catalogue, using
138+ * the codeset of the LC_MESSAGES category in the present locale.
139+ */
140+ char *codeset;
141+
142+ if( (codeset = setlocale( LC_MESSAGES, "" )) == NULL )
143+ codeset = setlocale( LC_MESSAGES, NULL );
144+ setlocale( LC_CTYPE, codeset );
145+ codeset = strdup( nl_langinfo( CODESET ));
146+ setlocale( LC_CTYPE, "C" );
147+
148+ return codeset;
149+}
150+
151+static
133152 int errout( const char *src, long linenum, const char *fmt, ... )
134153 {
135154 va_list args;
@@ -238,19 +257,12 @@ struct msgdict *mc_source( const char *input )
238257 * of the current message catalogue locale, so ensure that
239258 * we have established an appropriate codeset mapping.
240259 */
241-
242260 if( codeset == NULL )
243261 {
244262 /* No codeset mapping is yet in place,
245263 * so default to the codeset of the system locale.
246264 */
247-
248- if( (codeset = setlocale( LC_MESSAGES, "" )) == NULL )
249- codeset = setlocale( LC_MESSAGES, NULL );
250- setlocale( LC_CTYPE, codeset );
251- codeset = strdup( nl_langinfo( CODESET ));
252- setlocale( LC_CTYPE, "C" );
253- codeset = map_codeset( iconv_map, codeset, "wchar_t" );
265+ codeset = map_codeset( iconv_map, mc_default_codeset(), "wchar_t" );
254266 codeset_decl_lineno = linenum;
255267 codeset_decl_src = input;
256268 }
@@ -259,7 +271,6 @@ struct msgdict *mc_source( const char *input )
259271 * multibyte character codeset specified for the message catalogue,
260272 * transforming to the wide character domain, for local processing.
261273 */
262-
263274 p += ((skip = iconv_mbtowc( &c, p, count )) > 0) ? skip : 0;
264275 }
265276
@@ -268,7 +279,6 @@ struct msgdict *mc_source( const char *input )
268279 /* We are parsing context which is defined in the POSIX,
269280 * or "C" locale, so read single byte character sequences.
270281 */
271-
272282 c = (wchar_t)(*p++);
273283 }
274284
@@ -755,6 +765,15 @@ struct msgdict *mc_source( const char *input )
755765 if( (status & (MSGTEXT | NEWLINE | CONTINUED)) == (MSGTEXT | NEWLINE) )
756766 {
757767 wchar_t terminator = L'\0';
768+ if( codeset == NULL )
769+ {
770+ /* No codeset mapping is yet in place,
771+ * so default to the codeset of the system locale.
772+ */
773+ codeset = map_codeset( iconv_map, mc_default_codeset(), "wchar_t" );
774+ codeset_decl_lineno = linenum;
775+ codeset_decl_src = input;
776+ }
758777 int xcount = iconv_wctomb( messages + msgloc, terminator );
759778 if( xcount >= 0 )
760779 {
@@ -856,4 +875,4 @@ struct msgdict *mc_source( const char *input )
856875 return head;
857876 }
858877
859-/* $RCSfile$Revision: 1.1.1.1 $: end of file */
878+/* $RCSfile$Revision: 1.2 $: end of file */