diff options
-rw-r--r-- | libxslt/xsltlocale.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libxslt/xsltlocale.c b/libxslt/xsltlocale.c index ec03cde0..2caa2ec8 100644 --- a/libxslt/xsltlocale.c +++ b/libxslt/xsltlocale.c @@ -26,9 +26,9 @@ #define LC_COLLATE_MASK (1 << LC_COLLATE) #endif -#define ISALPHA(c) ((c & 0xc0) == 0x40 && (unsigned)((c & 0x1f) - 1) < 26) #define TOUPPER(c) (c & ~0x20) #define TOLOWER(c) (c | 0x20) +#define ISALPHA(c) ((unsigned)(TOUPPER(c) - 'A') < 26) /*without terminating null character*/ #define XSLTMAX_ISO639LANGLEN 8 @@ -97,11 +97,11 @@ xsltNewLocale(const xmlChar *languageTag) { return(NULL); llen = i; - *q++ = '_'; if (*p) { if (*p++ != '-') return(NULL); + *q++ = '_'; for (i=0; i<XSLTMAX_ISO3166CNTRYLEN && ISALPHA(*p); ++i) *q++ = TOUPPER(*p++); @@ -116,7 +116,7 @@ xsltNewLocale(const xmlChar *languageTag) { /* Continue without using country code */ - q = localeName + llen + 1; + q = localeName + llen; } /* Try locale without territory, e.g. for Esperanto (eo) */ @@ -135,7 +135,8 @@ xsltNewLocale(const xmlChar *languageTag) { if (region == NULL) return(NULL); - q = localeName + llen + 1; + q = localeName + llen; + *q++ = '_'; *q++ = region[0]; *q++ = region[1]; memcpy(q, ".utf8", 6); |