From 30c6033e8ce9c776549927cbff1e3e66a30f04b9 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Tue, 12 Mar 2019 09:27:11 +0800 Subject: [PATCH] cleanup --- include/gdi.h | 9 +++++---- src/font/unicode-bidi.c | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index aea99b64..c15f452d 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -7977,7 +7977,7 @@ MG_EXPORT void GUIAPI UStrGetJoiningTypes(const Uchar32 *ucs, BidiJoiningType *joing_types, int len); /** - * \fn int GUIAPI UBidiGetParagraphDir(const BidiType *bidi_types, int len) + * \fn BidiType GUIAPI UBidiGetParagraphDir(const BidiType *bidi_types, int len) * \brief get base paragraph direction * * This function finds the base direction of a single paragraph, @@ -7996,13 +7996,13 @@ MG_EXPORT void GUIAPI UStrGetJoiningTypes(const Uchar32 *ucs, * * \param bidi_types the pointer to the BidiType array as returned by * UStrGetBidiTypes(). - * \param len The length of bidi_types + * \param len The length of bidi types array. * * \return Base pargraph direction. No weak paragraph direction is returned, * only BIDI_PGDIR_LTR, BIDI_PGDIR_RTL, or BIDI_PGDIR_ON. * */ -MG_EXPORT int GUIAPI UBidiGetParagraphDir(const BidiType *bidi_types, int len); +MG_EXPORT BidiType GUIAPI UBidiGetParagraphDir(const BidiType *bidi_types, int len); /** * \fn BidiLevel GUIAPI UBidiGetParagraphEmbeddingLevels( @@ -8032,7 +8032,8 @@ MG_EXPORT int GUIAPI UBidiGetParagraphDir(const BidiType *bidi_types, int len); * Explicit right to left. * - BIDI_PGDIR_ON\n * The base direction will be resolved by applying the - * rules P2 and P3, and returned via this parameter. + * rules P2 and P3, and returned via this parameter (one + * of BIDI_PGDIR_LTR or BIDI_PGDIR_RTL) . * \param embedding_levels The pointer to a buffer which will restore * the embedding levels. * diff --git a/src/font/unicode-bidi.c b/src/font/unicode-bidi.c index f103cfa8..3c3c82fa 100644 --- a/src/font/unicode-bidi.c +++ b/src/font/unicode-bidi.c @@ -149,7 +149,7 @@ static void free_run_list(BidiRun *run_list) static BidiRun* run_list_encode_bidi_types (const BidiType *bidi_types, - const BidiBracketType *bracket_types, const int len) + const BidiBracketType *bracket_types, int len) { BidiRun *list, *last; register BidiRun *run = NULL; @@ -524,7 +524,7 @@ static void print_resolved_types(const BidiRun *pp) _DBG_PRINTF ("\n"); } -static void print_bidi_string(const BidiType *bidi_types, const int len) +static void print_bidi_string(const BidiType *bidi_types, int len) { int i; @@ -644,13 +644,14 @@ static void print_pairing_nodes(BidiPairingNode *nodes) #define BIDI_EMBEDDING_DIRECTION(link) \ BIDI_LEVEL_TO_DIR(RL_LEVEL(link)) -int UBidiGetParagraphDir(const BidiType *bidi_types, const int len) +BidiType UBidiGetParagraphDir(const BidiType *bidi_types, int len) { register int i; - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) { if (BIDI_IS_LETTER(bidi_types[i])) return BIDI_IS_RTL(bidi_types[i]) ? BIDI_PGDIR_RTL : BIDI_PGDIR_LTR; + } return BIDI_PGDIR_ON; } @@ -739,7 +740,7 @@ static void free_pairing_nodes(BidiPairingNode *nodes) } BidiLevel UBidiGetParagraphEmbeddingLevels(const BidiType *bidi_types, - const BidiBracketType *bracket_types, const int len, + const BidiBracketType *bracket_types, int len, BidiType *paragraph_dir, BidiLevel *embedding_levels) { BidiLevel base_level_per_iso_level[BIDI_MAX_EXPLICIT_LEVEL]; @@ -1610,14 +1611,15 @@ BidiLevel UBidiReorderLine(Uint32 flags, goto out; } - _DBG_PRINTF ("%s: reset the embedding levels, 4. whitespace at the end of line\n", - __FUNCTION__); - { register int i; /* L1. Reset the embedding levels of some chars: 4. any sequence of white space characters at the end of the line. */ + _DBG_PRINTF ("%s: L1. Reset the embedding levels of some chars:" + "4. any sequence of white space characters at the end of the line.\n", + __FUNCTION__); + for (i = off + len - 1; i >= off && BIDI_IS_EXPLICIT_OR_BN_OR_WS (bidi_types[i]); i--) embedding_levels[i] = BIDI_DIR_TO_LEVEL (paragraph_dir);