ICU-535 fixed some compiler warnings

X-SVN-Rev: 2314
This commit is contained in:
George Rhoten 2000-08-21 19:55:59 +00:00
parent 115436cc74
commit 3de2aeabe7
3 changed files with 108 additions and 35 deletions

View File

@ -150,9 +150,13 @@ typedef int32_t UTextOffset;
# define UTF_GET_CHAR_UNSAFE(s, i, c) UTF16_GET_CHAR_UNSAFE(s, i, c)
# define UTF_GET_CHAR_SAFE(s, start, i, length, c, strict) UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict)
# define UTF_GET_CHAR_SAFE_STRICT(s, start, i, length, c) UTF16_GET_CHAR_SAFE_STRICT(s, start, i, length, c)
# define UTF_GET_CHAR_SAFE_LENIENT(s, start, i, length, c) UTF16_GET_CHAR_SAFE_LENIENT(s, start, i, length, c)
# define UTF_NEXT_CHAR_UNSAFE(s, i, c) UTF16_NEXT_CHAR_UNSAFE(s, i, c)
# define UTF_NEXT_CHAR_SAFE(s, i, length, c, strict) UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict)
# define UTF_NEXT_CHAR_SAFE_STRICT(s, i, length, c) UTF16_NEXT_CHAR_SAFE_STRICT(s, i, length, c)
# define UTF_NEXT_CHAR_SAFE_LENIENT(s, i, length, c) UTF16_NEXT_CHAR_SAFE_LENIENT(s, i, length, c)
# define UTF_APPEND_CHAR_UNSAFE(s, i, c) UTF16_APPEND_CHAR_UNSAFE(s, i, c)
# define UTF_APPEND_CHAR_SAFE(s, i, length, c) UTF16_APPEND_CHAR_SAFE(s, i, length, c)
@ -168,6 +172,8 @@ typedef int32_t UTextOffset;
# define UTF_PREV_CHAR_UNSAFE(s, i, c) UTF16_PREV_CHAR_UNSAFE(s, i, c)
# define UTF_PREV_CHAR_SAFE(s, start, i, c, strict) UTF16_PREV_CHAR_SAFE(s, start, i, c, strict)
# define UTF_PREV_CHAR_SAFE_STRICT(s, start, i, c) UTF16_PREV_CHAR_SAFE_STRICT(s, start, i, c)
# define UTF_PREV_CHAR_SAFE_LENIENT(s, start, i, c) UTF16_PREV_CHAR_SAFE_LENIENT(s, start, i, c)
# define UTF_BACK_1_UNSAFE(s, i) UTF16_BACK_1_UNSAFE(s, i)
# define UTF_BACK_1_SAFE(s, start, i) UTF16_BACK_1_SAFE(s, start, i)
@ -192,30 +198,30 @@ typedef int32_t UTextOffset;
#ifdef UTF_SAFE
# define UTF_GET_CHAR(s, start, i, length, c) UTF_GET_CHAR_SAFE(s, start, i, length, c, FALSE)
# define UTF_GET_CHAR(s, start, i, length, c) UTF_GET_CHAR_SAFE_LENIENT(s, start, i, length, c)
# define UTF_NEXT_CHAR(s, i, length, c) UTF_NEXT_CHAR_SAFE(s, i, length, c, FALSE)
# define UTF_NEXT_CHAR(s, i, length, c) UTF_NEXT_CHAR_SAFE_LENIENT(s, i, length, c)
# define UTF_APPEND_CHAR(s, i, length, c) UTF_APPEND_CHAR_SAFE(s, i, length, c)
# define UTF_FWD_1(s, i, length) UTF_FWD_1_SAFE(s, i, length)
# define UTF_FWD_N(s, i, length, n) UTF_FWD_N_SAFE(s, i, length, n)
# define UTF_SET_CHAR_START(s, start, i) UTF_SET_CHAR_START_SAFE(s, start, i)
# define UTF_PREV_CHAR(s, start, i, c) UTF_PREV_CHAR_SAFE(s, start, i, c, FALSE)
# define UTF_PREV_CHAR(s, start, i, c) UTF_PREV_CHAR_SAFE_LENIENT(s, start, i, c)
# define UTF_BACK_1(s, start, i) UTF_BACK_1_SAFE(s, start, i)
# define UTF_BACK_N(s, start, i, n) UTF_BACK_N_SAFE(s, start, i, n)
# define UTF_SET_CHAR_LIMIT(s, start, i, length) UTF_SET_CHAR_LIMIT_SAFE(s, start, i, length)
#elif defined(UTF_STRICT)
# define UTF_GET_CHAR(s, start, i, length, c) UTF_GET_CHAR_SAFE(s, start, i, length, c, TRUE)
# define UTF_GET_CHAR(s, start, i, length, c) UTF_GET_CHAR_SAFE_STRICT(s, start, i, length, c)
# define UTF_NEXT_CHAR(s, i, length, c) UTF_NEXT_CHAR_SAFE(s, i, length, c, TRUE)
# define UTF_NEXT_CHAR(s, i, length, c) UTF_NEXT_CHAR_SAFE_STRICT(s, i, length, c)
# define UTF_APPEND_CHAR(s, i, length, c) UTF_APPEND_CHAR_SAFE(s, i, length, c)
# define UTF_FWD_1(s, i, length) UTF_FWD_1_SAFE(s, i, length)
# define UTF_FWD_N(s, i, length, n) UTF_FWD_N_SAFE(s, i, length, n)
# define UTF_SET_CHAR_START(s, start, i) UTF_SET_CHAR_START_SAFE(s, start, i)
# define UTF_PREV_CHAR(s, start, i, c) UTF_PREV_CHAR_SAFE(s, start, i, c, TRUE)
# define UTF_PREV_CHAR(s, start, i, c) UTF_PREV_CHAR_SAFE_STRICT(s, start, i, c)
# define UTF_BACK_1(s, start, i) UTF_BACK_1_SAFE(s, start, i)
# define UTF_BACK_N(s, start, i, n) UTF_BACK_N_SAFE(s, start, i, n)
# define UTF_SET_CHAR_LIMIT(s, start, i, length) UTF_SET_CHAR_LIMIT_SAFE(s, start, i, length)

