]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
intlconv: add safe check for transil feature (to detect wrong musl builds), fixes...
authorJaroslav Kysela <perex@perex.cz>
Mon, 19 Feb 2018 12:58:38 +0000 (13:58 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 19 Feb 2018 12:58:38 +0000 (13:58 +0100)
src/intlconv.c

index 3fe3eb683587911ad16eece01388fedf26468d34..fb0d176c0b064b01eaeedd1a166c64de2183bf27 100644 (file)
@@ -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