const char * fribidi_char_set_desc_cap_rtl ( void ) { static char *s = 0; int l, i, j; if (s) return s; l = 10000; s = (char *) fribidi_malloc (l); i = 0; i += sprintf (s + i, /*l - i, */ "CapRTL is a character set for testing with the reference\n" "implementation, with explicit marks escape strings, and\n" "the property that contains all unicode character types in\n" "ASCII range 1-127.\n" "\n" "Warning: CapRTL character types are subject to change.\n" "\n" "CapRTL's character types:\n"); for (j = 0; j < CAPRTL_CHARS; j++) { if (j % 4 == 0) s[i++] = '\n'; i += sprintf (s + i, /*l - i, */ " * 0x%02x %c%c %-3s ", j, j < 0x20 ? '^' : ' ', j < 0x20 ? j + '@' : j < 0x7f ? j : ' ', fribidi_get_bidi_type_name (CapRTLCharTypes[j])); } i += sprintf (s + i, /*l - i, */ "\n\n" "Escape sequences:\n" " Character `_' is used to escape explicit marks. The list is:\n" " * _> LRM\n" " * _< RLM\n" " * _l LRE\n" " * _r RLE\n" " * _L LRO\n" " * _R RLO\n" " * _o PDF\n" " * _i LRI\n" " * _y RLI\n" " * _f FSI\n" " * _I PDI\n" " * __ `_' itself\n" "\n"); return s; }
static void init_cap_rtl ( void ) { int request[_FRIBIDI_NUM_TYPES]; FriBidiCharType to_type[_FRIBIDI_NUM_TYPES]; int num_types = 0, count = 0; FriBidiCharType i; char mark[CAPRTL_CHARS]; caprtl_to_unicode = (FriBidiChar *) fribidi_malloc (CAPRTL_CHARS * sizeof caprtl_to_unicode[0]); for (i = 0; i < CAPRTL_CHARS; i++) if (CapRTLCharTypes[i] == fribidi_get_bidi_type (i)) { caprtl_to_unicode[i] = i; mark[i] = 1; } else { int j; caprtl_to_unicode[i] = FRIBIDI_UNICODE_CHARS; mark[i] = 0; if (fribidi_get_mirror_char (i, NULL)) { DBG ("warning: I could not map mirroring character map to itself in CapRTL"); } for (j = 0; j < num_types; j++) if (to_type[j] == CapRTLCharTypes[i]) break; if (j == num_types) { num_types++; to_type[j] = CapRTLCharTypes[i]; request[j] = 0; } request[j]++; count++; } for (i = 0; i < 0x10000 && count; i++) /* Assign BMP chars to CapRTL entries */ if (!fribidi_get_mirror_char (i, NULL) && !(i < CAPRTL_CHARS && mark[i])) { int j, k; FriBidiCharType t = fribidi_get_bidi_type (i); for (j = 0; j < num_types; j++) if (to_type[j] == t) break; if (!request[j]) /* Do not need this type */ continue; for (k = 0; k < CAPRTL_CHARS; k++) if (caprtl_to_unicode[k] == FRIBIDI_UNICODE_CHARS && to_type[j] == CapRTLCharTypes[k]) { request[j]--; count--; caprtl_to_unicode[k] = i; break; } } if (count) { int j; DBG ("warning: could not find a mapping for CapRTL to Unicode:"); for (j = 0; j < num_types; j++) if (request[j]) { DBG2 (" need this type: %s", fribidi_get_bidi_type_name (to_type[j])); } } }