Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: fusl/src/locale/textdomain.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/locale/strxfrm.c ('k') | fusl/src/locale/uselocale.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <libintl.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <errno.h>
5 #include <limits.h>
6 #include "libc.h"
7 #include "atomic.h"
8
9 static char *current_domain;
10
11 char *__gettextdomain()
12 {
13 return current_domain ? current_domain : "messages";
14 }
15
16 char *textdomain(const char *domainname)
17 {
18 if (!domainname) return __gettextdomain();
19
20 size_t domlen = strlen(domainname);
21 if (domlen > NAME_MAX) {
22 errno = EINVAL;
23 return 0;
24 }
25
26 if (!current_domain) {
27 current_domain = malloc(NAME_MAX+1);
28 if (!current_domain) return 0;
29 }
30
31 memcpy(current_domain, domainname, domlen+1);
32
33 return current_domain;
34 }
35
36 char *gettext(const char *msgid)
37 {
38 return dgettext(0, msgid);
39 }
40
41 char *ngettext(const char *msgid1, const char *msgid2, unsigned long int n)
42 {
43 return dngettext(0, msgid1, msgid2, n);
44 }
OLDNEW
« no previous file with comments | « fusl/src/locale/strxfrm.c ('k') | fusl/src/locale/uselocale.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698