This is the mail archive of the
mailing list for the glibc project.
Inline function definitions for isdigit and isxdigit?
- From: Florian Weimer <fweimer at redhat dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 15 Sep 2016 17:06:10 +0200
- Subject: Inline function definitions for isdigit and isxdigit?
- Authentication-results: sourceware.org; auth=none
Can we provide inline definitions for isdigit and xdigit?
POSIX says (for the digit character class):
In a locale definition file, only the digits <zero>, <one>, <two>,
<three>, <four>, <five>, <six>, <seven>, <eight>, and <nine> shall be
specified, and in contiguous ascending sequence by numerical value. The
digits <zero> to <nine> of the portable character set are automatically
included in this class.
This means it's fixed to '0' .. '9' for our purposes (our locales must
be ASCII-transparent at least as far as the digits are concerned).
For xdigit, one can have more than two sequences of 'A' .. 'F' letters:
In a locale definition file, only the characters defined for the class
digit shall be specified, in contiguous ascending sequence by numerical
value, followed by one or more sets of six characters representing the
hexadecimal digits 10 to 15 inclusive, with each set in ascending order
(for example, <A>, <B>, <C>, <D>, <E>, <F>, <a>, <b>, <c>, <d>, <e>, <f>).
But I wonder how useful this is in practice. One might be tempted to
define FULLWIDTH LATIN SMALL LETTER A (U+FF41) as a hexadecimal digit.
But this does not make much sense because FULLWIDTH DIGIT ZERO (U+FF10)
and the other double-width digits cannot be defined as hexadecimal
digits. I wonder if all reasonable extension candidates for xdigit are
Even for isxdigit, an inline definition would result in a shorter
machine code sequence than the current implementation (maybe not if the
result of the call to __ctype_b_loc can be reused). For isdigit, the
case is even clearer, even with a shared __ctype_b_loc value.