diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-12-13 11:35:00 -0300 |
---|---|---|
committer | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-12-18 15:41:37 -0300 |
commit | 478c99c128df506479b37d7ffbd1adee3134607f (patch) | |
tree | 2dd6164404d9c476482a976ecd9aed24336ad3ff | |
parent | 2140f8f1f048f9b666915d1788cf8250f9adae62 (diff) | |
download | rneovim-478c99c128df506479b37d7ffbd1adee3134607f.tar.gz rneovim-478c99c128df506479b37d7ffbd1adee3134607f.tar.bz2 rneovim-478c99c128df506479b37d7ffbd1adee3134607f.zip |
Change the signature of utf_convert() (mbyte.c) to use ARRAY_SIZE
-rw-r--r-- | src/nvim/mbyte.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 0edd872047..429fbc7427 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2346,13 +2346,12 @@ static convertStruct foldCase[] = * Return the converted equivalent of "a", which is a UCS-4 character. Use * the given conversion "table". Uses binary search on "table". */ -static int utf_convert(int a, convertStruct *table, int tableSize) +static int utf_convert(int a, convertStruct *table, size_t n_items) { - int start, mid, end; /* indices into table */ - int entries = tableSize / sizeof(convertStruct); + size_t start, mid, end; /* indices into table */ start = 0; - end = entries; + end = n_items; while (start < end) { /* need to search further */ mid = (end + start) / 2; @@ -2361,7 +2360,7 @@ static int utf_convert(int a, convertStruct *table, int tableSize) else end = mid; } - if (start < entries + if (start < n_items && table[start].rangeStart <= a && a <= table[start].rangeEnd && (a - table[start].rangeStart) % table[start].step == 0) @@ -2376,7 +2375,7 @@ static int utf_convert(int a, convertStruct *table, int tableSize) */ int utf_fold(int a) { - return utf_convert(a, foldCase, (int)sizeof(foldCase)); + return utf_convert(a, foldCase, ARRAY_SIZE(foldCase)); } static convertStruct toLower[] = @@ -2702,7 +2701,7 @@ int utf_toupper(int a) return TOUPPER_LOC(a); /* For any other characters use the above mapping table. */ - return utf_convert(a, toUpper, (int)sizeof(toUpper)); + return utf_convert(a, toUpper, ARRAY_SIZE(toUpper)); } bool utf_islower(int a) @@ -2732,7 +2731,7 @@ int utf_tolower(int a) return TOLOWER_LOC(a); /* For any other characters use the above mapping table. */ - return utf_convert(a, toLower, (int)sizeof(toLower)); + return utf_convert(a, toLower, ARRAY_SIZE(toLower)); } bool utf_isupper(int a) |