| 9 |
|
|
| 10 |
|
#include "copyright.h" |
| 11 |
|
|
| 12 |
< |
#include "standard.h" |
| 12 |
> |
#include <ctype.h> |
| 13 |
> |
#include <string.h> |
| 14 |
> |
#include <stdio.h> |
| 15 |
|
|
| 16 |
+ |
#include "platform.h" |
| 17 |
+ |
#include "paths.h" |
| 18 |
+ |
#include "standard.h" |
| 19 |
|
#include "object.h" |
| 15 |
– |
|
| 20 |
|
#include "otypes.h" |
| 21 |
|
|
| 18 |
– |
#include <ctype.h> |
| 22 |
|
|
| 23 |
|
OBJREC *objblock[MAXOBJBLK]; /* our objects */ |
| 24 |
|
OBJECT nobjects = 0; /* # of objects */ |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
void |
| 28 |
< |
readobj(inpspec) /* read in an object file or stream */ |
| 29 |
< |
char *inpspec; |
| 28 |
> |
readobj( /* read in an object file or stream */ |
| 29 |
> |
char *inpspec |
| 30 |
> |
) |
| 31 |
|
{ |
| 32 |
|
OBJECT lastobj; |
| 33 |
|
FILE *infp; |
| 34 |
< |
char buf[1024]; |
| 35 |
< |
register int c; |
| 34 |
> |
char buf[2048]; |
| 35 |
> |
int c; |
| 36 |
|
|
| 37 |
|
lastobj = nobjects; |
| 38 |
|
if (inpspec == NULL) { |
| 63 |
|
} |
| 64 |
|
if (inpspec[0] == '!') |
| 65 |
|
pclose(infp); |
| 66 |
< |
else |
| 66 |
> |
else if (infp != stdin) |
| 67 |
|
fclose(infp); |
| 68 |
|
if (nobjects == lastobj) { |
| 69 |
|
sprintf(errmsg, "(%s): empty file", inpspec); |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
void |
| 76 |
< |
getobject(name, fp) /* read the next object */ |
| 77 |
< |
char *name; |
| 78 |
< |
FILE *fp; |
| 76 |
> |
getobject( /* read the next object */ |
| 77 |
> |
char *name, |
| 78 |
> |
FILE *fp |
| 79 |
> |
) |
| 80 |
|
{ |
| 81 |
|
#define OALIAS -2 |
| 82 |
|
OBJECT obj; |
| 83 |
|
char sbuf[MAXSTR]; |
| 84 |
|
int rval; |
| 85 |
< |
register OBJREC *objp; |
| 85 |
> |
OBJREC *objp; |
| 86 |
|
|
| 87 |
|
if ((obj = newobject()) == OVOID) |
| 88 |
|
error(SYSTEM, "out of object space"); |
| 90 |
|
/* get modifier */ |
| 91 |
|
strcpy(sbuf, "EOF"); |
| 92 |
|
fgetword(sbuf, MAXSTR, fp); |
| 93 |
+ |
if (strchr(sbuf, '\t')) { |
| 94 |
+ |
sprintf(errmsg, "(%s): illegal tab in modifier \"%s\"", |
| 95 |
+ |
name, sbuf); |
| 96 |
+ |
error(USER, errmsg); |
| 97 |
+ |
} |
| 98 |
|
if (!strcmp(sbuf, VOIDID)) |
| 99 |
|
objp->omod = OVOID; |
| 100 |
|
else if (!strcmp(sbuf, ALIASMOD)) |
| 113 |
|
/* get identifier */ |
| 114 |
|
sbuf[0] = '\0'; |
| 115 |
|
fgetword(sbuf, MAXSTR, fp); |
| 116 |
+ |
if (strchr(sbuf, '\t')) { |
| 117 |
+ |
sprintf(errmsg, "(%s): illegal tab in identifier \"%s\"", |
| 118 |
+ |
name, sbuf); |
| 119 |
+ |
error(USER, errmsg); |
| 120 |
+ |
} |
| 121 |
|
objp->oname = savqstr(sbuf); |
| 122 |
|
/* get arguments */ |
| 123 |
|
if (objp->otype == MOD_ALIAS) { |
| 124 |
< |
register OBJECT alias; |
| 124 |
> |
OBJECT alias; |
| 125 |
|
strcpy(sbuf, "EOF"); |
| 126 |
|
fgetword(sbuf, MAXSTR, fp); |
| 127 |
|
if ((alias = modifier(sbuf)) == OVOID) { |
| 160 |
|
|
| 161 |
|
|
| 162 |
|
OBJECT |
| 163 |
< |
newobject() /* get a new object */ |
| 163 |
> |
newobject(void) /* get a new object */ |
| 164 |
|
{ |
| 165 |
< |
register int i; |
| 165 |
> |
int i; |
| 166 |
|
|
| 167 |
|
if ((nobjects & (OBJBLKSIZ-1)) == 0) { /* new block */ |
| 168 |
|
errno = 0; |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
void |
| 180 |
< |
freeobjects(firstobj, nobjs) /* free a range of objects */ |
| 181 |
< |
OBJECT firstobj, nobjs; |
| 180 |
> |
freeobjects( /* free a range of objects */ |
| 181 |
> |
int firstobj, |
| 182 |
> |
int nobjs |
| 183 |
> |
) |
| 184 |
|
{ |
| 185 |
< |
register int obj; |
| 185 |
> |
int obj; |
| 186 |
|
/* check bounds */ |
| 187 |
|
if (firstobj < 0) |
| 188 |
|
return; |
| 192 |
|
return; |
| 193 |
|
/* clear objects */ |
| 194 |
|
for (obj = firstobj+nobjs; obj-- > firstobj; ) { |
| 195 |
< |
register OBJREC *o = objptr(obj); |
| 195 |
> |
OBJREC *o = objptr(obj); |
| 196 |
|
free_os(o); /* free client memory */ |
| 197 |
|
freeqstr(o->oname); |
| 198 |
|
freefargs(&o->oargs); |
| 199 |
< |
bzero(o, sizeof(OBJREC)); |
| 199 |
> |
memset((void *)o, '\0', sizeof(OBJREC)); |
| 200 |
|
} |
| 184 |
– |
clearobjndx(); |
| 201 |
|
/* free objects off end */ |
| 202 |
|
for (obj = nobjects; obj-- > 0; ) |
| 203 |
|
if (objptr(obj)->oname != NULL) |
| 204 |
|
break; |
| 205 |
< |
++obj; |
| 205 |
> |
if (++obj >= nobjects) |
| 206 |
> |
return; |
| 207 |
|
while (nobjects > obj) /* free empty end blocks */ |
| 208 |
|
if ((--nobjects & (OBJBLKSIZ-1)) == 0) { |
| 209 |
|
int i = nobjects >> OBJBLKSHFT; |
| 210 |
|
free((void *)objblock[i]); |
| 211 |
|
objblock[i] = NULL; |
| 212 |
|
} |
| 213 |
+ |
truncobjndx(); /* truncate modifier look-up */ |
| 214 |
|
} |