comparison src/charset.c @ 39:410fa1a31baf v7.0023

updated for version 7.0023
author vimboss
date Sun, 19 Dec 2004 22:46:22 +0000
parents 3ba373b54370
children f1d2a58883b9
comparison
equal deleted inserted replaced
38:c524f99c7925 39:410fa1a31baf
817 char_u *s; 817 char_u *s;
818 818
819 for (s = p; *s != NUL && (len == MAXCOL || s < p + len); ) 819 for (s = p; *s != NUL && (len == MAXCOL || s < p + len); )
820 { 820 {
821 col += win_lbr_chartabsize(wp, s, col, NULL); 821 col += win_lbr_chartabsize(wp, s, col, NULL);
822 #ifdef FEAT_MBYTE 822 mb_ptr_adv(s);
823 if (has_mbyte)
824 s += (*mb_ptr2len_check)(s);
825 else
826 #endif
827 ++s;
828 } 823 }
829 return (int)col; 824 return (int)col;
830 } 825 }
831 826
832 /* 827 /*
965 colnr_T col; 960 colnr_T col;
966 { 961 {
967 int retval; 962 int retval;
968 963
969 retval = lbr_chartabsize(*s, col); 964 retval = lbr_chartabsize(*s, col);
970 #ifdef FEAT_MBYTE 965 mb_ptr_adv(*s);
971 if (has_mbyte)
972 *s += (*mb_ptr2len_check)(*s);
973 else
974 #endif
975 ++*s;
976 return retval; 966 return retval;
977 } 967 }
978 968
979 /* 969 /*
980 * This function is used very often, keep it fast!!!! 970 * This function is used very often, keep it fast!!!!
1052 / (colmax + win_col_off2(wp))) + 1) 1042 / (colmax + win_col_off2(wp))) + 1)
1053 * (colmax + win_col_off2(wp)); 1043 * (colmax + win_col_off2(wp));
1054 for (;;) 1044 for (;;)
1055 { 1045 {
1056 ps = s; 1046 ps = s;
1057 # ifdef FEAT_MBYTE 1047 mb_ptr_adv(s);
1058 if (has_mbyte)
1059 s += (*mb_ptr2len_check)(s);
1060 else
1061 # endif
1062 ++s;
1063 c = *s; 1048 c = *s;
1064 if (!(c != NUL 1049 if (!(c != NUL
1065 && (vim_isbreak(c) 1050 && (vim_isbreak(c)
1066 || (!vim_isbreak(c) 1051 || (!vim_isbreak(c)
1067 && (col2 == col || !vim_isbreak(*ps)))))) 1052 && (col2 == col || !vim_isbreak(*ps))))))
1261 1246
1262 if (ptr >= posptr) /* character at pos->col */ 1247 if (ptr >= posptr) /* character at pos->col */
1263 break; 1248 break;
1264 1249
1265 vcol += incr; 1250 vcol += incr;
1266 #ifdef FEAT_MBYTE 1251 mb_ptr_adv(ptr);
1267 if (has_mbyte)
1268 ptr += (*mb_ptr2len_check)(ptr);
1269 else
1270 #endif
1271 ++ptr;
1272 } 1252 }
1273 } 1253 }
1274 else 1254 else
1275 { 1255 {
1276 for (;;) 1256 for (;;)
1287 1267
1288 if (ptr >= posptr) /* character at pos->col */ 1268 if (ptr >= posptr) /* character at pos->col */
1289 break; 1269 break;
1290 1270
1291 vcol += incr; 1271 vcol += incr;
1292 #ifdef FEAT_MBYTE 1272 mb_ptr_adv(ptr);
1293 if (has_mbyte)
1294 ptr += (*mb_ptr2len_check)(ptr);
1295 else
1296 #endif
1297 ++ptr;
1298 } 1273 }
1299 } 1274 }
1300 if (start != NULL) 1275 if (start != NULL)
1301 *start = vcol + head; 1276 *start = vcol + head;
1302 if (end != NULL) 1277 if (end != NULL)
1569 { 1544 {
1570 char_u *ptr = start; 1545 char_u *ptr = start;
1571 int hex = 0; /* default is decimal */ 1546 int hex = 0; /* default is decimal */
1572 int negative = FALSE; 1547 int negative = FALSE;
1573 unsigned long un = 0; 1548 unsigned long un = 0;
1549 int n;
1574 1550
1575 if (ptr[0] == '-') 1551 if (ptr[0] == '-')
1576 { 1552 {
1577 negative = TRUE; 1553 negative = TRUE;
1578 ++ptr; 1554 ++ptr;
1579 } 1555 }
1580 1556
1581 if (ptr[0] == '0') /* could be hex or octal */ 1557 /* Recognize hex and octal. */
1558 if (ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9')
1582 { 1559 {
1583 hex = ptr[1]; 1560 hex = ptr[1];
1584 if (dohex && (hex == 'X' || hex == 'x') && vim_isxdigit(ptr[2])) 1561 if (dohex && (hex == 'X' || hex == 'x') && vim_isxdigit(ptr[2]))
1585 ptr += 2; /* hexadecimal */ 1562 ptr += 2; /* hexadecimal */
1586 else 1563 else
1587 { 1564 {
1588 if (dooct && VIM_ISDIGIT(hex)) 1565 hex = 0; /* default is decimal */
1589 hex = '0'; /* octal */ 1566 if (dooct)
1590 else 1567 {
1591 hex = 0; /* 0 by itself is decimal */ 1568 /* Don't interpret "0", "08" or "0129" as octal. */
1569 for (n = 1; VIM_ISDIGIT(ptr[n]); ++n)
1570 {
1571 if (ptr[n] > '7')
1572 {
1573 hex = 0; /* can't be octal */
1574 break;
1575 }
1576 if (ptr[n] > '0')
1577 hex = '0'; /* assume octal */
1578 }
1579 }
1592 } 1580 }
1593 } 1581 }
1594 1582
1595 /* 1583 /*
1596 * Do the string-to-numeric conversion "manually" to avoid sscanf quirks. 1584 * Do the string-to-numeric conversion "manually" to avoid sscanf quirks.