Mercurial > vim
comparison src/charset.c @ 492:81c06952fb1d
updated for version 7.0135
author | vimboss |
---|---|
date | Tue, 23 Aug 2005 21:00:13 +0000 |
parents | a5fcf36ef512 |
children | 73f10d8124f4 |
comparison
equal
deleted
inserted
replaced
491:21c3634c2113 | 492:81c06952fb1d |
---|---|
1529 return (c >= '0' && c <= '9') | 1529 return (c >= '0' && c <= '9') |
1530 || (c >= 'a' && c <= 'f') | 1530 || (c >= 'a' && c <= 'f') |
1531 || (c >= 'A' && c <= 'F'); | 1531 || (c >= 'A' && c <= 'F'); |
1532 } | 1532 } |
1533 | 1533 |
1534 #if defined(FEAT_MBYTE) || defined(PROTO) | |
1535 /* | |
1536 * Vim's own character class functions. These exist because many library | |
1537 * islower()/toupper() etc. do not work properly: they crash when used with | |
1538 * invalid values or can't handle latin1 when the locale is C. | |
1539 * Speed is most important here. | |
1540 */ | |
1541 #define LATIN1LOWER 'l' | |
1542 #define LATIN1UPPER 'U' | |
1543 | |
1544 /* !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]%_'abcdefghijklmnopqrstuvwxyz{|}~ */ | |
1545 static char_u latin1flags[256] = " UUUUUUUUUUUUUUUUUUUUUUUUUU llllllllllllllllllllllllll UUUUUUUUUUUUUUUUUUUUUUU UUUUUUUllllllllllllllllllllllll llllllll"; | |
1546 static char_u latin1upper[256] = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~"; | |
1547 static char_u latin1lower[256] = " !\"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; | |
1548 | |
1549 int | |
1550 vim_islower(c) | |
1551 int c; | |
1552 { | |
1553 if (c <= '@') | |
1554 return FALSE; | |
1555 if (c >= 0x80) | |
1556 { | |
1557 if (enc_utf8) | |
1558 return utf_islower(c); | |
1559 if (c >= 0x100) | |
1560 { | |
1561 #ifdef HAVE_ISWLOWER | |
1562 if (has_mbyte) | |
1563 return iswlower(c); | |
1564 #endif | |
1565 /* islower() can't handle these chars and may crash */ | |
1566 return FALSE; | |
1567 } | |
1568 if (enc_latin1like) | |
1569 return (latin1flags[c] & LATIN1LOWER) == LATIN1LOWER; | |
1570 } | |
1571 return islower(c); | |
1572 } | |
1573 | |
1574 int | |
1575 vim_isupper(c) | |
1576 int c; | |
1577 { | |
1578 if (c <= '@') | |
1579 return FALSE; | |
1580 if (c >= 0x80) | |
1581 { | |
1582 if (enc_utf8) | |
1583 return utf_isupper(c); | |
1584 if (c >= 0x100) | |
1585 { | |
1586 #ifdef HAVE_ISWUPPER | |
1587 if (has_mbyte) | |
1588 return iswupper(c); | |
1589 #endif | |
1590 /* islower() can't handle these chars and may crash */ | |
1591 return FALSE; | |
1592 } | |
1593 if (enc_latin1like) | |
1594 return (latin1flags[c] & LATIN1UPPER) == LATIN1UPPER; | |
1595 } | |
1596 return isupper(c); | |
1597 } | |
1598 | |
1599 int | |
1600 vim_toupper(c) | |
1601 int c; | |
1602 { | |
1603 if (c <= '@') | |
1604 return c; | |
1605 if (c >= 0x80) | |
1606 { | |
1607 if (enc_utf8) | |
1608 return utf_toupper(c); | |
1609 if (c >= 0x100) | |
1610 { | |
1611 #ifdef HAVE_TOWUPPER | |
1612 if (has_mbyte) | |
1613 return towupper(c); | |
1614 #endif | |
1615 /* toupper() can't handle these chars and may crash */ | |
1616 return c; | |
1617 } | |
1618 if (enc_latin1like) | |
1619 return latin1upper[c]; | |
1620 } | |
1621 return TOUPPER_LOC(c); | |
1622 } | |
1623 | |
1624 int | |
1625 vim_tolower(c) | |
1626 int c; | |
1627 { | |
1628 if (c <= '@') | |
1629 return c; | |
1630 if (c >= 0x80) | |
1631 { | |
1632 if (enc_utf8) | |
1633 return utf_tolower(c); | |
1634 if (c >= 0x100) | |
1635 { | |
1636 #ifdef HAVE_TOWLOWER | |
1637 if (has_mbyte) | |
1638 return towlower(c); | |
1639 #endif | |
1640 /* tolower() can't handle these chars and may crash */ | |
1641 return c; | |
1642 } | |
1643 if (enc_latin1like) | |
1644 return latin1lower[c]; | |
1645 } | |
1646 return TOLOWER_LOC(c); | |
1647 } | |
1648 #endif | |
1649 | |
1534 /* | 1650 /* |
1535 * skiptowhite: skip over text until ' ' or '\t' or NUL. | 1651 * skiptowhite: skip over text until ' ' or '\t' or NUL. |
1536 */ | 1652 */ |
1537 char_u * | 1653 char_u * |
1538 skiptowhite(p) | 1654 skiptowhite(p) |