cvs commit: src/lib/libc/regex regex2.h

Tim Robbins tjr at
Sat Aug 13 14:37:54 GMT 2005

Andrey Chernov wrote:

>On Sat, Aug 13, 2005 at 02:30:16AM +0000, Tim J. Robbins wrote:
>>tjr         2005-08-13 02:30:16 UTC
>>  FreeBSD src repository
>>  Modified files:
>>    lib/libc/regex       regex2.h 
>>  Log:
>>  Change OUT from -2 to CHAR_MIN-1, making it impossible for it to
>>  inadvertently match a negative char in the RE being compiled.
>It seems this commit may mask the bug where signed comparison used.
>Better fix perhaps to make compared char unsigned in all places, i.e.
>	if (-2 == (unsigned char)'\254')
For whatever reason, the "stop" argument to p_ere() and the "stop1" and 
"stop2" arguments to p_bre() are signed chars cast to int, not unsigned 
chars cast to int, so OUT needs to be outside the valid range of char, 
not unsigned char. This is somewhat unconventional, but I don't think 
the new value of CHAR_MIN-1 is any worse than the pre- rev. 1.8 value of 
CHAR_MAX+1. The choice of -2 in rev. 1.8 was a mistake on my part caused 
by not realising that characters were being passed around as signed 
chars cast to int.


More information about the cvs-src mailing list