View File

@ -72,7 +72,8 @@
} \
}
#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
#define _UTF16_GET_CHAR_SAFE_1(s, start, i, length, c) \
{ \
(c)=(s)[i]; \
if(UTF_IS_SURROGATE(c)) { \
uint16_t __c2; \
@ -80,23 +81,54 @@
if((i)+1<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)+1])) { \
(c)=UTF16_GET_PAIR_VALUE((c), __c2); \
/* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() */ \
} else if(strict) {\
/* unmatched first surrogate */ \
(c)=UTF_ERROR_VALUE; \
} \
}
#define _UTF16_GET_CHAR_SAFE_2(s, start, i, length, c) \
} else { \
if((i)>(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \
(c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \
/* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() */ \
} else if(strict) {\
/* unmatched second surrogate */ \
}
#define _UTF16_SAFE_ERROR(c) \
{ \
/* unmatched first surrogate */ \
(c)=UTF_ERROR_VALUE; \
} \
}
#define _UTF16_GET_CHAR_SAFE_END \
} \
/* else strict: (c)==0xfffe is caught by UTF_IS_ERROR() */ \
} \
}
#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) \
_UTF16_GET_CHAR_SAFE_1(s, start, i, length, c) \
else if(strict) \
_UTF16_SAFE_ERROR(c) \
_UTF16_GET_CHAR_SAFE_2(s, start, i, length, c) \
else if(strict) \
_UTF16_SAFE_ERROR(c) \
_UTF16_GET_CHAR_SAFE_END
/*
* The following two macros will get around compilers complaining
* about constant conditional statements.
*/
#define UTF16_GET_CHAR_SAFE_STRICT(s, start, i, length, c) \
_UTF16_GET_CHAR_SAFE_1(s, start, i, length, c) \
else \
_UTF16_SAFE_ERROR(c) \
_UTF16_GET_CHAR_SAFE_2(s, start, i, length, c) \
else \
_UTF16_SAFE_ERROR(c) \
_UTF16_GET_CHAR_SAFE_END
#define UTF16_GET_CHAR_SAFE_LENIENT(s, start, i, length, c) \
_UTF16_GET_CHAR_SAFE_1(s, start, i, length, c) \
_UTF16_GET_CHAR_SAFE_2(s, start, i, length, c) \
_UTF16_GET_CHAR_SAFE_END
/* definitions with forward iteration --------------------------------------- */
/*
@ -159,7 +191,7 @@
/* safe versions with error-checking and optional regularity-checking */
#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
#define _UTF16_NEXT_CHAR_SAFE_1(s, i, length, c) \
(c)=(s)[(i)++]; \
if(UTF_IS_FIRST_SURROGATE(c)) { \
uint16_t __c2; \
@ -167,14 +199,33 @@
++(i); \
(c)=UTF16_GET_PAIR_VALUE((c), __c2); \
/* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() */ \
} else if(strict) {\
/* unmatched first surrogate */ \
(c)=UTF_ERROR_VALUE; \
} \
} else if(strict && UTF_IS_SECOND_SURROGATE(c)) { \
/* unmatched second surrogate */ \
(c)=UTF_ERROR_VALUE; \
/* else strict: (c)==0xfffe is caught by UTF_IS_ERROR() */ \
}
#define _UTF16_NEXT_CHAR_SAFE_END \
} \
}
#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) \
{ \
_UTF16_NEXT_CHAR_SAFE_1(s, i, length, c) \
else if(strict) \
_UTF16_SAFE_ERROR(c) \
} else if(strict && UTF_IS_SECOND_SURROGATE(c)) \
_UTF16_SAFE_ERROR(c) \
}
#define UTF16_NEXT_CHAR_SAFE_STRICT(s, i, length, c) \
{ \
_UTF16_NEXT_CHAR_SAFE_1(s, i, length, c) \
else \
_UTF16_SAFE_ERROR(c) \
} else if(UTF_IS_SECOND_SURROGATE(c)) \
_UTF16_SAFE_ERROR(c) \
}
#define UTF16_NEXT_CHAR_SAFE_LENIENT(s, i, length, c) \
{ \
_UTF16_NEXT_CHAR_SAFE_1(s, i, length, c) \
} \
}
@ -267,7 +318,7 @@
/* safe versions with error-checking and optional regularity-checking */
#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) { \
#define _UTF16_PREV_CHAR_SAFE_1(s, start, i, c) \
(c)=(s)[--(i)]; \
if(UTF_IS_SECOND_SURROGATE(c)) { \
uint16_t __c2; \
@ -275,14 +326,30 @@
--(i); \
(c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \
/* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() */ \
} else if(strict) {\
/* unmatched second surrogate */ \
(c)=UTF_ERROR_VALUE; \
} \
} else if(strict && UTF_IS_FIRST_SURROGATE(c)) { \
/* unmatched first surrogate */ \
(c)=UTF_ERROR_VALUE; \
/* else strict: (c)==0xfffe is caught by UTF_IS_ERROR() */ \
}
#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) \
{ \
_UTF16_PREV_CHAR_SAFE_1(s, start, i, c) \
else if(strict) \
_UTF16_SAFE_ERROR(c) \
} else if(strict && UTF_IS_FIRST_SURROGATE(c)) \
_UTF16_SAFE_ERROR(c) \
}
#define UTF16_PREV_CHAR_SAFE_STRICT(s, start, i, c) \
{ \
_UTF16_PREV_CHAR_SAFE_1(s, start, i, c) \
else \
_UTF16_SAFE_ERROR(c) \
} else if (UTF_IS_FIRST_SURROGATE(c)) \
_UTF16_SAFE_ERROR(c) \
}
#define UTF16_PREV_CHAR_SAFE_LENIENT(s, start, i, c) \
{ \
_UTF16_PREV_CHAR_SAFE_1(s, start, i, c) \
} \
}

View File

@ -502,13 +502,13 @@ UnicodeString::doCompare( UTextOffset start,
if(minLength > 0) {
int32_t result;
if(U_IS_BIG_ENDIAN) {
# if U_IS_BIG_ENDIAN
// big-endian: byte comparison works
result = uprv_memcmp(chars + start, srcChars + srcStart, minLength * sizeof(UChar));
if(result != 0) {
return (int8_t)(result >> 15 | 1);
}
} else {
# else
// little-endian: compare UChar units
chars += start;
srcChars += srcStart;
@ -520,7 +520,7 @@ UnicodeString::doCompare( UTextOffset start,
++chars;
++srcChars;
} while(--minLength > 0);
}
# endif
}
return lengthResult;
}