On 12/14/16 11:23, Henri Verbeet wrote:
On 13 December 2016 at 19:48, Lauri Kenttä <lauri.kentta(a)gmail.com> wrote:
@@ -2027,6 +2027,19 @@ static int wctoint(WCHAR c, int base) v = c - 'A' + 10; else if ('a' <= c && c <= 'z') v = c - 'a' + 10; + else { + /* Unicode points that contain digits 0-9; keep this sorted! */ + static const WCHAR zeros[] = { + 0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6, + 0xd66, 0xe50, 0xed0, 0x1040, 0x17e0, 0x1810, 0xff10 + }; + int i; + for (i = 0; i < sizeof(zeros)/sizeof(zeros[0]) && c >= zeros[i]; ++i) { + if (zeros[i] <= c && c < zeros[i] + base) { Using "base" here seems questionable. That would imply that e.g. with base 16, "\x6f2\x6fa"/"۲ۺ" would return "42". Is that really the case? That's why I have asked for a test that shows the problem.