projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix wide printf forms ignoring width for %lc format specifier
[musl]
/
src
/
locale
/
dcngettext.c
diff --git
a/src/locale/dcngettext.c
b/src/locale/dcngettext.c
index
8b891d0
..
0b53286
100644
(file)
--- a/
src/locale/dcngettext.c
+++ b/
src/locale/dcngettext.c
@@
-10,6
+10,12
@@
#include "atomic.h"
#include "pleval.h"
#include "lock.h"
#include "atomic.h"
#include "pleval.h"
#include "lock.h"
+#include "fork_impl.h"
+
+#define malloc __libc_malloc
+#define calloc __libc_calloc
+#define realloc undef
+#define free undef
struct binding {
struct binding *next;
struct binding {
struct binding *next;
@@
-34,9
+40,11
@@
static char *gettextdir(const char *domainname, size_t *dirlen)
return 0;
}
return 0;
}
+static volatile int lock[1];
+volatile int *const __gettext_lockptr = lock;
+
char *bindtextdomain(const char *domainname, const char *dirname)
{
char *bindtextdomain(const char *domainname, const char *dirname)
{
- static volatile int lock[1];
struct binding *p, *q;
if (!domainname) return 0;
struct binding *p, *q;
if (!domainname) return 0;
@@
-122,6
+130,10
@@
char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2,
const struct __locale_map *lm;
size_t domlen;
struct binding *q;
const struct __locale_map *lm;
size_t domlen;
struct binding *q;
+ int old_errno = errno;
+
+ /* match gnu gettext behaviour */
+ if (!msgid1) goto notrans;
if ((unsigned)category >= LC_ALL) goto notrans;
if ((unsigned)category >= LC_ALL) goto notrans;
@@
-138,6
+150,7
@@
char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2,
lm = loc->cat[category];
if (!lm) {
notrans:
lm = loc->cat[category];
if (!lm) {
notrans:
+ errno = old_errno;
return (char *) ((n == 1) ? msgid1 : msgid2);
}
return (char *) ((n == 1) ? msgid1 : msgid2);
}
@@
-250,6
+263,7
@@
notrans:
trans += l+1;
}
}
trans += l+1;
}
}
+ errno = old_errno;
return (char *)trans;
}
return (char *)trans;
}