generalize mips-specific reloc code not to hard-code sym/type encoding
[musl] / src / locale / iconv.c
index 3c20c89..1eeea94 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <limits.h>
 #include <stdint.h>
+#include "locale_impl.h"
 
 #define UTF_32BE    0300
 #define UTF_16LE    0301
 #define BIG5        0340
 #define EUC_KR      0350
 
-/* FIXME: these are not implemented yet
- * EUC:   A1-FE A1-FE
- * GBK:   81-FE 40-7E,80-FE
- * Big5:  A1-FE 40-7E,A1-FE
- */
-
 /* Definitions of charmaps. Each charmap consists of:
  * 1. Empty-string-terminated list of null-terminated aliases.
  * 2. Special type code or number of elided entries.
@@ -171,9 +166,12 @@ size_t iconv(iconv_t cd0, char **restrict in, size_t *restrict inb, char **restr
        int err;
        unsigned char type = map[-1];
        unsigned char totype = tomap[-1];
+       locale_t *ploc = &CURRENT_LOCALE, loc = *ploc;
 
        if (!in || !*in || !*inb) return 0;
 
+       *ploc = UTF8_LOCALE;
+
        for (; *inb; *in+=l, *inb-=l) {
                c = *(unsigned char *)*in;
                l = 1;
@@ -437,6 +435,7 @@ size_t iconv(iconv_t cd0, char **restrict in, size_t *restrict inb, char **restr
                        break;
                }
        }
+       *ploc = loc;
        return x;
 ilseq:
        err = EILSEQ;
@@ -451,5 +450,6 @@ starved:
        x = -1;
 end:
        errno = err;
+       *ploc = loc;
        return x;
 }