From nobody@FreeBSD.org  Thu Nov  5 12:46:36 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F3D2610656BE
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Nov 2009 12:46:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5F9248FC20
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Nov 2009 12:46:35 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nA5CkYg7093814
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 5 Nov 2009 12:46:34 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id nA5CkYtl093813;
	Thu, 5 Nov 2009 12:46:34 GMT
	(envelope-from nobody)
Message-Id: <200911051246.nA5CkYtl093813@www.freebsd.org>
Date: Thu, 5 Nov 2009 12:46:34 GMT
From: Philippe Pepiot <ksh@philpep.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bad syntax cause yacc segfault
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         140309
>Category:       bin
>Synopsis:       [patch] bad syntax causes yacc(1) segfault
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bapt
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 05 12:50:02 UTC 2009
>Closed-Date:    
>Last-Modified:  Mon May 21 13:40:02 UTC 2012
>Originator:     Philippe Pepiot
>Release:        9.0 CURRENT
>Organization:
>Environment:
FreeBSD shen.philpep.org 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Wed Nov  4 19:56:02 CET 2009     root@shen.philpep.org:/usr/src/sys/i386/compile/SHEN  i386
>Description:
Sometimes yacc segfault when declare typed rule and you don't set a
value to $$ in the grammar rule.

The expected behavior of yacc in this case is to print an error message
like "the value of typed rule hasn't been set".

Here's backtrace :

#0  0x08053811 in end_rule () at /usr/src/usr.bin/yacc/reader.c:1260
1260            if (pitem[i+1] == 0 || pitem[i+1]->tag != plhs[nrules]->tag)


#0  0x08053811 in end_rule () at /usr/src/usr.bin/yacc/reader.c:1260
#1  0x0805486d in read_grammar () at /usr/src/usr.bin/yacc/reader.c:1632
#2  0x08055591 in reader () at /usr/src/usr.bin/yacc/reader.c:1926
#3  0x0804c4b4 in main (argc=2, argv=0xbfbfeb48) at /usr/src/usr.bin/yacc/main.c:434
>How-To-Repeat:
Just yacc this file :

%type <int> rule
%%
rule:
    ;
%%


$ yacc file.y
segmentation fault (core dumped) /usr/bin/yacc
>Fix:


>Release-Note:
>Audit-Trail:

From: Alexey Shuvaev <shuvaev@physik.uni-wuerzburg.de>
To: bug-followup@FreeBSD.org, ksh@philpep.org
Cc:  
Subject: Re: bin/140309: bad syntax cause yacc(1) segfault
Date: Sun, 8 Nov 2009 19:41:36 +0100

 Confirmed on amd64:
 ~> uname -a
 FreeBSD wep4035 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r198671: Fri Oct 30 16:12:10 CET 2009     root@wep4035:/usr/obj/usr/src/sys/GENERIC  amd64
 
 ~> yacc test.y 
 Bus error (core dumped)
 
 ~> cat test.y 
 %type <int> rule
 %%
 rule:
 ;
 %%
 
 Alexey.

From: Alexander Best <alexbestms@wwu.de>
To: <bug-followup@FreeBSD.org>,
 <ksh@philpep.org>
