iconv: add euro symbol to GBK as single byte 0x80
[musl.git] / src / errno / strerror.c
blob7f926432b3090190f0288ecd2caa27c75daf80a9
1 #include <errno.h>
2 #include <stddef.h>
3 #include <string.h>
4 #include "locale_impl.h"
6 /* mips has one error code outside of the 8-bit range due to a
7 * historical typo, so we just remap it. */
8 #if EDQUOT==1133
9 #define EDQUOT_ORIG 1133
10 #undef EDQUOT
11 #define EDQUOT 109
12 #endif
14 static const struct errmsgstr_t {
15 #define E(n, s) char str##n[sizeof(s)];
16 #include "__strerror.h"
17 #undef E
18 } errmsgstr = {
19 #define E(n, s) s,
20 #include "__strerror.h"
21 #undef E
24 static const unsigned short errmsgidx[] = {
25 #define E(n, s) [n] = offsetof(struct errmsgstr_t, str##n),
26 #include "__strerror.h"
27 #undef E
30 char *__strerror_l(int e, locale_t loc)
32 const char *s;
33 #ifdef EDQUOT_ORIG
34 if (e==EDQUOT) e=0;
35 else if (e==EDQUOT_ORIG) e=EDQUOT;
36 #endif
37 if (e >= sizeof errmsgidx / sizeof *errmsgidx) e = 0;
38 s = (char *)&errmsgstr + errmsgidx[e];
39 return (char *)LCTRANS(s, LC_MESSAGES, loc);
42 char *strerror(int e)
44 return __strerror_l(e, CURRENT_LOCALE);
47 weak_alias(__strerror_l, strerror_l);