Browse Source
Previously libandroid-support contained inline stubs for libintl.h functions (gettext(), dgettext() and friends). We now provide inline versions of them in libintl.h directly so libandroid-support is no longer necessary to get them.android-5
Fredrik Fornwall
8 years ago
3 changed files with 59 additions and 6 deletions
@ -0,0 +1,53 @@ |
|||||
|
#ifndef _LIBINTL_H |
||||
|
#define _LIBINTL_H |
||||
|
|
||||
|
#include <errno.h> |
||||
|
#include <string.h> |
||||
|
|
||||
|
static __inline__ char* gettext(const char* msgid) |
||||
|
{ return (char*) msgid; } |
||||
|
|
||||
|
static __inline__ char* dgettext(const char* domainname, const char* msgid) |
||||
|
{ return (char*) msgid; } |
||||
|
|
||||
|
static __inline__ char* dcgettext(const char* domainname, const char* msgid, int category) |
||||
|
{ return (char*) msgid; } |
||||
|
|
||||
|
static __inline__ char* ngettext(const char* msgid1, const char* msgid2, unsigned long int n) |
||||
|
{ return (char *) ((n == 1) ? msgid1 : msgid2); } |
||||
|
|
||||
|
static __inline__ char* dngettext(const char* domainname, const char* msgid1, const char* msgid2, unsigned long int n) |
||||
|
{ return (char *) ((n == 1) ? msgid1 : msgid2); } |
||||
|
|
||||
|
static __inline__ char* dcngettext(const char* domainname, const char* msgid1, const char* msgid2, unsigned long int n, int category) |
||||
|
{ return (char *) ((n == 1) ? msgid1 : msgid2); } |
||||
|
|
||||
|
static __inline__ char* textdomain(const char* domainname) |
||||
|
{ |
||||
|
static const char default_str[] = "messages"; |
||||
|
if (domainname && *domainname && strcmp(domainname, default_str)) { |
||||
|
errno = EINVAL; |
||||
|
return NULL; |
||||
|
} |
||||
|
return (char*) default_str; |
||||
|
} |
||||
|
|
||||
|
static __inline__ char* bindtextdomain(const char* domainname, const char* dirname) |
||||
|
{ |
||||
|
static const char dir[] = "/"; |
||||
|
if (!domainname || !*domainname || (dirname && ((dirname[0] != '/') || dirname[1]))) { |
||||
|
errno = EINVAL; |
||||
|
return NULL; |
||||
|
} |
||||
|
return (char*) dir; |
||||
|
} |
||||
|
|
||||
|
static __inline__ char* bind_textdomain_codeset(const char* domainname, const char* codeset) |
||||
|
{ |
||||
|
if (!domainname || !*domainname || (codeset && strcasecmp(codeset, "UTF-8"))) { |
||||
|
errno = EINVAL; |
||||
|
} |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
#endif |
Loading…
Reference in new issue