Cc:  
Subject: Re: bin/140309: bad syntax cause yacc(1) segfault
Date: Wed, 11 Nov 2009 15:42:26 +0100 (CET)

 running FreeBSD otaku 9.0-CURRENT FreeBSD 9.0-CURRENT #1 r199160M: Wed Nov 11
 00:33:45 CET 2009     root@otaku:/usr/obj/usr/src/sys/ARUNDEL  i386 i get the
 following yacc output:
 
 yacc: w - line 5 of "test.y", the default action assigns an undefined value to
 $$
 
 `cat test.y':
 %type <int> rule
 %%
 rule:
 ;
 %%
 
 cheers.
 alex

From: Alexander Best <alexbestms@wwu.de>
To: <bug-followup@FreeBSD.org>
Cc:  
Subject: Re: bin/140309: bad syntax cause yacc(1) segfault
Date: Sun, 07 Feb 2010 02:25:13 +0100 (CET)

 please disregard my previous post. this issue is still reproducable under
 
 FreeBSD otaku 9.0-CURRENT FreeBSD 9.0-CURRENT #13 r203556M: Sun Feb  7
 01:57:31 CET 2010     root@otaku:/usr/obj/usr/src/sys/ARUNDEL  amd64
 
 alex

From: Alexander Best <alexbestms@uni-muenster.de>
To: bug-followup@FreeBSD.org
Cc: Philippe Pepiot <ksh@philpep.org>, Alexey Shuvaev <shuvaev@physik.uni-wuerzburg.de>
Subject: Re: bin/140309: bad syntax cause yacc(1) segfault
Date: Tue, 15 Jun 2010 13:14:26 +0200

 --0016e64bb79059869304890fb5a3
 Content-Type: text/plain; charset=ISO-8859-1
 
 the following patch should fix the problem. it was imported from the
 latest vendor version (2010-06-10) of byacc into our ancient K&R byacc
 version dated 1993.
 
 it might be a good idea to add the example file.y from this pr as a
 regression test under tools/regression/usr.bin/yacc.
 
 cheers.
 alex
 
 -- 
 Alexander Best
 
 --0016e64bb79059869304890fb5a3
 Content-Type: text/plain; charset=US-ASCII; name="yacc.diff.txt"
 Content-Disposition: attachment; filename="yacc.diff.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_gagmwb5j0
 
 SW5kZXg6IHVzci5iaW4veWFjYy9yZWFkZXIuYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSB1c3IuYmluL3lhY2Mv
 cmVhZGVyLmMJKHJldmlzaW9uIDIwOTE0MCkKKysrIHVzci5iaW4veWFjYy9yZWFkZXIuYwkod29y
 a2luZyBjb3B5KQpAQCAtMTI1Niw5ICsxMjU2LDEyIEBACiAKICAgICBpZiAoIWxhc3Rfd2FzX2Fj
 dGlvbiAmJiBwbGhzW25ydWxlc10tPnRhZykKICAgICB7Ci0JZm9yIChpID0gbml0ZW1zIC0gMTsg
 cGl0ZW1baV07IC0taSkgY29udGludWU7Ci0JaWYgKHBpdGVtW2krMV0gPT0gMCB8fCBwaXRlbVtp
 KzFdLT50YWcgIT0gcGxoc1tucnVsZXNdLT50YWcpCi0JICAgIGRlZmF1bHRfYWN0aW9uX3dhcm5p
 bmcoKTsKKwlpZiAocGl0ZW1bbml0ZW1zIC0gMV0pCisJeworCSAgICBmb3IgKGkgPSBuaXRlbXMg
 LSAxOyAoaSA+IDApICYmIHBpdGVtW2ldOyAtLWkpIGNvbnRpbnVlOworCSAgICBpZiAocGl0ZW1b
 aSsxXSA9PSAwIHx8IHBpdGVtW2krMV0tPnRhZyAhPSBwbGhzW25ydWxlc10tPnRhZykKKwkJZGVm
 YXVsdF9hY3Rpb25fd2FybmluZygpOworCX0KICAgICB9CiAKICAgICBsYXN0X3dhc19hY3Rpb24g
 PSAwOwo=
 --0016e64bb79059869304890fb5a3--
State-Changed-From-To: open->analyzed 
State-Changed-By: brd 
State-Changed-When: Wed Jun 16 13:51:50 UTC 2010 
State-Changed-Why:  
Update state per Alexander. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140309 
Responsible-Changed-From-To: freebsd-bugs->bapt 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sat Jan 21 20:56:29 UTC 2012 
Responsible-Changed-Why:  
please don't hate me 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140309 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/140309: commit references a PR
Date: Mon, 21 May 2012 13:32:11 +0000 (UTC)

 Author: bapt
 Date: Mon May 21 13:31:26 2012
 New Revision: 235723
 URL: http://svn.freebsd.org/changeset/base/235723
 
 Log:
   Import byacc from invisible island, it brings us lots of compatibilities with
   bison, keeping full compatibility with our previous yacc implementation.
   
   Also bring the ability to create reentrant parser
   
   This fix bin/140309 [1]
   
   PR:		bin/140309 [1]
   Submitted by:	Philippe Pepiot <ksh@philpep.org> [1]
   Approved by:	des (mentor)
   MFC after:	1 month
 
 Added:
   head/contrib/byacc/
      - copied from r235040, vendor/byacc/dist/
   head/tools/regression/usr.bin/yacc/
   head/tools/regression/usr.bin/yacc/Makefile   (contents, props changed)
   head/tools/regression/usr.bin/yacc/calc.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/calc1.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/calc2.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/calc3.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/code_calc.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/code_error.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/error.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/ftp.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/grammar.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/pure_calc.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/pure_error.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/quote_calc.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/quote_calc2.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/quote_calc3.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/quote_calc4.y   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.00.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.01.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.02.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.03.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.04.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.05.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.06.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.07.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.08.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.09.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.10.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.11.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.12.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.13.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.14.out   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.sh   (contents, props changed)
   head/tools/regression/usr.bin/yacc/regress.t   (contents, props changed)
   head/tools/regression/usr.bin/yacc/undefined.y   (contents, props changed)
 Deleted:
   head/usr.bin/yacc/ACKNOWLEDGEMENTS
   head/usr.bin/yacc/NEW_FEATURES
   head/usr.bin/yacc/NOTES
   head/usr.bin/yacc/README
   head/usr.bin/yacc/closure.c
   head/usr.bin/yacc/defs.h
   head/usr.bin/yacc/error.c
   head/usr.bin/yacc/lalr.c
   head/usr.bin/yacc/lr0.c
   head/usr.bin/yacc/main.c
   head/usr.bin/yacc/mkpar.c
   head/usr.bin/yacc/output.c
   head/usr.bin/yacc/reader.c
   head/usr.bin/yacc/skeleton.c
   head/usr.bin/yacc/symtab.c
   head/usr.bin/yacc/test/
   head/usr.bin/yacc/verbose.c
   head/usr.bin/yacc/warshall.c
   head/usr.bin/yacc/yacc.1
   head/usr.bin/yacc/yyfix.1
   head/usr.bin/yacc/yyfix.sh
 Modified:
   head/contrib/byacc/defs.h
   head/contrib/byacc/main.c
   head/contrib/byacc/reader.c
   head/usr.bin/yacc/Makefile
 
 Modified: head/contrib/byacc/defs.h
 ==============================================================================
 --- vendor/byacc/dist/defs.h	Fri May  4 22:54:54 2012	(r235040)
 +++ head/contrib/byacc/defs.h	Mon May 21 13:31:26 2012	(r235723)
 @@ -241,7 +241,6 @@ extern char *line;
  extern int lineno;
  extern int outline;
  extern int exit_code;
 -extern int pure_parser;
  
  extern const char *const banner[];
  extern const char *const xdecls[];
 
 Modified: head/contrib/byacc/main.c
 ==============================================================================
 --- vendor/byacc/dist/main.c	Fri May  4 22:54:54 2012	(r235040)
 +++ head/contrib/byacc/main.c	Mon May 21 13:31:26 2012	(r235723)
 @@ -163,7 +163,7 @@ done(int k)
  }
  
  static void
 -onintr(int sig GCC_UNUSED)
 +onintr(__unused int sig)
  {
      got_intr = 1;
      done(EXIT_FAILURE);
 
 Modified: head/contrib/byacc/reader.c
 ==============================================================================
 --- vendor/byacc/dist/reader.c	Fri May  4 22:54:54 2012	(r235040)
 +++ head/contrib/byacc/reader.c	Mon May 21 13:31:26 2012	(r235723)
 @@ -338,6 +338,7 @@ keyword(void)
      }
      syntax_error(lineno, line, t_cptr);
      /*NOTREACHED */
 +    return (-1);
  }
  
  static void
 @@ -1781,6 +1782,8 @@ mark_symbol(void)
      int c;
      bucket *bp;
  
 +    bp = NULL;
 +
      c = cptr[1];
      if (c == '%' || c == '\\')
      {
 
 Added: head/tools/regression/usr.bin/yacc/Makefile
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/Makefile	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,4 @@
 +# $FreeBSD$
 +
 +all:
 +	@m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
 
 Added: head/tools/regression/usr.bin/yacc/calc.y
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/calc.y	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,106 @@
 +%{
 +# include <stdio.h>
 +# include <ctype.h>
 +
 +int regs[26];
 +int base;
 +
 +extern int yylex(void);
 +static void yyerror(const char *s);
 +
 +%}
 +
 +%start list
 +
 +%token DIGIT LETTER
 +
 +%left '|'
 +%left '&'
 +%left '+' '-'
 +%left '*' '/' '%'
 +%left UMINUS   /* supplies precedence for unary minus */
 +
 +%% /* beginning of rules section */
 +
 +list  :  /* empty */
 +      |  list stat '\n'
 +      |  list error '\n'
 +            {  yyerrok ; }
 +      ;
 +
 +stat  :  expr
 +            {  printf("%d\n",$1);}
 +      |  LETTER '=' expr
 +            {  regs[$1] = $3; }
 +      ;
 +
 +expr  :  '(' expr ')'
 +            {  $$ = $2; }
 +      |  expr '+' expr
 +            {  $$ = $1 + $3; }
 +      |  expr '-' expr
 +            {  $$ = $1 - $3; }
 +      |  expr '*' expr
 +            {  $$ = $1 * $3; }
 +      |  expr '/' expr
 +            {  $$ = $1 / $3; }
 +      |  expr '%' expr
 +            {  $$ = $1 % $3; }
 +      |  expr '&' expr
 +            {  $$ = $1 & $3; }
 +      |  expr '|' expr
 +            {  $$ = $1 | $3; }
 +      |  '-' expr %prec UMINUS
 +            {  $$ = - $2; }
 +      |  LETTER
 +            {  $$ = regs[$1]; }
 +      |  number
 +      ;
 +
 +number:  DIGIT
 +         {  $$ = $1; base = ($1==0) ? 8 : 10; }
 +      |  number DIGIT
 +         {  $$ = base * $1 + $2; }
 +      ;
 +
 +%% /* start of programs */
 +
 +int
 +main (void)
 +{
 +    while(!feof(stdin)) {
 +	yyparse();
 +    }
 +    return 0;
 +}
 +
 +static void
 +yyerror(const char *s)
 +{
 +    fprintf(stderr, "%s\n", s);
 +}
 +
 +int
 +yylex(void)
 +{
 +	/* lexical analysis routine */
 +	/* returns LETTER for a lower case letter, yylval = 0 through 25 */
 +	/* return DIGIT for a digit, yylval = 0 through 9 */
 +	/* all other characters are returned immediately */
 +
 +    int c;
 +
 +    while( (c=getchar()) == ' ' )   { /* skip blanks */ }
 +
 +    /* c is now nonblank */
 +
 +    if( islower( c )) {
 +	yylval = c - 'a';
 +	return ( LETTER );
 +    }
 +    if( isdigit( c )) {
 +	yylval = c - '0';
 +	return ( DIGIT );
 +    }
 +    return( c );
 +}
 
 Added: head/tools/regression/usr.bin/yacc/calc1.y
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/calc1.y	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,305 @@
 +%{
 +
 +/* http://dinosaur.compilertools.net/yacc/index.html */
 +
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <ctype.h>
 +#include <math.h>
 +
 +typedef struct interval
 +{
 +    double lo, hi;
 +}
 +INTERVAL;
 +
 +INTERVAL vmul(double, double, INTERVAL);
 +INTERVAL vdiv(double, double, INTERVAL);
 +
 +extern int yylex(void);
 +static void yyerror(const char *s);
 +
 +int dcheck(INTERVAL);
 +
 +double dreg[26];
 +INTERVAL vreg[26];
 +
 +%}
 +%expect 18
 +
 +%start line
 +%union
 +{
 +	int ival;
 +	double dval;
 +	INTERVAL vval;
 +}
 +
 +%token <ival> DREG VREG		/* indices into dreg, vreg arrays */
 +%token <dval> CONST		/* floating point constant */
 +
 +%type <dval> dexp		/* expression */
 +%type <vval> vexp		/* interval expression */
 +
 +	/* precedence information about the operators */
 +
 +%left '+' '-'
 +%left '*' '/'
 +%left UMINUS			/* precedence for unary minus */
 +
 +%%	/* beginning of rules section */
 +
 +lines   : /* empty */
 +	| lines line
 +	;
 +
 +line	: dexp '\n'
 +	{
 +		(void) printf("%15.8f\n", $1);
 +	}
 +	| vexp '\n'
 +	{
 +		(void) printf("(%15.8f, %15.8f)\n", $1.lo, $1.hi);
 +	}
 +	| DREG '=' dexp '\n'
 +	{
 +		dreg[$1] = $3;
 +	}
 +	| VREG '=' vexp '\n'
 +	{
 +		vreg[$1] = $3;
 +	}
 +	| error '\n'
 +	{
 +		yyerrok;
 +	}
 +	;
 +
 +dexp	: CONST
 +	| DREG
 +	{
 +		$$ = dreg[$1];
 +	}
 +	| dexp '+' dexp
 +	{
 +		$$ = $1 + $3;
 +	}
 +	| dexp '-' dexp
 +	{
 +		$$ = $1 - $3;
 +	}
 +	| dexp '*' dexp
 +	{
 +		$$ = $1 * $3;
 +	}
 +	| dexp '/' dexp
 +	{
 +		$$ = $1 / $3;
 +	}
 +	| '-' dexp %prec UMINUS
 +	{
 +		$$ = -$2;
 +	}
 +	| '(' dexp ')'
 +	{
 +		$$ = $2;
 +	}
 +	;
 +
 +vexp	: dexp
 +	{
 +		$$.hi = $$.lo = $1;
 +	}
 +	| '(' dexp ',' dexp ')'
 +	{
 +		$$.lo = $2;
 +		$$.hi = $4;
 +		if ( $$.lo > $$.hi ) 
 +		{
 +			(void) printf("interval out of order\n");
 +			YYERROR;
 +		}
 +	}
 +	| VREG
 +	{
 +		$$ = vreg[$1];
 +	}
 +	| vexp '+' vexp
 +	{
 +		$$.hi = $1.hi + $3.hi;
 +		$$.lo = $1.lo + $3.lo;
 +	}
 +	| dexp '+' vexp
 +	{
 +		$$.hi = $1 + $3.hi;
 +		$$.lo = $1 + $3.lo;
 +	}
 +	| vexp '-' vexp
 +	{
 +		$$.hi = $1.hi - $3.lo;
 +		$$.lo = $1.lo - $3.hi;
 +	}
 +	| dexp '-' vexp
 +	{
 +		$$.hi = $1 - $3.lo;
 +		$$.lo = $1 - $3.hi;
 +	}
 +	| vexp '*' vexp
 +	{
 +		$$ = vmul( $1.lo, $1.hi, $3 );
 +	}
 +	| dexp '*' vexp
 +	{
 +		$$ = vmul ($1, $1, $3 );
 +	}
 +	| vexp '/' vexp
 +	{
 +		if (dcheck($3)) YYERROR;
 +		$$ = vdiv ( $1.lo, $1.hi, $3 );
 +	}
 +	| dexp '/' vexp
 +	{
 +		if (dcheck ( $3 )) YYERROR;
 +		$$ = vdiv ($1, $1, $3 );
 +	}
 +	| '-' vexp %prec UMINUS
 +	{
 +		$$.hi = -$2.lo;
 +		$$.lo = -$2.hi;
 +	}
 +	| '(' vexp ')'
 +	{
 +		$$ = $2;
 +	}
 +	;
 +
 +%%	/* beginning of subroutines section */
 +
 +#define BSZ 50			/* buffer size for floating point numbers */
 +
 +	/* lexical analysis */
 +
 +static void
 +yyerror(const char *s)
 +{
 +    fprintf(stderr, "%s\n", s);
 +}
 +
 +int
 +yylex(void)
 +{
 +    int c;
 +
 +    while ((c = getchar()) == ' ')
 +    {				/* skip over blanks */
 +    }
 +
 +    if (isupper(c))
 +    {
 +	yylval.ival = c - 'A';
 +	return (VREG);
 +    }
 +    if (islower(c))
 +    {
 +	yylval.ival = c - 'a';
 +	return (DREG);
 +    }
 +
 +    if (isdigit(c) || c == '.')
 +    {
 +	/* gobble up digits, points, exponents */
 +	char buf[BSZ + 1], *cp = buf;
 +	int dot = 0, expr = 0;
 +
 +	for (; (cp - buf) < BSZ; ++cp, c = getchar())
 +	{
 +
 +	    *cp = c;
 +	    if (isdigit(c))
 +		continue;
 +	    if (c == '.')
 +	    {
 +		if (dot++ || expr)
 +		    return ('.');	/* will cause syntax error */
 +		continue;
 +	    }
 +
 +	    if (c == 'e')
 +	    {
 +		if (expr++)
 +		    return ('e');	/*  will  cause  syntax  error  */
 +		continue;
 +	    }
 +
 +	    /*  end  of  number  */
 +	    break;
 +	}
 +	*cp = '\0';
 +
 +	if ((cp - buf) >= BSZ)
 +	    printf("constant  too  long:  truncated\n");
 +	else
 +	    ungetc(c, stdin);	/*  push  back  last  char  read  */
 +	yylval.dval = atof(buf);
 +	return (CONST);
 +    }
 +    return (c);
 +}
 +
 +static INTERVAL
 +hilo(double a, double b, double c, double d)
 +{
 +    /*  returns  the  smallest  interval  containing  a,  b,  c,  and  d  */
 +    /*  used  by  *,  /  routines  */
 +    INTERVAL v;
 +
 +    if (a > b)
 +    {
 +	v.hi = a;
 +	v.lo = b;
 +    }
 +    else
 +    {
 +	v.hi = b;
 +	v.lo = a;
 +    }
 +
 +    if (c > d)
 +    {
 +	if (c > v.hi)
 +	    v.hi = c;
 +	if (d < v.lo)
 +	    v.lo = d;
 +    }
 +    else
 +    {
 +	if (d > v.hi)
 +	    v.hi = d;
 +	if (c < v.lo)
 +	    v.lo = c;
 +    }
 +    return (v);
 +}
 +
 +INTERVAL
 +vmul(double a, double b, INTERVAL v)
 +{
 +    return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
 +}
 +
 +int
 +dcheck(INTERVAL v)
 +{
 +    if (v.hi >= 0. && v.lo <= 0.)
 +    {
 +	printf("divisor  interval  contains  0.\n");
 +	return (1);
 +    }
 +    return (0);
 +}
 +
 +INTERVAL
 +vdiv(double a, double b, INTERVAL v)
 +{
 +    return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
 +}
 
 Added: head/tools/regression/usr.bin/yacc/calc2.y
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/calc2.y	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,120 @@
 +%parse-param { int regs[26] }
 +%parse-param { int *base }
 +
 +%lex-param { int *base }
 +
 +%{
 +# include <stdio.h>
 +# include <ctype.h>
 +
 +#ifdef YYBISON
 +#define YYLEX_PARAM base
 +#define YYLEX_DECL() yylex(int *YYLEX_PARAM)
 +#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
 +int YYLEX_DECL();
 +static void YYERROR_DECL();
 +#endif
 +
 +%}
 +
 +%start list
 +
 +%token DIGIT LETTER
 +
 +%left '|'
 +%left '&'
 +%left '+' '-'
 +%left '*' '/' '%'
 +%left UMINUS   /* supplies precedence for unary minus */
 +
 +%% /* beginning of rules section */
 +
 +list  :  /* empty */
 +      |  list stat '\n'
 +      |  list error '\n'
 +            {  yyerrok ; }
 +      ;
 +
 +stat  :  expr
 +            {  printf("%d\n",$1);}
 +      |  LETTER '=' expr
 +            {  regs[$1] = $3; }
 +      ;
 +
 +expr  :  '(' expr ')'
 +            {  $$ = $2; }
 +      |  expr '+' expr
 +            {  $$ = $1 + $3; }
 +      |  expr '-' expr
 +            {  $$ = $1 - $3; }
 +      |  expr '*' expr
 +            {  $$ = $1 * $3; }
 +      |  expr '/' expr
 +            {  $$ = $1 / $3; }
 +      |  expr '%' expr
 +            {  $$ = $1 % $3; }
 +      |  expr '&' expr
 +            {  $$ = $1 & $3; }
 +      |  expr '|' expr
 +            {  $$ = $1 | $3; }
 +      |  '-' expr %prec UMINUS
 +            {  $$ = - $2; }
 +      |  LETTER
 +            {  $$ = regs[$1]; }
 +      |  number
 +      ;
 +
 +number:  DIGIT
 +         {  $$ = $1; (*base) = ($1==0) ? 8 : 10; }
 +      |  number DIGIT
 +         {  $$ = (*base) * $1 + $2; }
 +      ;
 +
 +%% /* start of programs */
 +
 +#ifdef YYBYACC
 +extern int YYLEX_DECL();
 +#endif
 +
 +int
 +main (void)
 +{
 +    int regs[26];
 +    int base = 10;
 +
 +    while(!feof(stdin)) {
 +	yyparse(regs, &base);
 +    }
 +    return 0;
 +}
 +
 +static void
 +YYERROR_DECL()
 +{
 +    fprintf(stderr, "%s\n", s);
 +}
 +
 +int
 +YYLEX_DECL()
 +{
 +	/* lexical analysis routine */
 +	/* returns LETTER for a lower case letter, yylval = 0 through 25 */
 +	/* return DIGIT for a digit, yylval = 0 through 9 */
 +	/* all other characters are returned immediately */
 +
 +    int c;
 +
 +    while( (c=getchar()) == ' ' )   { /* skip blanks */ }
 +
 +    /* c is now nonblank */
 +
 +    if( islower( c )) {
 +	yylval = c - 'a';
 +	return ( LETTER );
 +    }
 +    if( isdigit( c )) {
 +	yylval = (c - '0') % (*base);
 +	return ( DIGIT );
 +    }
 +    return( c );
 +}
 
 Added: head/tools/regression/usr.bin/yacc/calc3.y
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/calc3.y	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,123 @@
 +%pure-parser
 +
 +%parse-param { int regs[26] }
 +%parse-param { int *base }
 +
 +%lex-param { int *base }
 +
 +%{
 +# include <stdio.h>
 +# include <ctype.h>
 +
 +#ifdef YYBISON
 +#define YYSTYPE int
 +#define YYLEX_PARAM base
 +#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM)
 +#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
 +int YYLEX_DECL();
 +static void YYERROR_DECL();
 +#endif
 +
 +%}
 +
 +%start list
 +
 +%token DIGIT LETTER
 +
 +%left '|'
 +%left '&'
 +%left '+' '-'
 +%left '*' '/' '%'
 +%left UMINUS   /* supplies precedence for unary minus */
 +
 +%% /* beginning of rules section */
 +
 +list  :  /* empty */
 +      |  list stat '\n'
 +      |  list error '\n'
 +            {  yyerrok ; }
 +      ;
 +
 +stat  :  expr
 +            {  printf("%d\n",$1);}
 +      |  LETTER '=' expr
 +            {  regs[$1] = $3; }
 +      ;
 +
 +expr  :  '(' expr ')'
 +            {  $$ = $2; }
 +      |  expr '+' expr
 +            {  $$ = $1 + $3; }
 +      |  expr '-' expr
 +            {  $$ = $1 - $3; }
 +      |  expr '*' expr
 +            {  $$ = $1 * $3; }
 +      |  expr '/' expr
 +            {  $$ = $1 / $3; }
 +      |  expr '%' expr
 +            {  $$ = $1 % $3; }
 +      |  expr '&' expr
 +            {  $$ = $1 & $3; }
 +      |  expr '|' expr
 +            {  $$ = $1 | $3; }
 +      |  '-' expr %prec UMINUS
 +            {  $$ = - $2; }
 +      |  LETTER
 +            {  $$ = regs[$1]; }
 +      |  number
 +      ;
 +
 +number:  DIGIT
 +         {  $$ = $1; (*base) = ($1==0) ? 8 : 10; }
 +      |  number DIGIT
 +         {  $$ = (*base) * $1 + $2; }
 +      ;
 +
 +%% /* start of programs */
 +
 +#ifdef YYBYACC
 +extern int YYLEX_DECL();
 +#endif
 +
 +int
 +main (void)
 +{
 +    int regs[26];
 +    int base = 10;
 +
 +    while(!feof(stdin)) {
 +	yyparse(regs, &base);
 +    }
 +    return 0;
 +}
 +
 +static void
 +YYERROR_DECL()
 +{
 +    fprintf(stderr, "%s\n", s);
 +}
 +
 +int
 +YYLEX_DECL()
 +{
 +	/* lexical analysis routine */
 +	/* returns LETTER for a lower case letter, yylval = 0 through 25 */
 +	/* return DIGIT for a digit, yylval = 0 through 9 */
 +	/* all other characters are returned immediately */
 +
 +    int c;
 +
 +    while( (c=getchar()) == ' ' )   { /* skip blanks */ }
 +
 +    /* c is now nonblank */
 +
 +    if( islower( c )) {
 +	*yylval = (c - 'a');
 +	return ( LETTER );
 +    }
 +    if( isdigit( c )) {
 +	*yylval = (c - '0') % (*base);
 +	return ( DIGIT );
 +    }
 +    return( c );
 +}
 
 Added: head/tools/regression/usr.bin/yacc/code_calc.y
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/code_calc.y	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,112 @@
 +%{
 +# include <stdio.h>
 +# include <ctype.h>
 +
 +int regs[26];
 +int base;
 +
 +#ifdef YYBISON
 +int yylex(void);
 +static void yyerror(const char *s);
 +#endif
 +
 +%}
 +
 +%start list
 +
 +%token DIGIT LETTER
 +
 +%left '|'
 +%left '&'
 +%left '+' '-'
 +%left '*' '/' '%'
 +%left UMINUS   /* supplies precedence for unary minus */
 +
 +%% /* beginning of rules section */
 +
 +list  :  /* empty */
 +      |  list stat '\n'
 +      |  list error '\n'
 +            {  yyerrok ; }
 +      ;
 +
 +stat  :  expr
 +            {  printf("%d\n",$1);}
 +      |  LETTER '=' expr
 +            {  regs[$1] = $3; }
 +      ;
 +
 +expr  :  '(' expr ')'
 +            {  $$ = $2; }
 +      |  expr '+' expr
 +            {  $$ = $1 + $3; }
 +      |  expr '-' expr
 +            {  $$ = $1 - $3; }
 +      |  expr '*' expr
 +            {  $$ = $1 * $3; }
 +      |  expr '/' expr
 +            {  $$ = $1 / $3; }
 +      |  expr '%' expr
 +            {  $$ = $1 % $3; }
 +      |  expr '&' expr
 +            {  $$ = $1 & $3; }
 +      |  expr '|' expr
 +            {  $$ = $1 | $3; }
 +      |  '-' expr %prec UMINUS
 +            {  $$ = - $2; }
 +      |  LETTER
 +            {  $$ = regs[$1]; }
 +      |  number
 +      ;
 +
 +number:  DIGIT
 +         {  $$ = $1; base = ($1==0) ? 8 : 10; }
 +      |  number DIGIT
 +         {  $$ = base * $1 + $2; }
 +      ;
 +
 +%% /* start of programs */
 +
 +#ifdef YYBYACC
 +extern int YYLEX_DECL();
 +#endif
 +
 +int
 +main (void)
 +{
 +    while(!feof(stdin)) {
 +	yyparse();
 +    }
 +    return 0;
 +}
 +
 +static void
 +yyerror(const char *s)
 +{
 +    fprintf(stderr, "%s\n", s);
 +}
 +
 +int
 +yylex(void)
 +{
 +	/* lexical analysis routine */
 +	/* returns LETTER for a lower case letter, yylval = 0 through 25 */
 +	/* return DIGIT for a digit, yylval = 0 through 9 */
 +	/* all other characters are returned immediately */
 +
 +    int c;
 +
 +    while( (c=getchar()) == ' ' )   { /* skip blanks */ }
 +
 +    /* c is now nonblank */
 +
 +    if( islower( c )) {
 +	yylval = c - 'a';
 +	return ( LETTER );
 +    }
 +    if( isdigit( c )) {
 +	yylval = c - '0';
 +	return ( DIGIT );
 +    }
 +    return( c );
 +}
 
 Added: head/tools/regression/usr.bin/yacc/code_error.y
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/code_error.y	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,36 @@
 +%{
 +
 +#ifdef YYBISON
 +int yylex(void);
 +static void yyerror(const char *);
 +#endif
 +
 +%}
 +%%
 +S: error
 +%%
 +
 +#include <stdio.h>
 +
 +#ifdef YYBYACC
 +extern int YYLEX_DECL();
 +#endif
 +
 +int
 +main(void)
 +{
 +    printf("yyparse() = %d\n", yyparse());
 +    return 0;
 +}
 +
 +int
 +yylex(void)
 +{
 +    return -1;
 +}
 +
 +static void
 +yyerror(const char* s)
 +{
 +    printf("%s\n", s);
 +}
 
 Added: head/tools/regression/usr.bin/yacc/error.y
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/error.y	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,28 @@
 +%{
 +int yylex(void);
 +static void yyerror(const char *);
 +%}
 +%%
 +S: error
 +%%
 +
 +#include <stdio.h>
 +
 +int
 +main(void)
 +{
 +    printf("yyparse() = %d\n", yyparse());
 +    return 0;
 +}
 +
 +int
 +yylex(void)
 +{
 +    return -1;
 +}
 +
 +static void
 +yyerror(const char* s)
 +{
 +    printf("%s\n", s);
 +}
 
 Added: head/tools/regression/usr.bin/yacc/ftp.y
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/usr.bin/yacc/ftp.y	Mon May 21 13:31:26 2012	(r235723)
 @@ -0,0 +1,1228 @@
 +/*
 + * Copyright (c) 1985, 1988 Regents of the University of California.
 + * All rights reserved.
 + *
 + * Redistribution and use in source and binary forms are permitted
 + * provided that the above copyright notice and this paragraph are
 + * duplicated in all such forms and that any documentation,
 + * advertising materials, and other materials related to such
 + * distribution and use acknowledge that the software was developed
 + * by the University of California, Berkeley.  The name of the
 + * University may not be used to endorse or promote products derived
 + * from this software without specific prior written permission.
 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 + *
 + *	@(#)ftpcmd.y	5.20.1.1 (Berkeley) 3/2/89
 + */
 +
 +/*
 + * Grammar for FTP commands.
 + * See RFC 959.
 + */
 +
 +%{
 +
 +/* sccsid[] = "@(#)ftpcmd.y	5.20.1.1 (Berkeley) 3/2/89"; */
 +
 +#include <sys/param.h>
 +#include <sys/socket.h>
 +
 +#include <netinet/in.h>
 +
 +#include <arpa/ftp.h>
 +
 +#include <stdlib.h>
 +#include <unistd.h>
 +#include <stdio.h>
 +#include <signal.h>
 +#include <ctype.h>
 +#include <pwd.h>
 +#include <setjmp.h>
 +#include <syslog.h>
 +#include <sys/stat.h>
 +#include <string.h>
 +#include <time.h>
 +#include <assert.h>
 +
 +#ifdef YYBISON
 +int yylex(void);
 +static void yyerror(const char *);
 +#endif
 +
 +extern	struct sockaddr_in data_dest;
 +extern	int logged_in;
 +extern	struct passwd *pw;
 +extern	int guest;
 +extern	int logging;
 +extern	int type;
 +extern	int form;
 +extern	int debug;
 +extern	int timeout;
 +extern	int maxtimeout;
 +extern  int pdata;
 +extern	char hostname[], remotehost[];
 +extern	char proctitle[];
 +extern	char *globerr;
 +extern	int usedefault;
 +extern  int transflag;
 +extern  char tmpline[];
 +
 +extern char **glob(char *);
 +extern char *renamefrom(char *);
 +extern void cwd(const char *);
 +
 +extern void dologout(int);
 +extern void fatal(const char *);
 +extern void makedir(const char *);
 +extern void nack(const char *);
 +extern void pass(const char *);
 +extern void passive(void);
 +extern void pwd(void);
 +extern void removedir(char *);
 +extern void renamecmd(char *, char *);
 +extern void retrieve(const char *, const char *);
 +extern void send_file_list(const char *);
 +extern void statcmd(void);
 +extern void statfilecmd(const char *);
 +extern void store(char *, const char *, int);
 +extern void user(const char *);
 +
 +extern void perror_reply(int, const char *, ...);
 +extern void reply(int, const char *, ...);
 +extern void lreply(int, const char *, ...);
 +
 +static	int cmd_type;
 +static	int cmd_form;
 +static	int cmd_bytesz;
 +char	cbuf[512];
 
 *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
