From owner-svn-src-head@FreeBSD.ORG Mon Jun 21 17:33:50 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65900106566C; Mon, 21 Jun 2010 17:33:50 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 7AB518FC15; Mon, 21 Jun 2010 17:33:49 +0000 (UTC) Received: by vws1 with SMTP id 1so1414271vws.13 for ; Mon, 21 Jun 2010 10:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=/gKx7q8exwy5ISKAIBKQHlPGJkCUPV6m/uRpOOc7Szw=; b=ZBQcvMnyyGvukQEhRU5iqRRQBEdlJ4CyldZ3c9nyDSqjjSZT8s+VP+VKaC8vWgWJ7C oheoHOt3vH3PoDAE5wsX/orYjcMhHeiehD0CGOAlTWGJxFCc6fuoXvcy8jszLFvlV2yk U6SrXZQbyoq32wR/coHXqbwMfFKbofl0ZzOhM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=U9pRp1bSRxkZAt4cKNtVLBSQlrRwAo9oDOWBatouKGv23a+lY2cZcU+ACbBUqttKt9 IfEfXaLTTuchn7vqwv9zCBIpYsz9ppscOGqQppVEvafjLN95+ImXHkvAzBUpLrN+0/V3 +nyw9TcDAxYC0cWGNPu+OsHOkDtcHu/mdhgdU= Received: by 10.224.69.159 with SMTP id z31mr3378931qai.273.1277141628000; Mon, 21 Jun 2010 10:33:48 -0700 (PDT) Received: from kan.dnsalias.net (c-24-63-226-98.hsd1.ma.comcast.net [24.63.226.98]) by mx.google.com with ESMTPS id t34sm48627435qcp.6.2010.06.21.10.33.46 (version=SSLv3 cipher=RC4-MD5); Mon, 21 Jun 2010 10:33:46 -0700 (PDT) Date: Mon, 21 Jun 2010 13:33:40 -0400 From: Alexander Kabaev To: Bruce Evans Message-ID: <20100621133340.7501713b@kan.dnsalias.net> In-Reply-To: <20100622024652.C43995@delplex.bde.org> References: <201006200034.o5K0Y6xl041024@svn.freebsd.org> <20100622024652.C43995@delplex.bde.org> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/QdXti8V3Uvqn36DS029H5JY"; protocol="application/pgp-signature" Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Marcel Moolenaar , src-committers@freebsd.org Subject: Re: svn commit: r209358 - head/cddl/contrib/opensolaris/lib/libdtrace/common X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2010 17:33:50 -0000 --Sig_/QdXti8V3Uvqn36DS029H5JY Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 22 Jun 2010 03:22:40 +1000 (EST) Bruce Evans wrote: > On Sun, 20 Jun 2010, Marcel Moolenaar wrote: >=20 > > Log: > > Unbreak platforms with char unsigned by default. Oddly enough, GCC > > isn't satisfied with a simple cast to int in the check against EOF, > > so the fix is a bit involved by actually having to go through a > > temporary variable. >=20 > Perhaps that is because gcc can see that the cast has no effect, so > the comparison can never be true if `c' is an unsigned char (unless > unsigned char has the same number of bits as signed int), but it > cannot see that the conversion to the temporary variable has the same > null effect. >=20 > > Modified: > > head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- > > head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l > > Sat Jun 19 22:13:40 2010 (r209357) +++ > > head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l > > Sun Jun 20 00:34:06 2010 (r209358) @@ -67,8 +67,12 @@ > > * for all subsequent invocations, which is the effect desired. > > */ > > #undef unput > > -#define unput(c) \ > > - if (c !=3D EOF) yyunput( c, yytext_ptr ) > > +#define unput(c) \ > > + do { \ > > + int _c =3D c; \ > > + if (_c !=3D EOF) \ > > + yyunput(_c, yytext_ptr); \ > > + } while(0) > > #endif > > > > static int id_or_type(const char *); > > >=20 > This remains broken, especially on platforms with chars unsigned. No > one should try to unput EOF, so c should never equal EOF, but if c is > a negative character it may equal EOF and thus >=20 > On platforms with chars unsigned (except exotic ones where chars have > the same size as ints), if c is a char then it is >=3D 0 and thus cannot > equal EOF (which is < 0). Since the platform is non-exotic, (int)c > and "int _c =3D c;" equal c and are this still >=3D 0 and thus cannot > equal EOF. Thus the comparison with EOF has no effect, and c is > always unput. >=20 > On platforms with chars signed, some chars may equal EOF. It is an > error to unput almost any value held in a variable of type char, > since its value might equal EOF and thus be rejected by unput(), but > unput() should be able to handle any character in the character set. >=20 > 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()). >=20 > 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()): >=20 > #define unput(c) yyunput((unsigned char)(c), yytext_ptr) >=20 > This also fixes the missing parantheses for 'c' and some style bugs. >=20 > 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. --=20 Alexander Kabaev --Sig_/QdXti8V3Uvqn36DS029H5JY Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iD8DBQFMH6J4Q6z1jMm+XZYRAggMAJ4qyCWuH+8bQAXQl5sbEEXq09Q2zwCfa7Op NMCDlp149XmRXWob9zGeNts= =ibEu -----END PGP SIGNATURE----- --Sig_/QdXti8V3Uvqn36DS029H5JY--