summaryrefslogtreecommitdiffstats
path: root/usr.bin/yacc
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>1999-07-29 09:42:14 +0000
committerobrien <obrien@FreeBSD.org>1999-07-29 09:42:14 +0000
commitecc95f8e7b45432bee66e7ceadb43a1ad6679cec (patch)
tree0204cb597a3c260ade2756d27728a958c13166a2 /usr.bin/yacc
parenta041e6bb6679895ea37a3d6083e25dd0ab539a28 (diff)
downloadFreeBSD-src-ecc95f8e7b45432bee66e7ceadb43a1ad6679cec.zip
FreeBSD-src-ecc95f8e7b45432bee66e7ceadb43a1ad6679cec.tar.gz
* Don't assume realloc() can take NULL as first arg. Yacc needs to
generate portable code... * Correctly define yyparse() (ie, K&R vs. C++/ANSI-C) Obtained from: OpenBSD revs 1.5 & 1.10
Diffstat (limited to 'usr.bin/yacc')
-rw-r--r--usr.bin/yacc/skeleton.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/yacc/skeleton.c b/usr.bin/yacc/skeleton.c
index c0f2ad1..7a00b48 100644
--- a/usr.bin/yacc/skeleton.c
+++ b/usr.bin/yacc/skeleton.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: skeleton.c,v 1.15 1999/04/18 13:37:49 peter Exp $
+ * $Id: skeleton.c,v 1.16 1999/07/29 08:47:30 obrien Exp $
*/
#ifndef lint
@@ -142,11 +142,15 @@ char *body[] =
" else if ((newsize *= 2) > YYMAXDEPTH)",
" newsize = YYMAXDEPTH;",
" i = yyssp - yyss;",
- " if ((newss = (short *)realloc(yyss, newsize * sizeof *newss)) == NULL)",
+ " newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :",
+ " (short *)malloc(newsize * sizeof *newss);",
+ " if (newss == NULL)",
" return -1;",
" yyss = newss;",
" yyssp = newss + i;",
- " if ((newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs)) == NULL)",
+ " newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :",
+ " (YYSTYPE *)malloc(newsize * sizeof *newvs);",
+ " if (newvs == NULL)",
" return -1;",
" yyvs = newvs;",
" yyvsp = newvs + i;",
@@ -161,7 +165,11 @@ char *body[] =
"#define YYERROR goto yyerrlab",
"",
"int",
+ "#if defined(__cplusplus) || __STDC__",
+ "yyparse(void)",
+ "#else",
"yyparse()",
+ "#endif",
"{",
" register int yym, yyn, yystate;",
"#if YYDEBUG",
OpenPOWER on IntegriCloud