Mercurial > vim
diff src/mbyte.c @ 500:4772a5e3f9fa v7.0138
updated for version 7.0138
author | vimboss |
---|---|
date | Mon, 29 Aug 2005 22:25:38 +0000 |
parents | 81c06952fb1d |
children | ce2181d14aa0 |
line wrap: on
line diff
--- a/src/mbyte.c +++ b/src/mbyte.c @@ -2706,17 +2706,37 @@ mb_prevptr(line, p) mb_charlen(str) char_u *str; { - int count; - - if (str == NULL) + char_u *p = str; + int count; + + if (p == NULL) return 0; - for (count = 0; *str != NUL; count++) - str += (*mb_ptr2len)(str); + for (count = 0; *p != NUL; count++) + p += (*mb_ptr2len)(p); return count; } +#if defined(FEAT_SYN_HL) || defined(PROTO) +/* + * Like mb_charlen() but for a string with specified length. + */ + int +mb_charlen_len(str, len) + char_u *str; + int len; +{ + char_u *p = str; + int count; + + for (count = 0; *p != NUL && p < str + len; count++) + p += (*mb_ptr2len)(p); + + return count; +} +#endif + /* * Try to un-escape a multi-byte character. * Used for the "to" and "from" part of a mapping.