[jit] Use ISALPHA and ISALNUM rather than writing our own

Jeff Law law@redhat.com
Wed Jan 1 00:00:00 GMT 2014


On 11/05/14 08:48, David Malcolm wrote:
> On Tue, 2014-11-04 at 14:39 -0700, Jeff Law wrote:
>> On 11/04/14 09:57, David Malcolm wrote:
>>>>> +#define IS_ASCII_DIGIT(CHAR) \
>>>>> +  ((CHAR) >= '0' && (CHAR) <='9')
>>>>> +
>>>>> +#define IS_ASCII_ALNUM(CHAR) \
>>>>> +  (IS_ASCII_ALPHA (CHAR) || IS_ASCII_DIGIT (CHAR))
>>>> Can't we rely on the C library to give us equivalents?
>>>
>>> I've been burned in the past by the C library using locales, in
>>> particular the two lowercase "i" variants in Turkish.
>>>
>>> These macros are used by gcc_jit_context_new_function to enforce C's
>>> naming restrictions, to avoid errors from the assembler.  The comment I
>>> put there was:
>>>
>>>     /* The assembler can only handle certain names, so for now, enforce
>>>        C's rules for identifiers upon the name.
>>>        Eventually we'll need some way to interact with e.g. C++ name mangling.  */
>>>
>>> Am I right in thinking that for the assembler we need to enforce the C
>>> naming rules specifically on *ASCII*.
>>>
>>> (clearly another comment is needed here).
>> I guess you've got to do it somewhere.  Presumably there isn't something
>> already in GCC that enforces an input character set?  I guess I just
>> dislike seeing something that feels like it ought to already be available.
>
> It turns out that locale-independent tests for this did already exist in
> libiberty, in safe-ctype.h, so I've committed this to the jit branch:
>
> gcc/jit/ChangeLog.jit:
> 	* libgccjit.c: Include safe-ctype.h from libiberty.
> 	(IS_ASCII_ALPHA): Delete.
> 	(IS_ASCII_DIGIT): Delete.
> 	(IS_ASCII_ALNUM): Delete.
> 	(gcc_jit_context_new_function): Replace use of IS_ASCII_ALPHA and
> 	IS_ASCII_ALNUM with ISALPHA and ISALNUM respectively, from
> 	libiberty.
Excellent.  Thanks for the cleanup.

Jeff



More information about the Jit mailing list