Inline function definitions for isdigit and isxdigit?
Florian Weimer
fweimer@redhat.com
Thu Sep 15 15:06:00 GMT 2016
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
similar.
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.
Thanks,
Florian
More information about the Libc-alpha
mailing list