comparison src/arabic.c @ 24768:7334bf933510 v8.2.2922

patch 8.2.2922: computing array length is done in various ways Commit: https://github.com/vim/vim/commit/eeec2548785b2dd245a31ab25d7bde0f88ea1a6d Author: K.Takata <kentkt@csc.jp> Date: Wed Jun 2 13:28:16 2021 +0200 patch 8.2.2922: computing array length is done in various ways Problem: Computing array length is done in various ways. Solution: Use ARRAY_LENGTH everywhere. (Ken Takata, closes https://github.com/vim/vim/issues/8305)
author Bram Moolenaar <Bram@vim.org>
date Wed, 02 Jun 2021 13:30:05 +0200
parents 061cf939f7ce
children
comparison
equal deleted inserted replaced
24767:00b56eac455d 24768:7334bf933510
161 {a_FYEH, 0xfbfc, 0xfbfe, 0xfbff, 0xfbfd}, 161 {a_FYEH, 0xfbfc, 0xfbfe, 0xfbff, 0xfbfd},
162 }; 162 };
163 163
164 #define a_BYTE_ORDER_MARK 0xfeff 164 #define a_BYTE_ORDER_MARK 0xfeff
165 165
166 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
167
168 /* 166 /*
169 * Find the struct achar pointer to the given Arabic char. 167 * Find the struct achar pointer to the given Arabic char.
170 * Returns NULL if not found. 168 * Returns NULL if not found.
171 */ 169 */
172 static struct achar * 170 static struct achar *
173 find_achar(int c) 171 find_achar(int c)
174 { 172 {
175 int h, m, l; 173 int h, m, l;
176 174
177 // using binary search to find c 175 // using binary search to find c
178 h = ARRAY_SIZE(achars); 176 h = ARRAY_LENGTH(achars);
179 l = 0; 177 l = 0;
180 while (l < h) 178 while (l < h)
181 { 179 {
182 m = (h + l) / 2; 180 m = (h + l) / 2;
183 if (achars[m].c == (unsigned)c) 181 if (achars[m].c == (unsigned)c)