#include <iconv.h>
#include <stdlib.h>
+#include <errno.h>
bool wimlib_mbs_is_utf8 = false;
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,\
worst_case_len_expr, \
\
len = iconv(*cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); \
if (len == (size_t)-1) { \
- err_msg; \
+ if (!error_message_being_printed) { \
+ error_message_being_printed = true; \
+ err_msg; \
+ error_message_being_printed = false; \
+ } \
ret = err_return; \
} else { \
*out_nbytes_ret = sizeof(buf) - outbytesleft; \
{
do {
if ((unsigned char)*utf8_str > 127)
- return false;
+ return true;
} while (*++utf8_str);
- return true;
+ return false;
}