From: Jaroslav Kysela Date: Mon, 19 Feb 2018 12:58:38 +0000 (+0100) Subject: intlconv: add safe check for transil feature (to detect wrong musl builds), fixes... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4535a2cf6ccf5209d220971890869390e1567889;p=thirdparty%2Ftvheadend.git intlconv: add safe check for transil feature (to detect wrong musl builds), fixes #4940, fixes #4827 --- diff --git a/src/intlconv.c b/src/intlconv.c index 3fe3eb683..fb0d176c0 100644 --- a/src/intlconv.c +++ b/src/intlconv.c @@ -23,11 +23,26 @@ tvh_iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, return iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft); } +static void +intlconv_test( void ) +{ + /* The string is "Yellow Horse" in Czech for the curiosity */ + const char *charset = intlconv_charset_id("ASCII", 1, 1); + char *s = intlconv_utf8safestr(charset, "ŽluťoučkýKůň", 128); + if (strcmp(s, "ZlutouckyKun")) { + tvherror(LS_MAIN, "iconv() routine is not working properly, aborting!"); + tvh_safe_usleep(2000000); + abort(); + } + free(s); +} + void intlconv_init( void ) { pthread_mutex_init(&intlconv_lock, NULL); pthread_mutex_init(&intlconv_lock_src, NULL); + intlconv_test(); } void