Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jun 2010 04:30:12 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Alexander Kabaev <kabaev@gmail.com>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, Marcel Moolenaar <marcel@freebsd.org>, src-committers@freebsd.org, Bruce Evans <brde@optusnet.com.au>
Subject:   Re: svn commit: r209358 - head/cddl/contrib/opensolaris/lib/libdtrace/common
Message-ID:  <20100622041935.J44301@delplex.bde.org>
In-Reply-To: <20100621133340.7501713b@kan.dnsalias.net>
References:  <201006200034.o5K0Y6xl041024@svn.freebsd.org> <20100622024652.C43995@delplex.bde.org> <20100621133340.7501713b@kan.dnsalias.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 21 Jun 2010, Alexander Kabaev wrote:

> On Tue, 22 Jun 2010 03:22:40 +1000 (EST)
> Bruce Evans <brde@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100622041935.J44301>