ICU-8668 Remove isalpha dependency

X-SVN-Rev: 31095
This commit is contained in:
Abhinav Gupta 2011-12-12 16:16:15 +00:00
parent 91542e27a5
commit 336ce31084
3 changed files with 8 additions and 6 deletions

View file

@ -41,8 +41,6 @@
#define uprv_strstr(s, c) U_STANDARD_CPP_NAMESPACE strstr(s, c)
#define uprv_strrchr(s, c) U_STANDARD_CPP_NAMESPACE strrchr(s, c)
#define uprv_isalpha(c) U_STANDARD_CPP_NAMESPACE isalpha(c)
U_CAPI char U_EXPORT2
uprv_toupper(char c);

View file

@ -510,6 +510,8 @@ Locale::operator==( const Locale& other) const
return (uprv_strcmp(other.fullName, fullName) == 0);
}
#define ISASCIIALPHA(c) ((c) >= 'a' && (c) <= 'z' || (c) >= 'A' && (c) <= 'Z')
/*This function initializes a Locale from a C locale ID*/
Locale& Locale::init(const char* localeID, UBool canonicalize)
{
@ -601,9 +603,9 @@ Locale& Locale::init(const char* localeID, UBool canonicalize)
uprv_memcpy(language, fullName, fieldLen[0]);
language[fieldLen[0]] = 0;
}
if (fieldLen[1] == 4 && uprv_isalpha(field[1][0]) &&
uprv_isalpha(field[1][1]) && uprv_isalpha(field[1][2]) &&
uprv_isalpha(field[1][3])) {
if (fieldLen[1] == 4 && ISASCIIALPHA(field[1][0]) &&
ISASCIIALPHA(field[1][1]) && ISASCIIALPHA(field[1][2]) &&
ISASCIIALPHA(field[1][3])) {
/* We have at least a script */
uprv_memcpy(script, field[1], fieldLen[1]);
script[fieldLen[1]] = 0;

View file

@ -1248,6 +1248,8 @@ ulocimp_getLanguage(const char *localeID,
return i;
}
#define ISASCIIALPHA(c) ((c) >= 'a' && (c) <= 'z' || (c) >= 'A' && (c) <= 'Z')
U_CFUNC int32_t
ulocimp_getScript(const char *localeID,
char *script, int32_t scriptCapacity,
@ -1261,7 +1263,7 @@ ulocimp_getScript(const char *localeID,
/* copy the second item as far as possible and count its length */
while(!_isTerminator(localeID[idLen]) && !_isIDSeparator(localeID[idLen])
&& uprv_isalpha(localeID[idLen])) {
&& ISASCIIALPHA(localeID[idLen])) {
idLen++;
}