musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/locale/iconv.c 16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
index 78c215e1..508d322e 100644
--- a/src/locale/iconv.c
+++ b/src/locale/iconv.c
@@ -12,8 +12,8 @@
#define UTF_32LE 0303
#define UCS2BE 0304
#define UCS2LE 0305
-#define US_ASCII 0306
-#define WCHAR_T 0307
+#define WCHAR_T 0306
+#define US_ASCII 0307
#define UTF_8 0310
#define EUC_JP 0320
#define SHIFT_JIS 0321
@@ -34,14 +34,14 @@
static const unsigned char charmaps[] =
"utf80円0円310円"
-"wchart0円0円307円"
+"wchart0円0円306円"
"ucs20円ucs2be0円0円304円"
"ucs2le0円0円305円"
"utf160円utf16be0円0円302円"
"utf16le0円0円301円"
"ucs40円ucs4be0円utf320円utf32be0円0円300円"
"ucs4le0円utf32le0円0円303円"
-"ascii0円usascii0円iso6460円iso646us0円0円306円"
+"ascii0円usascii0円iso6460円iso646us0円0円307円"
"eucjp0円0円320円"
"shiftjis0円sjis0円0円321円"
"gb180300円0円330円"
@@ -161,7 +161,7 @@ size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
c = *(unsigned char *)*in;
l = 1;
- if (c >= 128) switch (type) {
+ if (c >= 128 || type-UTF_32BE < 7U) switch (type) {
case UTF_8:
l = mbrtowc_utf8(&wc, *in, *inb, &st);
if (!l) l++;
@@ -196,9 +196,9 @@ size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
if (type-UCS2BE < 2U) goto ilseq;
l = 4;
if (*inb < 4) goto starved;
- d = get_16((void *)(*in + 2), from);
- if ((unsigned)(c-0xdc00) >= 0x400) goto ilseq;
- c = ((c-0xd800)<<10) | (d-0xdc00);
+ d = get_16((void *)(*in + 2), type);
+ if ((unsigned)(d-0xdc00) >= 0x400) goto ilseq;
+ c = ((c-0xd7c0)<<10) + (d-0xdc00);
}
break;
case SHIFT_JIS:
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月13日 23:17:18 +0000

AltStyle によって変換されたページ (->オリジナル) /