svn commit: r209358 - head/cddl/contrib/opensolaris/lib/libdtrace/common

Bruce Evans brde at optusnet.com.au
Mon Jun 21 18:30:15 UTC 2010


On Mon, 21 Jun 2010, Alexander Kabaev wrote:

> On Tue, 22 Jun 2010 03:22:40 +1000 (EST)
> Bruce Evans <brde at optusnet.com.au> wrote:
>
>> On Sun, 20 Jun 2010, Marcel Moolenaar wrote:
>>> ...
>>> #undef  unput
>>> -#define unput(c) \
>>> -	if (c != EOF) yyunput( c, yytext_ptr )
>>> +#define unput(c)					\
>>> +	do {						\
>>> +		int _c = c;				\
>>> +		if (_c != EOF)				\
>>> +			yyunput(_c, yytext_ptr);	\
>>> +	} while(0)
>>> #endif

>> ...
>> This problem is handled by ungetc() by always converting the value to
>> unsigned char.  Thus the value can never equal EOF, and the character
>> set is effectively represented by unsigned char's, not the plain chars
>> that stdio returns in some other interfaces (but not getc()).
>>
>> There seems to be no reason to break the warning about this instead of
>> using the same approach as stdio.  This depends on yyunput() not
>> having similar bugs (it must take an arg of type int and convert to
>> an unsigned cgar like ungetc()):
>>
>> #define	unput(c)	yyunput((unsigned char)(c), yytext_ptr)
>>
>> This also fixes the missing parantheses for 'c' and some style bugs.
>>
>> Bruce
>
> DTrace _does_ try to unput EOF though and apparently gets away with it
> on Solaris, so while yor version is correct, it is also useless.

Do you mean that it tries to unput EOF as an int (not obtained from a
char), and that that must fail and not unput ((unsigned char)EOF)?  Then
the current version is still broken on platforms with chars signed,
since when it tries to unput a char with value EOF, that will fail
and not unput ((unsigned char)<char's value>).

Bruce


More information about the svn-src-head mailing list