diff options
| author | Sam Varshavchik | 2020-12-06 20:29:07 -0500 |
|---|---|---|
| committer | Sam Varshavchik | 2020-12-06 20:29:07 -0500 |
| commit | 3a5d23502f3c34e1047fd93d02a777eda6a32a41 (patch) | |
| tree | d4b8de6001f5d9725be90a2236e011d473b1d4a2 /unicode/unicodecpp.C | |
| parent | dba04f8c6b41ff124485d620781c651ce1352ee4 (diff) | |
| download | courier-libs-3a5d23502f3c34e1047fd93d02a777eda6a32a41.tar.bz2 | |
courier-unicode: partial cleanup of bidirectional strings.
Diffstat (limited to 'unicode/unicodecpp.C')
| -rw-r--r-- | unicode/unicodecpp.C | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/unicode/unicodecpp.C b/unicode/unicodecpp.C index 8c43b31..5677b86 100644 --- a/unicode/unicodecpp.C +++ b/unicode/unicodecpp.C @@ -636,6 +636,8 @@ struct cb_wrapper { template<typename ...Args> void operator()(Args && ...args) { + if (caught) + return; try { cb(std::forward<Args>(args)...); } catch (...) @@ -771,6 +773,35 @@ int unicode::bidi_cleanup(std::u32string &string, return 0; } +int unicode::bidi_cleanup(std::u32string &string, + std::vector<unicode_bidi_level_t> &levels, + const std::function<void (size_t)> &lambda, + int cleanup_options, + size_t starting_pos, + size_t n) +{ + size_t s=string.size(); + + if (levels.size() != s) + return -1; + + if (starting_pos >= s) + return 0; + + if (n > s-starting_pos) + n=s-starting_pos; + + cb_wrapper<void (size_t)> cb{lambda}; + unicode_bidi_cleanup(&string[starting_pos], + &levels[starting_pos], + n, + cleanup_options, + removed_callback, + reinterpret_cast<void *>(&cb)); + cb.rethrow(); + return 0; +} + int unicode::bidi_logical_order(std::u32string &string, std::vector<unicode_bidi_level_t> &levels, unicode_bidi_level_t paragraph_embedding, |
