From owner-svn-src-all@FreeBSD.ORG Wed May 23 18:44:49 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AA7491065672; Wed, 23 May 2012 18:44:49 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8974F8FC0A; Wed, 23 May 2012 18:44:49 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q4NIintY074336; Wed, 23 May 2012 18:44:49 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q4NIinMS074335; Wed, 23 May 2012 18:44:49 GMT (envelope-from bapt@FreeBSD.org) X-Authentication-Warning: freefall.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f Date: Wed, 23 May 2012 20:44:46 +0200 From: Baptiste Daroussin To: Bruce Evans Message-ID: <20120523184446.GB64580@ithaqua.etoilebsd.net> References: <201205220128.q4M1SXPv081576@svn.freebsd.org> <20120522183847.M1344@besplex.bde.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8GpibOaaTibBMecb" Content-Disposition: inline In-Reply-To: <20120522183847.M1344@besplex.bde.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Garrett Cooper , Kevin Lo , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, svn-src-head@FreeBSD.org Subject: Re: svn commit: r235767 - head/lib/libc/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 May 2012 18:44:49 -0000 --8GpibOaaTibBMecb Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 22, 2012 at 08:51:44PM +1000, Bruce Evans wrote: > On Mon, 21 May 2012, Garrett Cooper wrote: >=20 > > On Mon, May 21, 2012 at 6:28 PM, Kevin Lo wrote: > >> Author: kevlo > >> Date: Tue May 22 01:28:32 2012 > >> New Revision: 235767 > >> URL: http://svn.freebsd.org/changeset/base/235767 > >> > >> Log: > >> =A0Add missing header needed by free() > >> > >> =A0Reported by: =A0tinderbox >=20 > Please don't use binary characters in mail. >=20 > > Thank you for saving my mailbox :)!!! > > > > FWIW, it's weird because my STABLE-9 box didn't reproduce this. >=20 > This seems to be a bug in both nsparser.y and the new yacc: > - new yacc: it is incompatible. >=20 > Old yacc includes stdlib.h and string.h as the first thing in the > generated file, so the C code copied from the .y part sees them too. >=20 > New yacc puts more its code including its all includes (which still > involve stdlib.h) at the end of the generated file. >=20 > Including stdlib.h nearly first is from Lite2 (skeleton.c 1.7 in 1997). > Much later, FreeBSD moved it to the very first thing in the generated > file, so as to use namespace pollution (__unused) from it early. > __unused was ifdefed and was defined by the yacc skeleton if > didn't define it. It took much churn to produce this, but it seems to > have been garbage, since old yacc didn't actually generate any use of > __unused. The definition was apparently compatibilty cruft to hide > unportabilities in .y files that use __unused (I guess these failed for > bootstrapping). New yacc doesn't define __unused. >=20 > - nsparser.y: it uses free() but never declared it. It depended on > namespace pollution in the yacc code, and this pollution being in a > particular order. >=20 > The yyparse() incompatibilities seem to be bugs on both sides too: > - Old yacc didn't declare yyparse() automatically, so .y files had to do > it, but probably shouldn't have. >=20 > - New yacc still doesn't declare yylex() or yyerror() automatically, so > applications still have to declare them. >=20 > - Some of these may be more the responsibility of the yacc library (to > supply defaults) than others. I couldn't see who is required to decla= re > them in POSIX.1-2001. However, a bad example in POSIX.1 has "extern i= nt > yyparse();" in main() just before calling yyparse(). Badness in this > example include several style bugs and the declaration being incomplete > (missing "void"). > Old yacc has about 20 lines of ifdefs half just to supply this "void" > for STDC but not for K&R. New yacc no longer supports K&R, at least > here, but it still has 11 lines of ifdefs to get the declaration of > yyparse() right for bison compatibility). > I don't know if the badness includes having the home made declaration. >=20 > Nearby bugs: all CSRG and FreeBSD changes including copyrights and > history seem to have been lost. Just after the old include of stdlib.h, > skeleton.c used to produce a string yyrcsid[] with __FBSDID() for > skeleton.c itself in it. New yacc generates a string yysccsid with > a hard-coded berkeley 1993 id in it, and the name in this id doesn't > even match the file name (it is "yaccpar"). Another FreeBSD change was > to remove this bogus id from the generated file. >=20 > Some relevant FreeBSD changes: >=20 > % Index: skeleton.c > % =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 > % RCS file: /home/ncvs/src/usr.bin/yacc/skeleton.c,v > % retrieving revision 1.1.1.2 > % retrieving revision 1.37 > % diff -u -2 -r1.1.1.2 -r1.37 > % --- skeleton.c 6 Jan 1997 03:03:46 -0000 1.1.1.2 > % +++ skeleton.c 12 Feb 2003 18:03:55 -0000 1.37 > % @@ -35,7 +35,12 @@ > % */ > %=20 > % +#if 0 > % #ifndef lint > % static char sccsid[] =3D "@(#)skeleton.c 5.8 (Berkeley) 4/29/95"; > % -#endif /* not lint */ > % +#endif > % +#endif >=20 > FreeBSD normally comments out vendor ids like this. 5.8 is from Lite2; > Lite1 had 5.7. New yacc doesn't have any of this. It apparently started > from older yacc (before Lite1; indeed, it agrees with the FreeBSD-1 =3D= =3D Net/2 > version in not having any CSRG copyrights or this sccsid). >=20 > % + > % +#include > % +__FBSDID("$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.37 2003/02/12 18:0= 3:55 davidc Exp $"); >=20 > FreeBSD normally adds this to source files. Except in contrib. yacc is > now mostly in contrib, although it hasn't changed all that much. >=20 > %=20 > % #include "defs.h" > % @@ -53,31 +58,42 @@ > % /* are conditional. */ > %=20 > % -char *banner[] =3D > % +const char *banner[] =3D >=20 > New yacc has this change too. >=20 > % { > % + "#include ", >=20 > See above. >=20 > % "#ifndef lint", > % - "static char yysccsid[] =3D \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\= ";", >=20 > Was in Net/2 (?), FreeBSD-1, Lite1 and Lite2. Came back with new yacc. > It's interesting that "yaccpar 1.9 (Berkeley) 1.9 02/21/93" is only 3 mon= ths > before the correct id "skeleton.c 5.7 (Berkeley) 5/24/93". >=20 > Hmm, the FreeBSD-1 history is even more instructive than I first > thought. FreeBSD-1 started with the CSRG version of skeleton.c on > 1993/06/12. This had CSRG copyrights and ids, and yaccpar was at 1.8 > 01/20/90. But this was upgraded to "the newest version on > vangogh.cs.berkeley.edu" 17 days later on 1993/06/29. This version > has no CSRG copyrights or ids, except for the above rotted one for > yaccpar (the 1.9 02/21/93 one). I think it was only missing CSRG > copyrights and ids because CSRG only added these to full releases. > This resulted in the version in FreeBSD-1 not having any copyright > notices inside most files, and none for the directory either. The > new byacc seems to be the same as the older yacc here too. >=20 > % + "#ifdef __unused", > % + "__unused", > % + "#endif", > % + "static char const ", > % + "yyrcsid[] =3D \"$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.37 2003= /02/12 18:03:55 davidc Exp $\";", > % "#endif", > % - "#include ", >=20 > See above. >=20 > % "#define YYBYACC 1", > % "#define YYMAJOR 1", > % "#define YYMINOR 9", > % - "#define yyclearin (yychar=3D(-1))", > % + "#define YYLEX yylex()", > % + "#define YYEMPTY -1", > % + "#define yyclearin (yychar=3D(YYEMPTY))", > % "#define yyerrok (yyerrflag=3D0)", > % - "#define YYRECOVERING (yyerrflag!=3D0)", > % + "#define YYRECOVERING() (yyerrflag!=3D0)", > % + "#if defined(__cplusplus) || __STDC__", > % + "static int yygrowstack(void);", > % + "#else", > % + "static int yygrowstack();", > % + "#endif", >=20 > % 0 > % }; >=20 > Hrmph. It was FreeBSD that added the STDC ifdefs, to avoid breaking > support for generating K&R code (older yacc generated fairly pure K&R > code without even "const"). For yygrowstack(), this was sloppy: > it only changed the declaration -- the function body still doesn't > say "void". >=20 > % @@ -151,13 +174,35 @@ > % "#define YYACCEPT goto yyaccept", > % "#define YYERROR goto yyerrlab", > % + "", > % + "#ifndef YYPARSE_PARAM", > % + "#if defined(__cplusplus) || __STDC__", > % + "#define YYPARSE_PARAM_ARG void", > % + "#define YYPARSE_PARAM_DECL", > % + "#else /* ! ANSI-C/C++ */", > % + "#define YYPARSE_PARAM_ARG", > % + "#define YYPARSE_PARAM_DECL", > % + "#endif /* ANSI-C/C++ */", > % + "#else /* YYPARSE_PARAM */", > % + "#ifndef YYPARSE_PARAM_TYPE", > % + "#define YYPARSE_PARAM_TYPE void *", > % + "#endif", > % + "#if defined(__cplusplus) || __STDC__", > % + "#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM", > % + "#define YYPARSE_PARAM_DECL", > % + "#else /* ! ANSI-C/C++ */", > % + "#define YYPARSE_PARAM_ARG YYPARSE_PARAM", > % + "#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;", > % + "#endif /* ANSI-C/C++ */", > % + "#endif /* ! YYPARSE_PARAM */", > % + "", > % "int", > % - "yyparse()", > % + "yyparse (YYPARSE_PARAM_ARG)", > % + " YYPARSE_PARAM_DECL", > % "{", > % - " register int yym, yyn, yystate;", > % + " int yym, yyn, yystate;", > % "#if YYDEBUG", > % - " register char *yys;", > % - " extern char *getenv();", > % + " const char *yys;", > % "", > % - " if (yys =3D getenv(\"YYDEBUG\"))", > % + " if ((yys =3D getenv(\"YYDEBUG\")))", > % " {", > % " yyn =3D *yys;", >=20 > The STDC support was especially messy for yyparse(). >=20 > Bruce Thanks for all the remarks, I'll try to fix all issues you have spotted as = soon as possible. regards, Bapt --8GpibOaaTibBMecb Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAk+9MB4ACgkQ8kTtMUmk6EyaMQCfeORSrtD3jcxwMhR2k1aJKqk0 8G8AniPcgzyUC3EuuVCNbqTY6glMNE1l =7Z87 -----END PGP SIGNATURE----- --8GpibOaaTibBMecb--