diff options
author | Bram Moolenaar <Bram@vim.org> | 2006-03-06 23:29:24 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2006-03-06 23:29:24 +0000 |
commit | 362e1a30c6f3527d5d0efc328c2fb448290cd6fc (patch) | |
tree | 91c408352947bec09aee2032949ef1acef606d15 /src/mbyte.c | |
parent | 768b8c4dbcb3cdaccab87daa833ab176a438cc3c (diff) | |
download | vim-git-362e1a30c6f3527d5d0efc328c2fb448290cd6fc.tar.gz |
updated for version 7.0216v7.0216
Diffstat (limited to 'src/mbyte.c')
-rw-r--r-- | src/mbyte.c | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/src/mbyte.c b/src/mbyte.c index 062d5842f..4cd7e96fa 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -1486,55 +1486,59 @@ utf_composinglike(p1, p2) #endif /* - * Convert a UTF-8 byte string to a wide chararacter. Also get up to two + * Convert a UTF-8 byte string to a wide chararacter. Also get up to MAX_MCO * composing characters. */ int -utfc_ptr2char(p, p1, p2) +utfc_ptr2char(p, pcc) char_u *p; - int *p1; /* return: first composing char or 0 */ - int *p2; /* return: second composing char or 0 */ + int *pcc; /* return: composing chars, last one is 0 */ { int len; int c; int cc; + int i = 0; c = utf_ptr2char(p); len = utf_ptr2len(p); + /* Only accept a composing char when the first char isn't illegal. */ if ((len > 1 || *p < 0x80) && p[len] >= 0x80 && UTF_COMPOSINGLIKE(p, p + len)) { - *p1 = utf_ptr2char(p + len); - len += utf_ptr2len(p + len); - if (p[len] >= 0x80 && utf_iscomposing(cc = utf_ptr2char(p + len))) - *p2 = cc; - else - *p2 = 0; - } - else - { - *p1 = 0; - *p2 = 0; + cc = utf_ptr2char(p + len); + for (;;) + { + pcc[i++] = cc; + if (i == MAX_MCO) + break; + len += utf_ptr2len(p + len); + if (p[len] < 0x80 || !utf_iscomposing(cc = utf_ptr2char(p + len))) + break; + } } + + if (i < MAX_MCO) /* last composing char must be 0 */ + pcc[i] = 0; + return c; } /* - * Convert a UTF-8 byte string to a wide chararacter. Also get up to two + * Convert a UTF-8 byte string to a wide chararacter. Also get up to MAX_MCO * composing characters. Use no more than p[maxlen]. */ int -utfc_ptr2char_len(p, p1, p2, maxlen) +utfc_ptr2char_len(p, pcc, maxlen) char_u *p; - int *p1; /* return: first composing char or 0 */ - int *p2; /* return: second composing char or 0 */ + int *pcc; /* return: composing chars, last one is 0 */ int maxlen; { int len; int c; int cc; + int i = 0; c = utf_ptr2char(p); len = utf_ptr2len_len(p, maxlen); @@ -1544,20 +1548,23 @@ utfc_ptr2char_len(p, p1, p2, maxlen) && p[len] >= 0x80 && UTF_COMPOSINGLIKE(p, p + len)) { - *p1 = utf_ptr2char(p + len); - len += utf_ptr2len_len(p + len, maxlen - len); - if (len < maxlen - && p[len] >= 0x80 - && utf_iscomposing(cc = utf_ptr2char(p + len))) - *p2 = cc; - else - *p2 = 0; - } - else - { - *p1 = 0; - *p2 = 0; + cc = utf_ptr2char(p + len); + for (;;) + { + pcc[i++] = cc; + if (i == MAX_MCO) + break; + len += utf_ptr2len_len(p + len, maxlen - len); + if (len >= maxlen + || p[len] < 0x80 + || !utf_iscomposing(cc = utf_ptr2char(p + len))) + break; + } } + + if (i < MAX_MCO) /* last composing char must be 0 */ + pcc[i] = 0; + return c; } @@ -1573,13 +1580,14 @@ utfc_char2bytes(off, buf) char_u *buf; { int len; + int i; len = utf_char2bytes(ScreenLinesUC[off], buf); - if (ScreenLinesC1[off] != 0) + for (i = 0; i < Screen_mco; ++i) { - len += utf_char2bytes(ScreenLinesC1[off], buf + len); - if (ScreenLinesC2[off] != 0) - len += utf_char2bytes(ScreenLinesC2[off], buf + len); + if (ScreenLinesC[i][off] == 0) + break; + len += utf_char2bytes(ScreenLinesC[i][off], buf + len); } return len; } |