struct iconv_list_head name = { \
.from_encoding = from, \
.to_encoding = to, \
- .list = LIST_HEAD_INIT(name.list), \
- .mutex = PTHREAD_MUTEX_INITIALIZER, \
}
static iconv_t *
errno = errno_save;
}
-/* Prevent printing an error message if a character conversion error occurs
- * while printing an error message. (This variable is not per-thread but it
- * doesn't matter too much since it's just the error messages.) */
-static bool error_message_being_printed = false;
-
#define DEFINE_CHAR_CONVERSION_FUNCTIONS(varname1, longname1, chartype1,\
varname2, longname2, chartype2,\
earlyreturn_on_utf8_locale, \
\
len = iconv(*cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); \
if (len == (size_t)-1) { \
- if (!error_message_being_printed) { \
- error_message_being_printed = true; \
- err_msg; \
- error_message_being_printed = false; \
- } \
+ err_msg; \
ret = err_return; \
} else { \
*out_nbytes_ret = bufsize - outbytesleft; \
\
len = iconv(*cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); \
if (len == (size_t)-1) { \
- if (!error_message_being_printed) { \
- error_message_being_printed = true; \
- err_msg; \
- error_message_being_printed = false; \
- } \
+ err_msg; \
ret = err_return; \
} else { \
out[(LARGE_NUMBER-outbytesleft)/sizeof(chartype2)] = 0; \
return utf8_to_tstr(utf8str, strlen(utf8str), out, &out_nbytes);
}
+static void
+iconv_init(struct iconv_list_head *head)
+{
+ pthread_mutex_init(&head->mutex, NULL);
+ INIT_LIST_HEAD(&head->list);
+}
+
static void
iconv_cleanup(struct iconv_list_head *head)
{
}
}
+void
+iconv_global_init(void)
+{
+ iconv_init(&iconv_utf8_to_tstr);
+ iconv_init(&iconv_tstr_to_utf8);
+#if !TCHAR_IS_UTF16LE
+ iconv_init(&iconv_utf16le_to_tstr);
+ iconv_init(&iconv_tstr_to_utf16le);
+ iconv_init(&iconv_utf16le_to_utf8);
+ iconv_init(&iconv_utf8_to_utf16le);
+#endif
+}
+
void
iconv_global_cleanup(void)
{