Mercurial > vim
comparison src/mbyte.c @ 1658:630eca9496e0 v7.2a.010
updated for version 7.2a-010
author | vimboss |
---|---|
date | Sun, 29 Jun 2008 14:16:06 +0000 |
parents | 73fe8baea242 |
children | 0b796e045c42 |
comparison
equal
deleted
inserted
replaced
1657:c3e225bc213a | 1658:630eca9496e0 |
---|---|
1385 | 1385 |
1386 if (p[0] < 0x80) /* be quick for ASCII */ | 1386 if (p[0] < 0x80) /* be quick for ASCII */ |
1387 return p[0]; | 1387 return p[0]; |
1388 | 1388 |
1389 len = utf8len_tab[p[0]]; | 1389 len = utf8len_tab[p[0]]; |
1390 if ((p[1] & 0xc0) == 0x80) | 1390 if (len > 1 && (p[1] & 0xc0) == 0x80) |
1391 { | 1391 { |
1392 if (len == 2) | 1392 if (len == 2) |
1393 return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f); | 1393 return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f); |
1394 if ((p[2] & 0xc0) == 0x80) | 1394 if ((p[2] & 0xc0) == 0x80) |
1395 { | 1395 { |
1751 #ifdef FEAT_ARABIC | 1751 #ifdef FEAT_ARABIC |
1752 prevlen = 0; | 1752 prevlen = 0; |
1753 #endif | 1753 #endif |
1754 while (len < size) | 1754 while (len < size) |
1755 { | 1755 { |
1756 if (p[len] < 0x80 || !UTF_COMPOSINGLIKE(p + prevlen, p + len)) | 1756 int len_next_char; |
1757 | |
1758 if (p[len] < 0x80) | |
1759 break; | |
1760 | |
1761 /* | |
1762 * Next character length should not go beyond size to ensure that | |
1763 * UTF_COMPOSINGLIKE(...) does not read beyond size. | |
1764 */ | |
1765 len_next_char = utf_ptr2len_len(p + len, size - len); | |
1766 if (len_next_char > size - len) | |
1767 break; | |
1768 | |
1769 if (!UTF_COMPOSINGLIKE(p + prevlen, p + len)) | |
1757 break; | 1770 break; |
1758 | 1771 |
1759 /* Skip over composing char */ | 1772 /* Skip over composing char */ |
1760 #ifdef FEAT_ARABIC | 1773 #ifdef FEAT_ARABIC |
1761 prevlen = len; | 1774 prevlen = len; |
1762 #endif | 1775 #endif |
1763 len += utf_ptr2len_len(p + len, size - len); | 1776 len += len_next_char; |
1764 } | 1777 } |
1765 return len; | 1778 return len; |
1766 } | 1779 } |
1767 | 1780 |
1768 /* | 1781 /* |