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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/locale/strxfrm.c ('k') | fusl/src/locale/uselocale.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/locale/textdomain.c
diff --git a/fusl/src/locale/textdomain.c b/fusl/src/locale/textdomain.c
new file mode 100644
index 0000000000000000000000000000000000000000..c501501d2b0e728f2634dcfa3458fc9101ccfab7
--- /dev/null
+++ b/fusl/src/locale/textdomain.c
@@ -0,0 +1,44 @@
+#include <libintl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+#include "libc.h"
+#include "atomic.h"
+
+static char *current_domain;
+
+char *__gettextdomain()
+{
+ return current_domain ? current_domain : "messages";
+}
+
+char *textdomain(const char *domainname)
+{
+ if (!domainname) return __gettextdomain();
+
+ size_t domlen = strlen(domainname);
+ if (domlen > NAME_MAX) {
+ errno = EINVAL;
+ return 0;
+ }
+
+ if (!current_domain) {
+ current_domain = malloc(NAME_MAX+1);
+ if (!current_domain) return 0;
+ }
+
+ memcpy(current_domain, domainname, domlen+1);
+
+ return current_domain;
+}
+
+char *gettext(const char *msgid)
+{
+ return dgettext(0, msgid);
+}
+
+char *ngettext(const char *msgid1, const char *msgid2, unsigned long int n)
+{
+ return dngettext(0, msgid1, msgid2, n);
+}
« 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