From 33418441e8d6d5b4a9a0c79347f840179006dd18 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Thu, 15 Feb 2001 02:36:15 +0000 Subject: [PATCH] ICU-471 add shaping options & error code X-SVN-Rev: 3629 --- icu4c/source/common/putil.c | 3 ++- icu4c/source/common/unicode/ushape.h | 14 ++++++++++---- icu4c/source/common/unicode/utypes.h | 1 + icu4c/source/common/ushape.c | 2 -- icu4c/source/test/cintltst/cbiditst.c | 18 ------------------ 5 files changed, 13 insertions(+), 25 deletions(-) diff --git a/icu4c/source/common/putil.c b/icu4c/source/common/putil.c index 5383f8386e..6fab3afb25 100644 --- a/icu4c/source/common/putil.c +++ b/icu4c/source/common/putil.c @@ -1917,7 +1917,8 @@ _uErrorName[U_ERROR_LIMIT]={ "U_UNSUPPORTED_ERROR", "U_RESOURCE_TYPE_MISMATCH", "U_ILLEGAL_ESCAPE_SEQUENCE", - "U_UNSUPPORTED_ESCAPE_SEQUENCE" + "U_UNSUPPORTED_ESCAPE_SEQUENCE", + "U_NO_SPACE_AVAILABLE" }; U_CAPI const char * U_EXPORT2 diff --git a/icu4c/source/common/unicode/ushape.h b/icu4c/source/common/unicode/ushape.h index 4fd9ba8d8a..aab9fedc78 100644 --- a/icu4c/source/common/unicode/ushape.h +++ b/icu4c/source/common/unicode/ushape.h @@ -123,8 +123,11 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, */ #define U_SHAPE_LENGTH_FIXED_SPACES_AT_END 2 -/** Not a valid option value. */ -#define U_SHAPE_LENGTH_RESERVED 3 +/** + * Memory option: the result must have the same length as the source. + * If more room is necessary, then try to consume spaces at the beginning of the text. + */ +#define U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING 3 /** Bit mask for memory options. */ #define U_SHAPE_LENGTH_MASK 3 @@ -152,8 +155,11 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, /** Letter shaping option: replace "shaped" letter characters by abstract ones. */ #define U_SHAPE_LETTERS_UNSHAPE 0x10 -/** Not a valid option value. */ -#define U_SHAPE_LETTERS_RESERVED 0x18 +/** + * Letter shaping option: replace abstract letter characters by "shaped" ones, + * but do not process Tashkeel characters. + */ +#define U_SHAPE_LETTERS_EXCEPT_TASHKEEL 0x18 /** Bit mask for letter shaping options. */ #define U_SHAPE_LETTERS_MASK 0x18 diff --git a/icu4c/source/common/unicode/utypes.h b/icu4c/source/common/unicode/utypes.h index 53f462b965..94920506a2 100644 --- a/icu4c/source/common/unicode/utypes.h +++ b/icu4c/source/common/unicode/utypes.h @@ -347,6 +347,7 @@ enum UErrorCode { U_RESOURCE_TYPE_MISMATCH = 17, /**< an operation is requested over a resource that does not support it */ U_ILLEGAL_ESCAPE_SEQUENCE = 18, /**< ISO-2022 illlegal escape sequence */ U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, /**< ISO-2022 unsupported escape sequence */ + U_NO_SPACE_AVAILABLE = 20, /**< No space available for in-buffer expansion for Arabic shaping */ U_ERROR_LIMIT /**< This must always be the last value to indicate the limit for UErrorCode (last error code +1) */ }; diff --git a/icu4c/source/common/ushape.c b/icu4c/source/common/ushape.c index c9de0ec8fd..59ace47f3e 100644 --- a/icu4c/source/common/ushape.c +++ b/icu4c/source/common/ushape.c @@ -105,8 +105,6 @@ u_shapeArabic(const UChar *source, int32_t sourceLength, if( source==NULL || sourceLength<-1 || (dest==NULL && destSize!=0) || destSize<0 || options>=U_SHAPE_DIGIT_TYPE_RESERVED || - (options&U_SHAPE_LENGTH_MASK)==U_SHAPE_LENGTH_RESERVED || - (options&U_SHAPE_LETTERS_MASK)==U_SHAPE_LETTERS_RESERVED || (options&U_SHAPE_DIGITS_MASK)>=U_SHAPE_DIGITS_RESERVED ) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; diff --git a/icu4c/source/test/cintltst/cbiditst.c b/icu4c/source/test/cintltst/cbiditst.c index 6824079190..8d71710bfd 100644 --- a/icu4c/source/test/cintltst/cbiditst.c +++ b/icu4c/source/test/cintltst/cbiditst.c @@ -729,24 +729,6 @@ doArabicShapingTest() { log_err("failure in u_shapeArabic(destSize=-1), returned %s instead of U_ILLEGAL_ARGUMENT_ERROR\n", u_errorName(errorCode)); } - errorCode=U_ZERO_ERROR; - length=u_shapeArabic(source, LENGTHOF(source), - dest, LENGTHOF(dest), - U_SHAPE_LENGTH_RESERVED|U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN, - &errorCode); - if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { - log_err("failure in u_shapeArabic(U_SHAPE_LENGTH_RESERVED), returned %s instead of U_ILLEGAL_ARGUMENT_ERROR\n", u_errorName(errorCode)); - } - - errorCode=U_ZERO_ERROR; - length=u_shapeArabic(source, LENGTHOF(source), - dest, LENGTHOF(dest), - U_SHAPE_LETTERS_RESERVED|U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN, - &errorCode); - if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { - log_err("failure in u_shapeArabic(U_SHAPE_LETTERS_RESERVED), returned %s instead of U_ILLEGAL_ARGUMENT_ERROR\n", u_errorName(errorCode)); - } - errorCode=U_ZERO_ERROR; length=u_shapeArabic(source, LENGTHOF(source), dest, LENGTHOF(dest),