diff options
author | behdad <behdad> | 2001-03-07 16:15:13 +0000 |
---|---|---|
committer | behdad <behdad> | 2001-03-07 16:15:13 +0000 |
commit | c0ec5c311f024b945e6c8143273164524781983d (patch) | |
tree | 0e352828c2a780e4eba8ad10e3e0d7d19cdbfa52 | |
parent | 0c6d0ab32f45f785f44f6cb0ea90ff53f85cac7a (diff) |
Some dead codes removed, some parts rewritten, bitfields used for char
types.
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | README | 2 | ||||
-rwxr-xr-x | conformance/dotest | 4 | ||||
-rwxr-xr-x | conformance/findbad | 6 | ||||
-rwxr-xr-x | conformance/findbads | 4 | ||||
-rwxr-xr-x | conformance/test | 2 | ||||
-rw-r--r-- | fribidi.c | 297 | ||||
-rw-r--r-- | fribidi_benchmark.c | 2 | ||||
-rw-r--r-- | fribidi_get_type.c | 8 | ||||
-rw-r--r-- | fribidi_main.c | 10 | ||||
-rw-r--r-- | fribidi_tables.i | 74 | ||||
-rw-r--r-- | fribidi_types.h | 221 | ||||
-rw-r--r-- | test_fribidi.c | 6 | ||||
-rwxr-xr-x | unidata/CreateGetType.pl | 4 |
14 files changed, 365 insertions, 293 deletions
@@ -1,3 +1,19 @@ +2001-03-07 Behdad Esfahbod <behdad@bamdad.org> + + * fribidi.c: Removed dead codes, many parts rewritten more efficient, + including Resolving Neutrals, Resolving Implicit Levels and .... + + * fribidi_types.h: Almost redefined, to use bitfields for char types, + and many macros defined for efficient querying about char types. + some unused char types removed, also char types L, R, N converted + to LTR, RTL and ON everywhere. + + * CreateGetType.pl: Changed to define tables as arrays of + FriBidiCharType instead of guchar. + + * conformance/: Updated some scripts for automatic testing with + reference implementation. + 2001-02-19 Behdad Esfahbod <behdad@bamdad.org> * fribidi.c: Added support for all explicit marks (embeddings and @@ -40,6 +56,8 @@ 2000-11-12 Dov Grobgeld <dov@imagic.weizmann.ac.il> + * Released fribidi-0.1.15. + * fribidi.c: [OZ] Applied Owen Taylor's patch from 2000-07-19 to fribidi.c. The patch affects pp->prev rules for the last element in cases W3 and W7. @@ -83,7 +83,7 @@ where str is the Unicode input string len is the length of the unicode string pbase_dir is the input and output base direction. If - base == FRIBIDI_TYPE_N then fribidi_log2vis + base == FRIBIDI_TYPE_ON then fribidi_log2vis calculates the base direction on its own according to the BiDi algorithm. visual_str The reordered output unicode string. diff --git a/conformance/dotest b/conformance/dotest index 6524257..76b8cbb 100755 --- a/conformance/dotest +++ b/conformance/dotest @@ -1,7 +1,9 @@ #!/bin/sh # Generate and test a single test data. -path=`dirname $0` +path=`dirname $(which $0)` + +trap 'rm -f $path/test.{in,out,ref} &> /dev/null ; exit' INT if ! test -f "$path/test_gen_rand"; then gcc -o $path/test_gen_rand $path/test_gen_rand.c diff --git a/conformance/findbad b/conformance/findbad index cda7fd4..4848a53 100755 --- a/conformance/findbad +++ b/conformance/findbad @@ -1,8 +1,10 @@ #!/bin/sh # Find a single nonconforming test. -# First command line parameter is the lenght of test in bytes, default is 10. +# First command line parameter is the length of test in bytes, default is 10. -path=`dirname $0` +path=`dirname $(which $0)` + +trap 'echo; rm -f $path/test.{in,out,ref} &> /dev/null ; exit' INT while ! test "`$path/dotest $1`"; do echo -n .; done shift diff --git a/conformance/findbads b/conformance/findbads index f933318..b30fa61 100755 --- a/conformance/findbads +++ b/conformance/findbads @@ -2,7 +2,9 @@ # Generate and test single tests, and archive the nonconforming ones. # First command line parameter is the lenght of test in bytes, default is 10. -path=`dirname $0` +path=`dirname $(which $0)` + +trap 'rm -f $path/test.{in,out,ref} &> /dev/null ; exit' INT while true; do $path/findbad $@ diff --git a/conformance/test b/conformance/test index 0bb14ad..6a1d194 100755 --- a/conformance/test +++ b/conformance/test @@ -3,7 +3,7 @@ # use -debug switch to see the debug info into stderr. # use -clean to remove explicit marks before doing diff. -path=`dirname $0` +path=`dirname $(which $0)` if ! test -f "$path/reference/bidiref"; then gcc -o $path/reference/bidiref $path/reference/bidiref.cpp @@ -17,6 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#define DEBUG #include <glib.h> #include "fribidi.h" #ifdef DEBUG @@ -394,17 +395,6 @@ static void compact_list(TypeLink *list) } } -/* Define a rule macro that only assigns the center type */ -#define TYPE_RULE_C(old_prev, old_this, old_next, \ - new_this) \ - if (prev_type == FRIBIDI_TYPE_ ## old_prev && \ - this_type == FRIBIDI_TYPE_ ## old_this && \ - next_type == FRIBIDI_TYPE_ ## old_next) \ - { \ - RL_TYPE(pp) = FRIBIDI_TYPE_ ## new_this; \ - continue; \ - } - /*======================================================= // define macros for push and pop the status in to / out of the stack //-------------------------------------------------------*/ @@ -433,7 +423,7 @@ static void compact_list(TypeLink *list) b. If the new level would not be valid, then this code is invalid. Don't change the current level or override status. */ -#define PUSH_STATUS(new_override) \ +#define PUSH_STATUS \ { \ if (new_level <= MAX_LEVEL) \ { \ @@ -475,29 +465,26 @@ static void compact_list(TypeLink *list) // Levels, so define macros, to support them, with as less change as needed. //--------------------------------------------------------------------------*/ -/* Return the direction of the level number, ie. even is FRIBIDI_TYPE_L and - odd is FRIBIDI_TYPE_R. -*/ -#define LEVEL_DIR(lev) \ - (lev & 1 ? FRIBIDI_TYPE_R : FRIBIDI_TYPE_L) - /* Return the type of previous char or the sor, if already at the start of - a run level. -*/ + a run level. */ #define PREV_TYPE_OR_SOR \ - (RL_LEVEL(ppprev)==RL_LEVEL(pp) ? RL_TYPE(ppprev) : LEVEL_DIR( \ + (RL_LEVEL(ppprev)==RL_LEVEL(pp) ? RL_TYPE(ppprev) : LEVEL_TO_DIR( \ (RL_LEVEL(ppprev)>RL_LEVEL(pp) ? RL_LEVEL(ppprev) : RL_LEVEL(pp)) \ )) /* Return the type of next char or the eor, if already at the end of - a run level. -*/ + a run level. */ #define NEXT_TYPE_OR_EOR \ - (!ppnext ? LEVEL_DIR(RL_LEVEL(pp)) : \ - (RL_LEVEL(ppnext)==RL_LEVEL(pp) ? RL_TYPE(ppnext) : LEVEL_DIR( \ + (!ppnext ? LEVEL_TO_DIR(RL_LEVEL(pp)) : \ + (RL_LEVEL(ppnext)==RL_LEVEL(pp) ? RL_TYPE(ppnext) : LEVEL_TO_DIR( \ (RL_LEVEL(ppnext)>RL_LEVEL(pp) ? RL_LEVEL(ppnext) : RL_LEVEL(pp)) \ ))) + +/* Return the embedding direction of a link. */ +#define EMBEDDING_DIRECTION(list) \ + LEVEL_TO_DIR(RL_LEVEL(list)) + #ifdef DEBUG /*====================================================================== // For debugging, define some functions for printing the types and the @@ -597,44 +584,28 @@ fribidi_analyse_string(/* input */ init_list(&explicits_list, &explicits_list_end); /* Find the base level */ - if (*pbase_dir == FRIBIDI_TYPE_L) - base_level = 0; - else if (*pbase_dir == FRIBIDI_TYPE_R) - base_level = 1; - + if (IS_STRONG(*pbase_dir)) + base_level = DIR_TO_LEVEL(*pbase_dir); /* P2. Search for first strong character and use its direction as base direction */ else { base_level = 0; /* Default */ - base_dir = FRIBIDI_TYPE_N; + base_dir = FRIBIDI_TYPE_ON; for (pp = type_rl_list; pp; pp = pp->next) - { - if (RL_TYPE(pp) == FRIBIDI_TYPE_R || - RL_TYPE(pp) == FRIBIDI_TYPE_AL) - { - base_level = 1; - base_dir = FRIBIDI_TYPE_R; - break; - } - else if (RL_TYPE(pp) == FRIBIDI_TYPE_L) - { - base_level = 0; - base_dir = FRIBIDI_TYPE_L; - break; - } - } + if (IS_LETTER(RL_TYPE(pp))) { + base_level = DIR_TO_LEVEL(RL_TYPE(pp)); + base_dir = LEVEL_TO_DIR(base_level); + break; + } /* If no strong base_dir was found, resort to the weak direction * that was passed on input. */ - if (base_dir == FRIBIDI_TYPE_N) - if (*pbase_dir == FRIBIDI_TYPE_WR) - base_level = 1; - else - base_level = 0; + if (IS_NEUTRAL(base_dir)) + base_level = DIR_TO_LEVEL(*pbase_dir); } - base_dir = LEVEL_DIR(base_level); + base_dir = LEVEL_TO_DIR(base_level); /* Explicit Levels and Directions */ DBG("Explicit Levels and Directions.\n"); @@ -645,8 +616,8 @@ fribidi_analyse_string(/* input */ Only embedding levels from 0 to 61 are valid in this phase. */ gint level = base_level; - gint override = FRIBIDI_TYPE_N; - gint new_level; + gint override = FRIBIDI_TYPE_ON; + gint new_level, new_override; /* stack */ gint stack_size = 0; gint over_pushed = 0; @@ -659,37 +630,33 @@ fribidi_analyse_string(/* input */ for (pp = type_rl_list->next; pp->next; pp = pp->next) { gint this_type = RL_TYPE(pp); - /* 1. Explicit Embeddings */ - /* X2. With each RLE, compute the least greater odd embedding level. */ - if (this_type == FRIBIDI_TYPE_RLE) - for (i = 0; i < RL_LEN(pp); i++) - { - new_level = (level + 1) | 1; - PUSH_STATUS(FRIBIDI_TYPE_N); - } - /* X3. With each LRE, compute the least greater even embedding level. */ - else if (this_type == FRIBIDI_TYPE_LRE) - for (i = 0; i < RL_LEN(pp); i++) - { - new_level = (level + 2) & ~1; - PUSH_STATUS(FRIBIDI_TYPE_N); - } - /* 2. Explicit Overrides */ - /* X4. With each RLO, compute the least greater odd embedding level. */ - if (this_type == FRIBIDI_TYPE_RLO) - for (i = 0; i < RL_LEN(pp); i++) - { - new_level = (level + 1) | 1; - PUSH_STATUS(FRIBIDI_TYPE_R); - } - /* X5. With each LRO, compute the least greater even embedding level. */ - else if (this_type == FRIBIDI_TYPE_LRO) - for (i = 0; i < RL_LEN(pp); i++) - { - new_level = (level + 2) & ~1; - PUSH_STATUS(FRIBIDI_TYPE_L); - } - + if (IS_EXPLICIT_OR_BN(this_type)) { + if (IS_STRONG(this_type)) { /* LRE, RLE, LRO, RLO */ + /* 1. Explicit Embeddings */ + /* X2. With each RLE, compute the least greater odd embedding level. */ + /* X3. With each LRE, compute the least greater even embedding level. */ + /* 2. Explicit Overrides */ + /* X4. With each RLO, compute the least greater odd embedding level. */ + /* X5. With each LRO, compute the least greater even embedding level. */ + new_level = ((level + DIR_TO_LEVEL(this_type) + 2) & ~1) + - DIR_TO_LEVEL(this_type); + new_override = EXPLICIT_TO_OVERRIDE_DIR(this_type); + for (i = 0; i < RL_LEN(pp); i++) + PUSH_STATUS; + } else if (this_type == FRIBIDI_TYPE_PDF) { + /* 3. Terminating Embeddings and overrides */ + /* X7. With each PDF, determine the matching embedding or + override code. */ + for (i = 0; i < RL_LEN(pp); i++) + POP_STATUS; + } + /* X9. Remove all RLE, LRE, RLO, LRO, PDF, and BN codes. */ + /* Remove element and add it to explicits_list */ + temp_link->next = pp->next; + pp->level = FRIBIDI_LEVEL_REMOVED; + move_element_before(pp, explicits_list_end); + pp = temp_link; + } /* X6. For all typed besides RLE, LRE, RLO, LRO, and PDF: a. Set the level of the current character to the current embedding level. @@ -697,47 +664,21 @@ fribidi_analyse_string(/* input */ reset the current character type to the directional override status. */ - else if (this_type != FRIBIDI_TYPE_PDF) - { - RL_LEVEL(pp) = level; - if (override != FRIBIDI_TYPE_N) - RL_TYPE(pp) = override; - } - /* 3. Terminating Embeddings and overrides */ - /* X7. With each PDF, determine the matching embedding or - ovveride code. - */ - else /* now: this_type == FRIBIDI_TYPE_PDF */ - for (i = 0; i < RL_LEN(pp); i++) - POP_STATUS; + else { + RL_LEVEL(pp) = level; + if (!IS_NEUTRAL(override)) + RL_TYPE(pp) = override; + } /* X8. All explicit directional embeddings and overrides are completely terminated at the end of each paragraph. Paragraph - separators are not included in the embedding. - */ - /* - This function is running on a single paragraph, so we can do - X8 after all the input is processed. - */ - /* X9. Remove all RLE, LRE, RLO, LRO, PDF, and BN codes. - */ - if (this_type == FRIBIDI_TYPE_RLE || - this_type == FRIBIDI_TYPE_LRE || - this_type == FRIBIDI_TYPE_RLO || - this_type == FRIBIDI_TYPE_LRO || - this_type == FRIBIDI_TYPE_PDF || - this_type == FRIBIDI_TYPE_BN) - { - /* Remove element and add it to explicits_list */ - temp_link->next = pp->next; - pp->level = FRIBIDI_LEVEL_REMOVED; - move_element_before(pp, explicits_list_end); - pp = temp_link; - } + separators are not included in the embedding. */ + /* This function is running on a single paragraph, so we can do + X8 after all the input is processed. */ } /* Implementing X8. It has no effect on a single paragraph! */ level = base_level; - override = FRIBIDI_TYPE_N; + override = FRIBIDI_TYPE_ON; status_stack -= stack_size; stack_size = 0; @@ -795,11 +736,9 @@ fribidi_analyse_string(/* input */ because the types may change, it affects rule 3. */ if (RL_LEVEL(ppprev) != RL_LEVEL(pp)) - last_strong = prev_type/*sor*/; + last_strong = prev_type/*==sor*/; else - if (prev_type == FRIBIDI_TYPE_AL || - prev_type == FRIBIDI_TYPE_R || - prev_type == FRIBIDI_TYPE_L) + if (IS_STRONG(prev_type)) last_strong = prev_type; /* W1. NSM @@ -818,7 +757,7 @@ fribidi_analyse_string(/* input */ /* W3: Change ALs to R. */ if (this_type == FRIBIDI_TYPE_AL) - RL_TYPE(pp) = FRIBIDI_TYPE_R; + RL_TYPE(pp) = FRIBIDI_TYPE_RTL; RL_TYPE(ppprev) = prev_type_new; @@ -841,12 +780,10 @@ fribidi_analyse_string(/* input */ A single common separator between two numbers of the same type changes to that type. */ - if (RL_LEN(pp) == 1) - { - TYPE_RULE_C(EN,ES,EN, EN); - TYPE_RULE_C(EN,CS,EN, EN); - TYPE_RULE_C(AN,CS,AN, AN); - } + if (RL_LEN(pp) == 1 && IS_ES_OR_CS(this_type) && + IS_NUMBER(prev_type) && prev_type == next_type && + (prev_type == FRIBIDI_TYPE_EN || this_type == FRIBIDI_TYPE_CS)) + RL_TYPE(pp) = prev_type; ppprev = pp; pp = ppnext; @@ -868,11 +805,9 @@ fribidi_analyse_string(/* input */ because the types may change, it affects rule 3. */ if (RL_LEVEL(ppprev) != RL_LEVEL(pp)) - last_strong = prev_type/*sor*/; + last_strong = prev_type/*==sor*/; else - if (prev_type == FRIBIDI_TYPE_AL || - prev_type == FRIBIDI_TYPE_R || - prev_type == FRIBIDI_TYPE_L) + if (IS_STRONG(prev_type)) last_strong = prev_type; /* W5. A sequence of European terminators adjacent to European numbers changes to All European numbers. @@ -886,15 +821,13 @@ fribidi_analyse_string(/* input */ /* W6. Otherwise change separators and terminators to other neutral. */ - if (this_type == FRIBIDI_TYPE_ET || - this_type == FRIBIDI_TYPE_CS || - this_type == FRIBIDI_TYPE_ES) + if (IS_NUMBER_SEPARATOR_OR_TERMINATOR(this_type)) RL_TYPE(pp) = FRIBIDI_TYPE_ON; /* W7. Change european numbers to L. */ - if (this_type == FRIBIDI_TYPE_EN && last_strong == FRIBIDI_TYPE_L) - RL_TYPE(pp) = FRIBIDI_TYPE_L; + if (this_type == FRIBIDI_TYPE_EN && last_strong == FRIBIDI_TYPE_LTR) + RL_TYPE(pp) = FRIBIDI_TYPE_LTR; ppprev = pp; pp = ppnext; @@ -918,62 +851,35 @@ fribidi_analyse_string(/* input */ TypeLink *ppprev, *ppnext/* prev and next non neutral */; gint prev_type, next_type; - /* We can now collapse all separators and other neutral types to - plain neutrals. */ - for (pp = type_rl_list->next; pp->next; pp = pp->next) - { - gint this_type = RL_TYPE(pp); - - if (this_type == FRIBIDI_TYPE_WS || - this_type == FRIBIDI_TYPE_ON || - this_type == FRIBIDI_TYPE_ES || - this_type == FRIBIDI_TYPE_ET || - this_type == FRIBIDI_TYPE_BN || - this_type == FRIBIDI_TYPE_BS || - this_type == FRIBIDI_TYPE_SS || - this_type == FRIBIDI_TYPE_CS) - RL_TYPE(pp) = FRIBIDI_TYPE_N; - } - - compact_list(type_rl_list); - /* N1. and N2. For each neutral, resolve it. */ for (ppnext=pp=(ppprev=type_rl_list)->next; pp->next; pp=pp->next) { - gint this_type = RL_TYPE(pp); /* "European and arabic numbers are treated as though they were R" */ - if (this_type == FRIBIDI_TYPE_EN || this_type == FRIBIDI_TYPE_AN) - this_type = FRIBIDI_TYPE_R; + /* CHANGE_NUMBER_TO_RTL does this. */ + gint this_type = CHANGE_NUMBER_TO_RTL(RL_TYPE(pp)); /* Find prev_type from ppprev. */ - prev_type = PREV_TYPE_OR_SOR; - /* "European and arabic numbers are treated as though they were R" */ - if (prev_type == FRIBIDI_TYPE_EN || prev_type == FRIBIDI_TYPE_AN) - prev_type = FRIBIDI_TYPE_R; + prev_type = CHANGE_NUMBER_TO_RTL(PREV_TYPE_OR_SOR); /* Update ppnext if needed. */ if (RL_LEVEL(pp) == RL_LEVEL(ppnext)) { /* Find next non-neutral. */ for (ppnext = pp->next; - RL_TYPE(ppnext) == FRIBIDI_TYPE_N && + IS_NEUTRAL(RL_TYPE(ppnext)) && RL_LEVEL(ppnext) == RL_LEVEL(ppnext->prev); ppnext = ppnext->next) /* Nothing! */; - next_type = NEXT_TYPE_OR_EOR; - - /* "European and arabic numbers are treated as though they were R" */ - if (next_type == FRIBIDI_TYPE_EN || next_type == FRIBIDI_TYPE_AN) - next_type = FRIBIDI_TYPE_R; + next_type = CHANGE_NUMBER_TO_RTL(NEXT_TYPE_OR_EOR); } - if (this_type == FRIBIDI_TYPE_N) + if (IS_NEUTRAL(this_type)) RL_TYPE(pp) = (prev_type == next_type) ? /* N1. */ prev_type : - /* N2. */ LEVEL_DIR(RL_LEVEL(pp)); - + /* N2. */ EMBEDDING_DIRECTION(pp); + /* Update ppprev if needed. */ - if (this_type != FRIBIDI_TYPE_N || + if (!IS_NEUTRAL(this_type) || RL_LEVEL(pp) != RL_LEVEL(pp->next)) ppprev = pp; } @@ -998,23 +904,13 @@ fribidi_analyse_string(/* input */ gint this_type = RL_TYPE(pp); gint level = RL_LEVEL(pp); - /* This code should be expanded to handle explicit directions! */ - - /* I1. Even */ - if (level % 2 == 0) - { - if (this_type == FRIBIDI_TYPE_R) - RL_LEVEL(pp)++; - else if (this_type == FRIBIDI_TYPE_AN || - this_type == FRIBIDI_TYPE_EN) - RL_LEVEL(pp) += 2; - } - /* I2. Odd */ - else - if (this_type == FRIBIDI_TYPE_L || - this_type == FRIBIDI_TYPE_AN || - this_type == FRIBIDI_TYPE_EN) - RL_LEVEL(pp)++; + /* I1. Even */ + /* I2. Odd */ + if (IS_NUMBER(this_type)) + RL_LEVEL(pp) = (RL_LEVEL(pp) + 2) & ~1; + else + RL_LEVEL(pp) = (RL_LEVEL(pp) ^ DIR_TO_LEVEL(this_type)) + + (RL_LEVEL(pp) & 1); if (RL_LEVEL(pp) > max_level) max_level = RL_LEVEL(pp); @@ -1145,20 +1041,11 @@ void fribidi_log2vis(/* input */ pos = len - 1; for (j=len-1; j>=0; j--) { k = fribidi_get_type(str[j]); - if (!state && (k == FRIBIDI_TYPE_BS || k == FRIBIDI_TYPE_SS)) { + if (!state && IS_SEPARATOR(k)) { state = 1; pos = j; } else - if (state && (!j || !( - k == FRIBIDI_TYPE_WS || - k == FRIBIDI_TYPE_BS || - k == FRIBIDI_TYPE_SS || - k == FRIBIDI_TYPE_BN || - k == FRIBIDI_TYPE_LRO || - k == FRIBIDI_TYPE_LRE || - k == FRIBIDI_TYPE_RLO || - k == FRIBIDI_TYPE_RLE || - k == FRIBIDI_TYPE_PDF))) { + if (state && !(j && IS_EXPLICIT_OR_SEPARATOR_OR_BN_OR_WS(k))) { /* if state is on at the very first of string, do this too. */ if (!j) j--; @@ -1168,7 +1055,7 @@ void fribidi_log2vis(/* input */ p->pos = j+1; p->len = pos - j; p->type = *pbase_dir; - p->level = p->type == FRIBIDI_TYPE_R ? 1 : 0; + p->level = DIR_TO_LEVEL(p->type); move_element_before(p, q); q = p; } diff --git a/fribidi_benchmark.c b/fribidi_benchmark.c index a685b6a..3968306 100644 --- a/fribidi_benchmark.c +++ b/fribidi_benchmark.c @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) for (i=0; i<niter; i++) { /* Create a bidi string */ - base = FRIBIDI_TYPE_N; + base = FRIBIDI_TYPE_ON; fribidi_log2vis(us, len, &base, /* output */ out_us, diff --git a/fribidi_get_type.c b/fribidi_get_type.c index d00353f..5d71239 100644 --- a/fribidi_get_type.c +++ b/fribidi_get_type.c @@ -27,22 +27,22 @@ FriBidiCharType fribidi_get_type(FriBidiChar uch) { int i = uch % 256, j = uch / 256; - guchar *block = FriBidiPropertyBlocks[j]; + FriBidiCharType *block = FriBidiPropertyBlocks[j]; if (block) return block[i]; else { switch (j) { - case 0x05: if (i >= 0x90) return FRIBIDI_TYPE_R; else break; + case 0x05: if (i >= 0x90) return FRIBIDI_TYPE_RTL; else break; case 0xFB: if (i >= 0x50) return FRIBIDI_TYPE_AL; else - if (i >= 0x1D) return FRIBIDI_TYPE_R; else break; + if (i >= 0x1D) return FRIBIDI_TYPE_RTL; else break; case 0x06: case 0xFC: case 0xFD: return FRIBIDI_TYPE_AL; case 0x07: if (i <= 0xBF) return FRIBIDI_TYPE_AL; else break; case 0xFE: if (i >= 0x70) return FRIBIDI_TYPE_AL; else break; } - return FRIBIDI_TYPE_L; + return FRIBIDI_TYPE_LTR; } } diff --git a/fribidi_main.c b/fribidi_main.c index bf611bf..d12e61f 100644 --- a/fribidi_main.c +++ b/fribidi_main.c @@ -72,7 +72,7 @@ void die(gchar *fmt, ...) #define PDF FRIBIDI_TYPE_PDF #define EN FRIBIDI_TYPE_EN -guchar FriBidiPropertyBlockSmallCaps[] = { +FriBidiCharType FriBidiPropertyBlockSmallCaps[] = { //0 1 2 3 4 5 6 7 8 9 a b c d e f ON ,ON ,ON ,ON ,LTR,RTL,ON ,ON ,ON ,ON ,ON ,ON ,ON ,BS ,RLO,RLE,/*00-0f*/ LRO,LRE,PDF,WS ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,/*10-1f*/ @@ -238,7 +238,7 @@ int main(int argc, char *argv[]) gboolean do_fill = FALSE; gint char_set = 0; guchar *bol_text = NULL, *eol_text = NULL; - FriBidiCharType input_base_direction = FRIBIDI_TYPE_N; + FriBidiCharType input_base_direction = FRIBIDI_TYPE_ON; /* Parse the command line */ @@ -278,8 +278,8 @@ int main(int argc, char *argv[]) CASE("-width") { text_width = atoi(argv[argp++]); continue; } CASE("-eol") { eol_text = argv[argp++]; continue; } CASE("-bol") { bol_text = argv[argp++]; continue; } - CASE("-rtl") { input_base_direction = FRIBIDI_TYPE_R; continue; } - CASE("-ltr") { input_base_direction = FRIBIDI_TYPE_L; continue; } + CASE("-rtl") { input_base_direction = FRIBIDI_TYPE_RTL; continue; } + CASE("-ltr") { input_base_direction = FRIBIDI_TYPE_LTR; continue; } CASE("-fill") { do_fill = TRUE; continue; } CASE("-debug") { @@ -358,7 +358,7 @@ int main(int argc, char *argv[]) if (bol_text) printf("%s", bol_text); - if (base == FRIBIDI_TYPE_R && do_pad && *outstring) { + if (base == FRIBIDI_TYPE_RTL && do_pad && *outstring) { j = strlen(outstring); k = (j-1) % text_width + 1; for (i=(j-1)/text_width-1; i>=0; i--) diff --git a/fribidi_tables.i b/fribidi_tables.i index 238caf5..10f5a64 100644 --- a/fribidi_tables.i +++ b/fribidi_tables.i @@ -1,6 +1,6 @@ -/*====================================================================== -// This file was automatically created from PropList.txt -// by the perl script CreateGetType.pl. +/*======================================================================== +// This file was automatically created from PropList.txt, version 3.0.1, +// and BidiMirroring.txt, version 1, by the perl script CreateGetType.pl. //----------------------------------------------------------------------*/ #include "fribidi.h" @@ -28,7 +28,7 @@ #define EN FRIBIDI_TYPE_EN -guchar FriBidiPropertyBlock0000[256] = { +FriBidiCharType FriBidiPropertyBlock0000[256] = { BN ,BN ,BN ,BN ,BN ,BN ,BN ,BN ,BN ,SS ,BS ,SS ,WS ,BS ,BN ,BN , BN ,BN ,BN ,BN ,BN ,BN ,BN ,BN ,BN ,BN ,BN ,BN ,BS ,BS ,BS ,SS , WS ,ON ,ON ,ET ,ET ,ET ,ON ,ON ,ON ,ON ,ON ,ET ,CS ,ET ,CS ,ES , @@ -47,7 +47,7 @@ guchar FriBidiPropertyBlock0000[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,ON ,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0100[256] = { +FriBidiCharType FriBidiPropertyBlock0100[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -66,7 +66,7 @@ guchar FriBidiPropertyBlock0100[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0200[256] = { +FriBidiCharType FriBidiPropertyBlock0200[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -85,7 +85,7 @@ guchar FriBidiPropertyBlock0200[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0300[256] = { +FriBidiCharType FriBidiPropertyBlock0300[256] = { NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, @@ -104,7 +104,7 @@ guchar FriBidiPropertyBlock0300[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0400[256] = { +FriBidiCharType FriBidiPropertyBlock0400[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -123,7 +123,7 @@ guchar FriBidiPropertyBlock0400[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0500[256] = { +FriBidiCharType FriBidiPropertyBlock0500[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -142,7 +142,7 @@ guchar FriBidiPropertyBlock0500[256] = { RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL, }; -guchar FriBidiPropertyBlock0600[256] = { +FriBidiCharType FriBidiPropertyBlock0600[256] = { CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS , CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,CS ,AL ,AL ,AL ,AL ,AL , AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , @@ -161,7 +161,7 @@ guchar FriBidiPropertyBlock0600[256] = { EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,AL ,AL ,AL ,AL ,AL ,AL , }; -guchar FriBidiPropertyBlock0700[256] = { +FriBidiCharType FriBidiPropertyBlock0700[256] = { AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,BN , AL ,NSM,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , @@ -180,7 +180,7 @@ guchar FriBidiPropertyBlock0700[256] = { NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, }; -guchar FriBidiPropertyBlock0900[256] = { +FriBidiCharType FriBidiPropertyBlock0900[256] = { NSM,NSM,NSM,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -199,7 +199,7 @@ guchar FriBidiPropertyBlock0900[256] = { LTR,LTR,ET ,ET ,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0a00[256] = { +FriBidiCharType FriBidiPropertyBlock0a00[256] = { NSM,NSM,NSM,NSM,NSM,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -218,7 +218,7 @@ guchar FriBidiPropertyBlock0a00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0b00[256] = { +FriBidiCharType FriBidiPropertyBlock0b00[256] = { NSM,NSM,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -237,7 +237,7 @@ guchar FriBidiPropertyBlock0b00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0c00[256] = { +FriBidiCharType FriBidiPropertyBlock0c00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -256,7 +256,7 @@ guchar FriBidiPropertyBlock0c00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0d00[256] = { +FriBidiCharType FriBidiPropertyBlock0d00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -275,7 +275,7 @@ guchar FriBidiPropertyBlock0d00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0e00[256] = { +FriBidiCharType FriBidiPropertyBlock0e00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -294,7 +294,7 @@ guchar FriBidiPropertyBlock0e00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock0f00[256] = { +FriBidiCharType FriBidiPropertyBlock0f00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,NSM,NSM,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -313,7 +313,7 @@ guchar FriBidiPropertyBlock0f00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock1000[256] = { +FriBidiCharType FriBidiPropertyBlock1000[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,NSM,NSM,NSM, @@ -332,7 +332,7 @@ guchar FriBidiPropertyBlock1000[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock1600[256] = { +FriBidiCharType FriBidiPropertyBlock1600[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -351,7 +351,7 @@ guchar FriBidiPropertyBlock1600[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock1700[256] = { +FriBidiCharType FriBidiPropertyBlock1700[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -370,7 +370,7 @@ guchar FriBidiPropertyBlock1700[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlock1800[256] = { +FriBidiCharType FriBidiPropertyBlock1800[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,BN ,BN ,BN ,BN ,BN , LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -389,7 +389,7 @@ guchar FriBidiPropertyBlock1800[256] = { NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, }; -guchar FriBidiPropertyBlock1f00[256] = { +FriBidiCharType FriBidiPropertyBlock1f00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -408,7 +408,7 @@ guchar FriBidiPropertyBlock1f00[256] = { ON ,ON ,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,ON ,ON ,ON , }; -guchar FriBidiPropertyBlock2000[256] = { +FriBidiCharType FriBidiPropertyBlock2000[256] = { WS ,WS ,WS ,WS ,WS ,WS ,WS ,WS ,WS ,WS ,WS ,BN ,BN ,BN ,LTR,RTL, ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,WS ,BS ,LRE,RLE,PDF,LRO,RLO,WS , @@ -427,7 +427,7 @@ guchar FriBidiPropertyBlock2000[256] = { NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, }; -guchar FriBidiPropertyBlock2100[256] = { +FriBidiCharType FriBidiPropertyBlock2100[256] = { ON ,ON ,LTR,ON ,ON ,ON ,ON ,LTR,ON ,ON ,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,ON ,LTR,ON ,ON ,ON ,LTR,LTR,LTR,LTR,LTR,ON ,ON , ON ,ON ,ON ,ON ,LTR,ON ,LTR,ON ,LTR,ON ,LTR,LTR,LTR,LTR,ET ,LTR, @@ -446,7 +446,7 @@ guchar FriBidiPropertyBlock2100[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , }; -guchar FriBidiPropertyBlock2200[256] = { +FriBidiCharType FriBidiPropertyBlock2200[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ET ,ET ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , @@ -465,7 +465,7 @@ guchar FriBidiPropertyBlock2200[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , }; -guchar FriBidiPropertyBlock2300[256] = { +FriBidiCharType FriBidiPropertyBlock2300[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , @@ -484,7 +484,7 @@ guchar FriBidiPropertyBlock2300[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , }; -guchar FriBidiPropertyBlock2400[256] = { +FriBidiCharType FriBidiPropertyBlock2400[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , @@ -503,7 +503,7 @@ guchar FriBidiPropertyBlock2400[256] = { EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN , }; -guchar FriBidiPropertyBlock2500[256] = { +FriBidiCharType FriBidiPropertyBlock2500[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , @@ -522,7 +522,7 @@ guchar FriBidiPropertyBlock2500[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , }; -guchar FriBidiPropertyBlock3000[256] = { +FriBidiCharType FriBidiPropertyBlock3000[256] = { WS ,ON ,ON ,ON ,ON ,LTR,LTR,LTR,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , ON ,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,NSM,NSM,NSM,NSM,NSM,NSM, @@ -541,7 +541,7 @@ guchar FriBidiPropertyBlock3000[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,ON ,LTR,LTR,LTR,LTR, }; -guchar FriBidiPropertyBlocka400[256] = { +FriBidiCharType FriBidiPropertyBlocka400[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -560,7 +560,7 @@ guchar FriBidiPropertyBlocka400[256] = { ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON ,ON , }; -guchar FriBidiPropertyBlockfb00[256] = { +FriBidiCharType FriBidiPropertyBlockfb00[256] = { LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,RTL,NSM,RTL, RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,ET ,RTL,RTL,RTL,RTL,RTL,RTL, @@ -579,7 +579,7 @@ guchar FriBidiPropertyBlockfb00[256] = { AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , }; -guchar FriBidiPropertyBlockfc00[256] = { +FriBidiCharType FriBidiPropertyBlockfc00[256] = { AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , @@ -598,7 +598,7 @@ guchar FriBidiPropertyBlockfc00[256] = { AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , }; -guchar FriBidiPropertyBlockfd00[256] = { +FriBidiCharType FriBidiPropertyBlockfd00[256] = { AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , @@ -617,7 +617,7 @@ guchar FriBidiPropertyBlockfd00[256] = { AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL , }; -guchar FriBidiPropertyBlockfe00[256] = { +FriBidiCharType FriBidiPropertyBlockfe00[256] = { NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM,NSM, @@ -636,7 +636,7 @@ guchar FriBidiPropertyBlockfe00[256] = { AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,AL ,BN , }; -guchar FriBidiPropertyBlockff00[256] = { +FriBidiCharType FriBidiPropertyBlockff00[256] = { ON ,ON ,ON ,ET ,ET ,ET ,ON ,ON ,ON ,ON ,ON ,ET ,CS ,ET ,CS ,ES , EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,EN ,CS ,ON ,ON ,ON ,ON ,ON , ON ,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, @@ -657,7 +657,7 @@ guchar FriBidiPropertyBlockff00[256] = { /* 33 blocks defined */ -guchar *FriBidiPropertyBlocks[256] = { +FriBidiCharType *FriBidiPropertyBlocks[256] = { FriBidiPropertyBlock0000, FriBidiPropertyBlock0100, FriBidiPropertyBlock0200, diff --git a/fribidi_types.h b/fribidi_types.h index 9878e92..a79ef2d 100644 --- a/fribidi_types.h +++ b/fribidi_types.h @@ -24,42 +24,203 @@ typedef guint32 FriBidiChar; +/* Define some bit masks, that character types are based on, each one has + only one bit on. */ +static enum +{ + FRIBIDI_MASK_RTL = 0x00000001, /* Is right to left */ + FRIBIDI_MASK_ARABIC = 0x00000002, /* Is arabic */ + + /* Each char can be only one of the three following. */ + FRIBIDI_MASK_STRONG = 0x00000010, /* Is strong */ + FRIBIDI_MASK_WEAK = 0x00000020, /* Is weak */ + FRIBIDI_MASK_NEUTRAL = 0x00000040, /* Is neutral */ + FRIBIDI_MASK_SENTINEL = 0x00000080, /* Is sentinel: SOT, EOT */ + /* Sentinels are not valid chars, just identify the start and end of strings. */ + + /* Each char can be only one of the five following. */ + FRIBIDI_MASK_LETTER = 0x00000100, /* Is letter: L, R, AL */ + FRIBIDI_MASK_NUMBER = 0x00000200, /* Is number: EN, AN */ + FRIBIDI_MASK_NUMSEPTER = 0x00000400, /* Is number separator or terminator: ES, ET, CS */ + FRIBIDI_MASK_SPACE = 0x00000800, /* Is space: BN, BS, SS, WS */ + FRIBIDI_MASK_EXPLICIT = 0x00001000, /* Is expilict mark: LRE, RLE, LRO, RLO, PDF */ + + /* Can be on only if FRIBIDI_MASK_SPACE is also on. */ + FRIBIDI_MASK_SEPARATOR = 0x00002000, /* Is test separator: BS, SS */ + + /* Can be on only if FRIBIDI_MASK_EXPLICIT is also on. */ + FRIBIDI_MASK_OVERRIDE = 0x00004000, /* Is explicit override: LRO, RLO */ + + /* Can be on for SOT and EOT sentinels only, not a valid char if is on. */ + + /* The following must be to make types pairwise different, some of them can + be removed but are here because of efficiency (make queries faster). */ + + FRIBIDI_MASK_ES = 0x00010000, + FRIBIDI_MASK_ET = 0x00020000, + FRIBIDI_MASK_CS = 0x00040000, + + FRIBIDI_MASK_NSM = 0x00080000, + FRIBIDI_MASK_BN = 0x00100000, + + FRIBIDI_MASK_BS = 0x00200000, + FRIBIDI_MASK_SS = 0x00400000, + FRIBIDI_MASK_WS = 0x00800000, +} FRIBIDI_MASK; + typedef enum { - FRIBIDI_TYPE_LTR , /* Strong left to right */ - FRIBIDI_TYPE_RTL , /* Right to left characters */ - FRIBIDI_TYPE_WL , /* Weak left to right */ - FRIBIDI_TYPE_WR , /* Weak right to left */ - FRIBIDI_TYPE_EN , /* European digit */ - FRIBIDI_TYPE_ES , /* European number separator */ - FRIBIDI_TYPE_ET , /* European number terminator */ - FRIBIDI_TYPE_AN , /* Arabic digit */ - FRIBIDI_TYPE_CS , /* Common Separator */ - FRIBIDI_TYPE_BS , /* Block separator */ - FRIBIDI_TYPE_SS , /* Segment separator */ - FRIBIDI_TYPE_WS , /* Whitespace */ - FRIBIDI_TYPE_AL , /* Arabic characters */ - FRIBIDI_TYPE_NSM , /* Non spacing mark */ - FRIBIDI_TYPE_LRE , /* Left-To-Right embedding */ - FRIBIDI_TYPE_RLE , /* Right-To-Left embedding */ - FRIBIDI_TYPE_LRO , /* Left-To-Right override */ - FRIBIDI_TYPE_RLO , /* Right-To-Left override */ - FRIBIDI_TYPE_PDF , /* Pop directional override */ - FRIBIDI_TYPE_ON , /* Other Neutral */ + FRIBIDI_TYPE_LTR = /* Strong left to right */ + FRIBIDI_MASK_STRONG + FRIBIDI_MASK_LETTER, + FRIBIDI_TYPE_RTL = /* Right to left characters */ + FRIBIDI_MASK_STRONG + FRIBIDI_MASK_LETTER + + FRIBIDI_MASK_RTL, + FRIBIDI_TYPE_AL = /* Arabic characters */ + FRIBIDI_MASK_STRONG + FRIBIDI_MASK_LETTER + + FRIBIDI_MASK_RTL + FRIBIDI_MASK_ARABIC, + FRIBIDI_TYPE_LRE = /* Left-To-Right embedding */ + FRIBIDI_MASK_STRONG + FRIBIDI_MASK_EXPLICIT, + FRIBIDI_TYPE_RLE = /* Right-To-Left embedding */ + FRIBIDI_MASK_STRONG + FRIBIDI_MASK_EXPLICIT + + FRIBIDI_MASK_RTL, + FRIBIDI_TYPE_LRO = /* Left-To-Right override */ + FRIBIDI_MASK_STRONG + FRIBIDI_MASK_EXPLICIT + + FRIBIDI_MASK_OVERRIDE, + FRIBIDI_TYPE_RLO = /* Right-To-Left override */ + FRIBIDI_MASK_STRONG + FRIBIDI_MASK_EXPLICIT + + FRIBIDI_MASK_RTL + FRIBIDI_MASK_OVERRIDE, + + FRIBIDI_TYPE_PDF = /* Pop directional override */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_EXPLICIT, + FRIBIDI_TYPE_EN = /* European digit */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_NUMBER, + FRIBIDI_TYPE_AN = /* Arabic digit */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_NUMBER + + FRIBIDI_MASK_ARABIC, + FRIBIDI_TYPE_ES = /* European number separator */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_NUMSEPTER + + FRIBIDI_MASK_ES, + FRIBIDI_TYPE_ET = /* European number terminator */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_NUMSEPTER + + FRIBIDI_MASK_ET, + FRIBIDI_TYPE_CS = /* Common Separator */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_NUMSEPTER + + FRIBIDI_MASK_CS, + FRIBIDI_TYPE_NSM = /* Non spacing mark */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_NSM, + FRIBIDI_TYPE_BN = /* Boundary neutral */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_SPACE + + FRIBIDI_MASK_BN, + + FRIBIDI_TYPE_BS = /* Block separator */ + FRIBIDI_MASK_NEUTRAL + FRIBIDI_MASK_SPACE + + FRIBIDI_MASK_SEPARATOR + FRIBIDI_MASK_BS, + FRIBIDI_TYPE_SS = /* Segment separator */ + FRIBIDI_MASK_NEUTRAL + FRIBIDI_MASK_SPACE + + FRIBIDI_MASK_SEPARATOR + FRIBIDI_MASK_SS, + FRIBIDI_TYPE_WS = /* Whitespace */ + FRIBIDI_MASK_NEUTRAL + FRIBIDI_MASK_SPACE + + FRIBIDI_MASK_WS, + FRIBIDI_TYPE_ON = /* Other Neutral */ + FRIBIDI_MASK_NEUTRAL, + + /* The following are used to identify the paragraph direction, + types L, R, N are not used internally anymore, and recommended to use + LTR, RTL and ON instead, didn't removed because of compatability. */ + FRIBIDI_TYPE_L = FRIBIDI_TYPE_LTR, + FRIBIDI_TYPE_R = FRIBIDI_TYPE_RTL, + FRIBIDI_TYPE_N = FRIBIDI_TYPE_ON, + FRIBIDI_TYPE_WL = /* Weak left to right */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_LETTER, + FRIBIDI_TYPE_WR = /* Weak right to left */ + FRIBIDI_MASK_WEAK + FRIBIDI_MASK_LETTER + + FRIBIDI_MASK_RTL, /* The following are only used internally */ - FRIBIDI_TYPE_L = FRIBIDI_TYPE_LTR, - FRIBIDI_TYPE_R = FRIBIDI_TYPE_RTL, - FRIBIDI_TYPE_BN = FRIBIDI_TYPE_ON + 2, - FRIBIDI_TYPE_CM , - FRIBIDI_TYPE_SOT , - FRIBIDI_TYPE_EOT , - FRIBIDI_TYPE_N , - FRIBIDI_TYPE_E , - FRIBIDI_TYPE_CTL , /* Control units */ - FRIBIDI_TYPE_EO , /* Control units */ + FRIBIDI_TYPE_SOT = /* Start of text */ + FRIBIDI_MASK_SENTINEL, + FRIBIDI_TYPE_EOT = /* End of text */ + FRIBIDI_MASK_SENTINEL + FRIBIDI_MASK_RTL, } FriBidiCharType; +/* Defining macros for needed queries, It is fully dependent on the + implementation of FriBidiCharType. */ + +/* Return the direction of the level number, FRIBIDI_TYPE_LTR for even and + FRIBIDI_TYPE_RTL for odds. */ +#define LEVEL_TO_DIR(lev) (FRIBIDI_TYPE_LTR | (lev & 1)) + +/* Return the minimum level of the direction, 0 for FRIBIDI_TYPE_LTR and + 1 for FRIBIDI_TYPE_RTL and FRIBIDI_TYPE_AL. */ +#define DIR_TO_LEVEL(dir) (dir & 1) + +/* Is right to left? */ +#define IS_RTL(p) ((P) & FRIBIDI_MASK_RTL) +/* Is arabic? */ +#define IS_ARABIC(p) ((p) & FRIBIDI_MASK_ARABIC) + +/* Is strong? */ +#define IS_STRONG(p) ((p) & FRIBIDI_MASK_STRONG) +/* Is weak? */ +#define IS_WEAK(p) ((p) & FRIBIDI_MASK_WEAK) +/* Is neutral? */ +#define IS_NEUTRAL(p) ((p) & FRIBIDI_MASK_NEUTRAL) +/* Is sentinel? */ +#define IS_SENTINEL(p) ((p) & FRIBIDI_MASK_SENTINEL) + +/* Is letter: L, R, AL? */ +#define IS_LETTER(p) ((p) & FRIBIDI_MASK_LETTER) +/* Is number: EN, AN? */ +#define IS_NUMBER(p) ((p) & FRIBIDI_MASK_NUMBER) +/* Is number separator or terminator: ES, ET, CS? */ +#define IS_NUMBER_SEPARATOR_OR_TERMINATOR(p) \ + ((p) & FRIBIDI_MASK_NUMSEPTER) +/* Is space: BN, BS, SS, WS? */ +#define IS_SPACE(p) ((p) & FRIBIDI_MASK_SPACE) +/* Is explicit mark: LRE, RLE, LRO, RLO, PDF? */ +#define IS_EXPLICIT(p) ((p) & FRIBIDI_MASK_EXPLICIT) + +/* Is test separator: BS, SS? */ +#define IS_SEPARATOR(p) ((p) & FRIBIDI_MASK_SEPARATOR) + +/* Is explicit override: LRO, RLO? */ +#define IS_OVERRIDE(p) ((p) & FRIBIDI_MASK_OVERRIDE) + +/* Some more: */ + +/* Is left to right letter: LTR? */ +#define IS_LTR_LETTER(p) \ + ((p) & (FRIBIDI_MASK_LETTER | FRIBIDI_MASK_RTL) == FRIBIDI_MASK_LETTER) + +/* Is right to left letter: RTL, AL? */ +#define IS_RTL_LETTER(p) \ + ((p) & (FRIBIDI_MASK_LETTER | FRIBIDI_MASK_RTL) == \ + (FRIBIDI_MASK_LETTER | FRIBIDI_MASK_RTL)) + +/* Is ES or CS: ES, CS? */ +#define IS_ES_OR_CS(p) \ + ((p) & (FRIBIDI_MASK_ES | FRIBIDI_MASK_CS)) + +/* Is explicit or BN: LRE, RLE, LRO, RLO, PDF, BN? */ +#define IS_EXPLICIT_OR_BN(p) \ + ((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_BN)) + +/* Is explicit or separator or BN or WS: LRE, RLE, LRO, RLO, PDF, BS, SS, BN, WS? */ +#define IS_EXPLICIT_OR_SEPARATOR_OR_BN_OR_WS(p) \ + ((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_SEPARATOR | \ + FRIBIDI_MASK_BN | FRIBIDI_MASK_WS)) + +/* Define some conversions. */ + +/* Change numbers:EN, AN to RTL. */ +#define CHANGE_NUMBER_TO_RTL(p) \ + (IS_NUMBER(p) ? FRIBIDI_TYPE_RTL : (p)) + +/* Override status of an explicit mark: LRO->LTR, RLO->RTL, otherwise->ON. */ +#define EXPLICIT_TO_OVERRIDE_DIR(p) \ + (IS_EXPLICIT(p) ? LEVEL_TO_DIR(DIR_TO_LEVEL(p)) : FRIBIDI_TYPE_ON) + + #ifdef DEBUG char char_from_type[] = { 'L', 'R', 'l', 'r', '1', 'w', 'w', '9', 'w', 'P', 'S', '_', 'A', diff --git a/test_fribidi.c b/test_fribidi.c index 570df24..2880d2b 100644 --- a/test_fribidi.c +++ b/test_fribidi.c @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) fribidi_iso8859_8_to_unicode(S_, us); /* Create a bidi string */ - base = FRIBIDI_TYPE_N; + base = FRIBIDI_TYPE_ON; fribidi_log2vis(us, len, &base, /* output */ out_us, @@ -158,7 +158,7 @@ int main(int argc, char *argv[]) if (outstring[i]>=0xE0 && outstring[i]<=0xFA) outstring[i]-= 0xE0 - 'A'; /* Map to capital letters */ - if (base == FRIBIDI_TYPE_R && !do_no_pad) + if (base == FRIBIDI_TYPE_RTL && !do_no_pad) for (i=0; i<pad_width-len; i++) printf(" "); @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) printf("%s", outstring); } - if (base == FRIBIDI_TYPE_L && !do_no_pad) + if (base == FRIBIDI_TYPE_LTR && !do_no_pad) for (i=0; i<pad_width-len; i++) printf(" "); diff --git a/unidata/CreateGetType.pl b/unidata/CreateGetType.pl index dd40c34..28aad0e 100755 --- a/unidata/CreateGetType.pl +++ b/unidata/CreateGetType.pl @@ -207,7 +207,7 @@ sub split_entity { sub create_block { my ($block,$name, $ranges) = @_; my($title) = <<__; -guchar ${name}\[256\] = { +FriBidiCharType ${name}\[256\] = { __ my $result; my $last_type=$ranges->[0]->[2]; @@ -264,7 +264,7 @@ __ my $i = 0; my $block_array = <<__; -guchar *FriBidiPropertyBlocks[256] = { +FriBidiCharType *FriBidiPropertyBlocks[256] = { __ my %seen_blocks; |