diff options
| author | Sam Varshavchik | 2020-12-06 22:35:33 -0500 |
|---|---|---|
| committer | Sam Varshavchik | 2020-12-06 22:37:04 -0500 |
| commit | a5cc76216e08481a6f3614574a8ee498e5800afa (patch) | |
| tree | 42f9ac075cf54afaef9bbd27f5a3b75dc3602439 /unicode/unicodecpp.C | |
| parent | 3a5d23502f3c34e1047fd93d02a777eda6a32a41 (diff) | |
| download | courier-libs-a5cc76216e08481a6f3614574a8ee498e5800afa.tar.bz2 | |
courier-unicode: partial logical reordering.
Diffstat (limited to 'unicode/unicodecpp.C')
| -rw-r--r-- | unicode/unicodecpp.C | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/unicode/unicodecpp.C b/unicode/unicodecpp.C index 5677b86..3ef3b05 100644 --- a/unicode/unicodecpp.C +++ b/unicode/unicodecpp.C @@ -806,16 +806,24 @@ int unicode::bidi_logical_order(std::u32string &string, std::vector<unicode_bidi_level_t> &levels, unicode_bidi_level_t paragraph_embedding, const std::function<void (size_t, size_t)> - &lambda) + &lambda, + size_t starting_pos, + size_t n) { - if (string.size() != levels.size()) + auto s=string.size(); + + if (s != levels.size()) return -1; - if (string.empty()) + if (starting_pos >= s) return 0; + if (n > s-starting_pos) + n=s-starting_pos; + cb_wrapper<void (size_t, size_t)> cb{lambda}; - unicode_bidi_logical_order(&string[0], &levels[0], string.size(), + unicode_bidi_logical_order(&string[starting_pos], + &levels[starting_pos], n, paragraph_embedding, &reorder_callback, reinterpret_cast<void *>(&cb)); @@ -826,13 +834,20 @@ int unicode::bidi_logical_order(std::u32string &string, void unicode::bidi_logical_order(std::vector<unicode_bidi_level_t> &levels, unicode_bidi_level_t paragraph_embedding, const std::function<void (size_t, size_t)> - &lambda) + &lambda, + size_t starting_pos, + size_t n) { - if (levels.size() == 0) + auto s=levels.size(); + + if (starting_pos >= s) return; + if (n > s-starting_pos) + n=s-starting_pos; + cb_wrapper<void (size_t, size_t)> cb{lambda}; - unicode_bidi_logical_order(NULL, &levels[0], levels.size(), + unicode_bidi_logical_order(NULL, &levels[starting_pos], n, paragraph_embedding, &reorder_callback, reinterpret_cast<void *>(&cb)); |
