summaryrefslogtreecommitdiffstats
path: root/unicode/unicode_bidi.c
diff options
context:
space:
mode:
authorSam Varshavchik2020-11-29 08:41:57 -0500
committerSam Varshavchik2020-11-30 19:31:57 -0500
commit844f6a9ef755c1c5826c9583b364af08b54a4dcc (patch)
tree10f0af36c609cad9953f7a736e11a2f2e8d8b897 /unicode/unicode_bidi.c
parentf2db409949ad94d4fc175d04ebd72bda3bd1df4e (diff)
downloadcourier-libs-844f6a9ef755c1c5826c9583b364af08b54a4dcc.tar.bz2
Combine cleanup functions, add unicode::literals namespace.
Diffstat (limited to 'unicode/unicode_bidi.c')
-rw-r--r--unicode/unicode_bidi.c38
1 files changed, 10 insertions, 28 deletions
diff --git a/unicode/unicode_bidi.c b/unicode/unicode_bidi.c
index 79c4db5..cfae12f 100644
--- a/unicode/unicode_bidi.c
+++ b/unicode/unicode_bidi.c
@@ -2032,6 +2032,7 @@ void unicode_bidi_reorder(char32_t *p,
size_t unicode_bidi_cleanup(char32_t *string,
unicode_bidi_level_t *levels,
size_t n,
+ int cleanup_options,
void (*removed_callback)(size_t, void *),
void *arg)
{
@@ -2040,7 +2041,13 @@ size_t unicode_bidi_cleanup(char32_t *string,
{
enum_bidi_type_t cl=unicode_bidi_type(string[j]);
- if (IS_X9(cl))
+ if (cleanup_options & UNICODE_BIDI_CLEANUP_EXTRA
+ ? (
+ is_explicit_indicator_except_b(cl) ||
+ (string[j] == UNICODE_LRM ||
+ string[j] == UNICODE_RLM ||
+ string[j] == UNICODE_ALM))
+ : IS_X9(cl))
{
if (removed_callback)
(*removed_callback)(j, arg);
@@ -2048,34 +2055,9 @@ size_t unicode_bidi_cleanup(char32_t *string,
}
if (levels)
levels[i]=levels[j] & 1;
- ++i;
- }
- return i;
-}
-
-size_t unicode_bidi_extra_cleanup(char32_t *string,
- unicode_bidi_level_t *levels,
- size_t n,
- void (*removed_callback)(size_t, void *),
- void *arg)
-{
- size_t i=0;
- for (size_t j=0; j<n; ++j)
- {
- enum_bidi_type_t cl=unicode_bidi_type(string[j]);
- if (is_explicit_indicator_except_b(cl) ||
- (string[j] == UNICODE_LRM ||
- string[j] == UNICODE_RLM ||
- string[j] == UNICODE_ALM))
- {
- if (removed_callback)
- (*removed_callback)(j, arg);
- continue;
- }
- string[i]=cl == UNICODE_BIDI_TYPE_B ? '\n' : string[j];
- if (levels)
- levels[i]=levels[j] & 1;
+ string[i]=(cleanup_options & UNICODE_BIDI_CLEANUP_BNL)
+ && cl == UNICODE_BIDI_TYPE_B ? '\n' : string[j];
++i;
}
return i;