| 170 |
|
mg_entity(name) /* get entity number from its name */ |
| 171 |
|
char *name; |
| 172 |
|
{ |
| 173 |
< |
static LUTAB ent_tab; /* entity lookup table */ |
| 173 |
> |
static LUTAB ent_tab = LU_SINIT(NULL,NULL); /* lookup table */ |
| 174 |
|
register char *cp; |
| 175 |
|
|
| 176 |
|
if (!ent_tab.tsiz) { /* initialize hash table */ |
| 215 |
|
|
| 216 |
|
ctx->lineno = 0; |
| 217 |
|
if (fn == NULL) { |
| 218 |
< |
ctx->fname = "<stdin>"; |
| 218 |
> |
strcpy(ctx->fname, "<stdin>"); |
| 219 |
|
ctx->fp = stdin; |
| 220 |
|
ctx->prev = mg_file; |
| 221 |
|
mg_file = ctx; |
| 227 |
|
olen = cp - mg_file->fname + 1; |
| 228 |
|
else |
| 229 |
|
olen = 0; |
| 230 |
– |
ctx->fname = (char *)malloc(olen+strlen(fn)+1); |
| 231 |
– |
if (ctx->fname == NULL) |
| 232 |
– |
return(MG_EMEM); |
| 230 |
|
if (olen) |
| 231 |
|
strcpy(ctx->fname, mg_file->fname); |
| 232 |
|
strcpy(ctx->fname+olen, fn); |
| 233 |
|
ctx->fp = fopen(ctx->fname, "r"); |
| 234 |
< |
if (ctx->fp == NULL) { |
| 238 |
< |
free((MEM_PTR)ctx->fname); |
| 234 |
> |
if (ctx->fp == NULL) |
| 235 |
|
return(MG_ENOFILE); |
| 240 |
– |
} |
| 236 |
|
ctx->prev = mg_file; /* establish new context */ |
| 237 |
|
mg_file = ctx; |
| 238 |
|
return(MG_OK); |
| 248 |
|
if (ctx->fp == stdin) |
| 249 |
|
return; /* don't close standard input */ |
| 250 |
|
fclose(ctx->fp); |
| 256 |
– |
free((MEM_PTR)ctx->fname); |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
|