--- ray/src/common/readobj.c 2003/06/07 12:50:20 2.13 +++ ray/src/common/readobj.c 2019/05/04 00:36:58 2.23 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: readobj.c,v 2.13 2003/06/07 12:50:20 schorsch Exp $"; +static const char RCSid[] = "$Id: readobj.c,v 2.23 2019/05/04 00:36:58 greg Exp $"; #endif /* * readobj.c - routines for reading in object descriptions. @@ -10,12 +10,11 @@ static const char RCSid[] = "$Id: readobj.c,v 2.13 200 #include "copyright.h" #include +#include #include -#ifdef _WIN32 - #define popen _popen - #define pclose _pclose -#endif +#include "platform.h" +#include "paths.h" #include "standard.h" #include "object.h" #include "otypes.h" @@ -26,13 +25,14 @@ OBJECT nobjects = 0; /* # of objects */ void -readobj(inpspec) /* read in an object file or stream */ -char *inpspec; +readobj( /* read in an object file or stream */ + char *inpspec +) { OBJECT lastobj; FILE *infp; - char buf[1024]; - register int c; + char buf[2048]; + int c; lastobj = nobjects; if (inpspec == NULL) { @@ -63,7 +63,7 @@ char *inpspec; } if (inpspec[0] == '!') pclose(infp); - else + else if (infp != stdin) fclose(infp); if (nobjects == lastobj) { sprintf(errmsg, "(%s): empty file", inpspec); @@ -73,15 +73,16 @@ char *inpspec; void -getobject(name, fp) /* read the next object */ -char *name; -FILE *fp; +getobject( /* read the next object */ + char *name, + FILE *fp +) { #define OALIAS -2 OBJECT obj; char sbuf[MAXSTR]; int rval; - register OBJREC *objp; + OBJREC *objp; if ((obj = newobject()) == OVOID) error(SYSTEM, "out of object space"); @@ -89,6 +90,11 @@ FILE *fp; /* get modifier */ strcpy(sbuf, "EOF"); fgetword(sbuf, MAXSTR, fp); + if (strchr(sbuf, '\t')) { + sprintf(errmsg, "(%s): illegal tab in modifier \"%s\"", + name, sbuf); + error(USER, errmsg); + } if (!strcmp(sbuf, VOIDID)) objp->omod = OVOID; else if (!strcmp(sbuf, ALIASMOD)) @@ -107,10 +113,15 @@ FILE *fp; /* get identifier */ sbuf[0] = '\0'; fgetword(sbuf, MAXSTR, fp); + if (strchr(sbuf, '\t')) { + sprintf(errmsg, "(%s): illegal tab in identifier \"%s\"", + name, sbuf); + error(USER, errmsg); + } objp->oname = savqstr(sbuf); /* get arguments */ if (objp->otype == MOD_ALIAS) { - register OBJECT alias; + OBJECT alias; strcpy(sbuf, "EOF"); fgetword(sbuf, MAXSTR, fp); if ((alias = modifier(sbuf)) == OVOID) { @@ -149,9 +160,9 @@ FILE *fp; OBJECT -newobject() /* get a new object */ +newobject(void) /* get a new object */ { - register int i; + int i; if ((nobjects & (OBJBLKSIZ-1)) == 0) { /* new block */ errno = 0; @@ -166,10 +177,12 @@ newobject() /* get a new object */ } void -freeobjects(firstobj, nobjs) /* free a range of objects */ -OBJECT firstobj, nobjs; +freeobjects( /* free a range of objects */ + int firstobj, + int nobjs +) { - register int obj; + int obj; /* check bounds */ if (firstobj < 0) return; @@ -179,11 +192,11 @@ OBJECT firstobj, nobjs; return; /* clear objects */ for (obj = firstobj+nobjs; obj-- > firstobj; ) { - register OBJREC *o = objptr(obj); + OBJREC *o = objptr(obj); free_os(o); /* free client memory */ freeqstr(o->oname); freefargs(&o->oargs); - bzero((void *)o, sizeof(OBJREC)); + memset((void *)o, '\0', sizeof(OBJREC)); } clearobjndx(); /* free objects off end */