#define uprv_strtod(source, end) U_STANDARD_CPP_NAMESPACE strtod(source, end)
#define uprv_strtoul(str, end, base) U_STANDARD_CPP_NAMESPACE strtoul(str, end, base)
#define uprv_strtol(str, end, base) U_STANDARD_CPP_NAMESPACE strtol(str, end, base)
-#if U_PLATFORM == U_PF_WINDOWS
-# if defined(__BORLANDC__)
-# define uprv_stricmp(str1, str2) U_STANDARD_CPP_NAMESPACE stricmp(str1, str2)
-# define uprv_strnicmp(str1, str2, n) U_STANDARD_CPP_NAMESPACE strnicmp(str1, str2, n)
-# else
-# define uprv_stricmp(str1, str2) U_STANDARD_CPP_NAMESPACE _stricmp(str1, str2)
-# define uprv_strnicmp(str1, str2, n) U_STANDARD_CPP_NAMESPACE _strnicmp(str1, str2, n)
-# endif
-#elif defined(POSIX)
-# define uprv_stricmp(str1, str2) U_STANDARD_CPP_NAMESPACE strcasecmp(str1, str2)
-# define uprv_strnicmp(str1, str2, n) U_STANDARD_CPP_NAMESPACE strncasecmp(str1, str2, n)
-#else
-# define uprv_stricmp(str1, str2) T_CString_stricmp(str1, str2)
-# define uprv_strnicmp(str1, str2, n) T_CString_strnicmp(str1, str2, n)
-#endif
/* Conversion from a digit to the character with radix base from 2-19 */
/* May need to use U_UPPER_ORDINAL*/
U_CAPI int32_t U_EXPORT2
T_CString_stringToInteger(const char *integerString, int32_t radix);
+/**
+ * Case-insensitive, language-independent string comparison
+ * limited to the ASCII character repertoire.
+ */
U_CAPI int U_EXPORT2
-T_CString_stricmp(const char *str1, const char *str2);
+uprv_stricmp(const char *str1, const char *str2);
+/**
+ * Case-insensitive, language-independent string comparison
+ * limited to the ASCII character repertoire.
+ */
U_CAPI int U_EXPORT2
-T_CString_strnicmp(const char *str1, const char *str2, uint32_t n);
+uprv_strnicmp(const char *str1, const char *str2, uint32_t n);
#endif /* ! CSTRING_H */
#include "cmemory.h" /* for UAlignedMemory */
#include "cintltst.h"
#include "ccapitst.h"
-
-/* for not including "cstring.h" -begin*/
-#if U_PLATFORM_USES_ONLY_WIN32_API
-# define ctest_stricmp(str1, str2) U_STANDARD_CPP_NAMESPACE _stricmp(str1, str2)
-#elif defined(POSIX)
-# define ctest_stricmp(str1, str2) U_STANDARD_CPP_NAMESPACE strcasecmp(str1, str2)
-#else
-# define ctest_stricmp(str1, str2) T_CString_stricmp(str1, str2)
-#endif
-
-static int U_EXPORT2
-T_CString_stricmp(const char *str1, const char *str2) {
- if(str1==NULL) {
- if(str2==NULL) {
- return 0;
- } else {
- return -1;
- }
- } else if(str2==NULL) {
- return 1;
- } else {
- /* compare non-NULL strings lexically with lowercase */
- int rc;
- unsigned char c1, c2;
- for(;;) {
- c1=(unsigned char)*str1;
- c2=(unsigned char)*str2;
- if(c1==0) {
- if(c2==0) {
- return 0;
- } else {
- return -1;
- }
- } else if(c2==0) {
- return 1;
- } else {
- /* compare non-zero characters with lowercase */
- rc=(int)(unsigned char)tolower(c1)-(int)(unsigned char)tolower(c2);
- if(rc!=0) {
- return rc;
- }
- }
- ++str1;
- ++str2;
- }
- }
-}
-/* for not including "cstring.h" -end*/
+#include "cstring.h"
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
{
log_verbose("getName o.k. %s\n", ucnv_getName(myConverter, &err));
}
- if (ctest_stricmp(ucnv_getName(myConverter, &err), CodePagesToTest[codepage_index]))
+ if (uprv_stricmp(ucnv_getName(myConverter, &err), CodePagesToTest[codepage_index]))
log_err("getName failed\n");
else
log_verbose("getName ok\n");
/*
**********************************************************************
-* Copyright (C) 1998-2010, International Business Machines Corporation
+* Copyright (C) 1998-2011, International Business Machines Corporation
* and others. All Rights Reserved.
**********************************************************************
*
}
uprv_strcpy(src, "this is lower case");
- if(T_CString_stricmp(src, "THIS is lower CASE") != 0){
- log_err("FAIL: *****T_CString_stricmp() failed.");
+ if(uprv_stricmp(src, "THIS is lower CASE") != 0){
+ log_err("FAIL: *****uprv_stricmp() failed.");
}
- if((intValue=T_CString_stricmp(NULL, "first string is null") )!= -1){
- log_err("FAIL: T_CString_stricmp() where the first string is null failed. Expected: -1, returned %d\n", intValue);
+ if((intValue=uprv_stricmp(NULL, "first string is null") )!= -1){
+ log_err("FAIL: uprv_stricmp() where the first string is null failed. Expected: -1, returned %d\n", intValue);
}
- if((intValue=T_CString_stricmp("second string is null", NULL)) != 1){
- log_err("FAIL: T_CString_stricmp() where the second string is null failed. Expected: 1, returned %d\n", intValue);
+ if((intValue=uprv_stricmp("second string is null", NULL)) != 1){
+ log_err("FAIL: uprv_stricmp() where the second string is null failed. Expected: 1, returned %d\n", intValue);
}
- if((intValue=T_CString_stricmp(NULL, NULL)) != 0){
- log_err("FAIL: T_CString_stricmp(NULL, NULL) failed. Expected: 0, returned %d\n", intValue);;
+ if((intValue=uprv_stricmp(NULL, NULL)) != 0){
+ log_err("FAIL: uprv_stricmp(NULL, NULL) failed. Expected: 0, returned %d\n", intValue);;
}
- if((intValue=T_CString_stricmp("", "")) != 0){
- log_err("FAIL: T_CString_stricmp(\"\", \"\") failed. Expected: 0, returned %d\n", intValue);;
+ if((intValue=uprv_stricmp("", "")) != 0){
+ log_err("FAIL: uprv_stricmp(\"\", \"\") failed. Expected: 0, returned %d\n", intValue);;
}
- if((intValue=T_CString_stricmp("", "abc")) != -1){
- log_err("FAIL: T_CString_stricmp(\"\", \"abc\") failed. Expected: -1, returned %d\n", intValue);
+ if((intValue=uprv_stricmp("", "abc")) != -1){
+ log_err("FAIL: uprv_stricmp(\"\", \"abc\") failed. Expected: -1, returned %d\n", intValue);
}
- if((intValue=T_CString_stricmp("abc", "")) != 1){
- log_err("FAIL: T_CString_stricmp(\"abc\", \"\") failed. Expected: 1, returned %d\n", intValue);
+ if((intValue=uprv_stricmp("abc", "")) != 1){
+ log_err("FAIL: uprv_stricmp(\"abc\", \"\") failed. Expected: 1, returned %d\n", intValue);
}
temp=uprv_strdup("strdup");
uprv_free((char *)temp);
uprv_strcpy(src, "this is lower case");
- if(T_CString_strnicmp(src, "THIS", 4 ) != 0){
- log_err("FAIL: *****T_CString_strnicmp() failed.");
+ if(uprv_strnicmp(src, "THIS", 4 ) != 0){
+ log_err("FAIL: *****uprv_strnicmp() failed.");
}
- if((intValue=T_CString_strnicmp(NULL, "first string is null", 10) )!= -1){
- log_err("FAIL: T_CString_strnicmp() where the first string is null failed. Expected: -1, returned %d\n", intValue);
+ if((intValue=uprv_strnicmp(NULL, "first string is null", 10) )!= -1){
+ log_err("FAIL: uprv_strnicmp() where the first string is null failed. Expected: -1, returned %d\n", intValue);
}
- if((intValue=T_CString_strnicmp("second string is null", NULL, 10)) != 1){
- log_err("FAIL: T_CString_strnicmp() where the second string is null failed. Expected: 1, returned %d\n", intValue);
+ if((intValue=uprv_strnicmp("second string is null", NULL, 10)) != 1){
+ log_err("FAIL: uprv_strnicmp() where the second string is null failed. Expected: 1, returned %d\n", intValue);
}
- if((intValue=T_CString_strnicmp(NULL, NULL, 10)) != 0){
- log_err("FAIL: T_CString_strnicmp(NULL, NULL, 10) failed. Expected: 0, returned %d\n", intValue);;
+ if((intValue=uprv_strnicmp(NULL, NULL, 10)) != 0){
+ log_err("FAIL: uprv_strnicmp(NULL, NULL, 10) failed. Expected: 0, returned %d\n", intValue);;
}
- if((intValue=T_CString_strnicmp("", "", 10)) != 0){
- log_err("FAIL: T_CString_strnicmp(\"\", \"\") failed. Expected: 0, returned %d\n", intValue);;
+ if((intValue=uprv_strnicmp("", "", 10)) != 0){
+ log_err("FAIL: uprv_strnicmp(\"\", \"\") failed. Expected: 0, returned %d\n", intValue);;
}
- if((intValue=T_CString_strnicmp("", "abc", 10)) != -1){
- log_err("FAIL: T_CString_stricmp(\"\", \"abc\", 10) failed. Expected: -1, returned %d\n", intValue);
+ if((intValue=uprv_strnicmp("", "abc", 10)) != -1){
+ log_err("FAIL: uprv_stricmp(\"\", \"abc\", 10) failed. Expected: -1, returned %d\n", intValue);
}
- if((intValue=T_CString_strnicmp("abc", "", 10)) != 1){
- log_err("FAIL: T_CString_strnicmp(\"abc\", \"\", 10) failed. Expected: 1, returned %d\n", intValue);
+ if((intValue=uprv_strnicmp("abc", "", 10)) != 1){
+ log_err("FAIL: uprv_strnicmp(\"abc\", \"\", 10) failed. Expected: 1, returned %d\n", intValue);
}
}