From 542a2aa0d7051ba10219d229b832ed49b18e96f6 Mon Sep 17 00:00:00 2001 From: "Peter B. Kessler" Date: Fri, 17 Oct 1980 06:09:25 -0800 Subject: [PATCH] undefined type is spelled P2UNDEF not P2UNDEFINED. SCCS-vsn: usr.bin/pascal/src/rval.c 1.3 SCCS-vsn: usr.bin/pascal/src/p2put.c 1.3 --- usr/src/usr.bin/pascal/src/p2put.c | 39 +++++++++++++++--------------- usr/src/usr.bin/pascal/src/rval.c | 4 +-- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/usr/src/usr.bin/pascal/src/p2put.c b/usr/src/usr.bin/pascal/src/p2put.c index bff16f4aac..c31123b994 100644 --- a/usr/src/usr.bin/pascal/src/p2put.c +++ b/usr/src/usr.bin/pascal/src/p2put.c @@ -1,6 +1,6 @@ /* Copyright (c) 1979 Regents of the University of California */ -static char sccsid[] = "@(#)p2put.c 1.2 %G%"; +static char sccsid[] = "@(#)p2put.c 1.3 %G%"; /* * functions to help pi put out @@ -378,14 +378,25 @@ putCONG( string , length , required ) * is stored as * * so, we build types recursively + * also, we know that /lib/f1 can only deal with 6 qualifications + * so we stop the recursion there. this stops infinite type recursion + * through mutually recursive pointer types. */ +#define MAXQUALS 6 int p2type( np ) - struct nl *np; +{ + + return typerecur( np , 0 ); +} +typerecur( np , quals ) + struct nl *np; + int quals; { - if ( np == NIL ) - return P2UNDEFINED; + if ( np == NIL || quals > MAXQUALS ) { + return P2UNDEF; + } switch ( np -> class ) { case SCAL : case RANGE : @@ -404,9 +415,6 @@ p2type( np ) } case STR : return ( P2ARY | P2CHAR ); - /* - return P2STRTY; - */ case RECORD : case SET : return P2STRTY; @@ -419,12 +427,9 @@ p2type( np ) case TYPE : switch ( nloff( np ) ) { case TNIL : - return ( P2PTR | P2UNDEFINED ); + return ( P2PTR | P2UNDEF ); case TSTR : return ( P2ARY | P2CHAR ); - /* - return P2STRTY; - */ case TSET : return P2STRTY; default : @@ -433,19 +438,16 @@ p2type( np ) case REF: case WITHPTR: case PTR : - return ADDTYPE( p2type( np -> type ) , P2PTR ); + return ADDTYPE( typerecur( np -> type , quals + 1 ) , P2PTR ); case ARRAY : - return ADDTYPE( p2type( np -> type ) , P2ARY ); - /* - return P2STRTY; - */ + return ADDTYPE( typerecur( np -> type , quals + 1 ) , P2ARY ); case FUNC : /* * functions are really pointers to functions * which return their underlying type. */ - return ADDTYPE( ADDTYPE( p2type( np -> type ) , P2FTN ) - , P2PTR ); + return ADDTYPE( ADDTYPE( typerecur( np -> type , quals + 2 ) , + P2FTN ) , P2PTR ); case PROC : /* * procedures are pointers to functions @@ -460,7 +462,6 @@ p2type( np ) */ return ADDTYPE( P2PTR , P2STRTY ); default : - fprintf( stderr , "[p2type] np -> class %d\n" , np -> class ); panic( "p2type" ); } } diff --git a/usr/src/usr.bin/pascal/src/rval.c b/usr/src/usr.bin/pascal/src/rval.c index 9f481ff3cd..bac37026eb 100644 --- a/usr/src/usr.bin/pascal/src/rval.c +++ b/usr/src/usr.bin/pascal/src/rval.c @@ -1,6 +1,6 @@ /* Copyright (c) 1979 Regents of the University of California */ -static char sccsid[] = "@(#)rval.c 1.2 %G%"; +static char sccsid[] = "@(#)rval.c 1.3 %G%"; #include "whoami.h" #include "0.h" @@ -87,7 +87,7 @@ rvalue(r, contype , required ) put(2, O_CON2, 0); # endif OBJ # ifdef PC - putleaf( P2ICON , 0 , 0 , P2PTR|P2UNDEFINED , 0 ); + putleaf( P2ICON , 0 , 0 , P2PTR|P2UNDEF , 0 ); # endif PC return (nl+TNIL); -- 2.20.1