| 349 |
|
{ |
| 350 |
|
MG_FCTXT cntxt; |
| 351 |
|
int rval; |
| 352 |
+ |
register int nbr; |
| 353 |
|
|
| 354 |
|
if ((rval = mg_open(&cntxt, fn)) != MG_OK) { |
| 355 |
|
fprintf(stderr, "%s: %s\n", fn, mg_err[rval]); |
| 356 |
|
return(rval); |
| 357 |
|
} |
| 358 |
< |
while (mg_read()) /* parse each line */ |
| 358 |
> |
while ((nbr = mg_read()) > 0) { /* parse each line */ |
| 359 |
> |
if (nbr >= MG_MAXLINE-1 && cntxt.inpline[nbr-1] != '\n') { |
| 360 |
> |
fprintf(stderr, "%s: %d: %s\n", cntxt.fname, |
| 361 |
> |
cntxt.lineno, mg_err[rval=MG_ELINE]); |
| 362 |
> |
break; |
| 363 |
> |
} |
| 364 |
|
if ((rval = mg_parse()) != MG_OK) { |
| 365 |
|
fprintf(stderr, "%s: %d: %s:\n%s", cntxt.fname, |
| 366 |
|
cntxt.lineno, mg_err[rval], |
| 367 |
|
cntxt.inpline); |
| 368 |
|
break; |
| 369 |
|
} |
| 370 |
+ |
} |
| 371 |
|
mg_close(); |
| 372 |
|
return(rval); |
| 373 |
|
} |
| 415 |
|
char *xfarg[MG_MAXARGC]; |
| 416 |
|
MG_FCTXT ictx; |
| 417 |
|
XF_SPEC *xf_orig = xf_context; |
| 418 |
< |
int rv; |
| 418 |
> |
register int rv; |
| 419 |
|
|
| 420 |
|
if (ac < 2) |
| 421 |
|
return(MG_EARGC); |
| 428 |
|
for (i = 1; i < ac-1; i++) |
| 429 |
|
xfarg[i] = av[i+1]; |
| 430 |
|
xfarg[ac-1] = NULL; |
| 431 |
< |
if ((rv = mg_handle(MG_E_XF, ac-1, xfarg)) != MG_OK) |
| 431 |
> |
if ((rv = mg_handle(MG_E_XF, ac-1, xfarg)) != MG_OK) { |
| 432 |
> |
mg_close(); |
| 433 |
|
return(rv); |
| 434 |
+ |
} |
| 435 |
|
} |
| 436 |
|
do { |
| 437 |
< |
while (mg_read()) |
| 437 |
> |
while ((rv = mg_read()) > 0) { |
| 438 |
> |
if (rv >= MG_MAXLINE-1 && ictx.inpline[rv-1] != '\n') { |
| 439 |
> |
fprintf(stderr, "%s: %d: %s\n", ictx.fname, |
| 440 |
> |
ictx.lineno, mg_err[MG_ELINE]); |
| 441 |
> |
mg_close(); |
| 442 |
> |
return(MG_EINCL); |
| 443 |
> |
} |
| 444 |
|
if ((rv = mg_parse()) != MG_OK) { |
| 445 |
|
fprintf(stderr, "%s: %d: %s:\n%s", ictx.fname, |
| 446 |
|
ictx.lineno, mg_err[rv], |
| 448 |
|
mg_close(); |
| 449 |
|
return(MG_EINCL); |
| 450 |
|
} |
| 451 |
+ |
} |
| 452 |
|
if (ac > 2) |
| 453 |
< |
if ((rv = mg_handle(MG_E_XF, 1, xfarg)) != MG_OK) |
| 453 |
> |
if ((rv = mg_handle(MG_E_XF, 1, xfarg)) != MG_OK) { |
| 454 |
> |
mg_close(); |
| 455 |
|
return(rv); |
| 456 |
+ |
} |
| 457 |
|
} while (xf_context != xf_orig); |
| 458 |
|
mg_close(); |
| 459 |
|
return(MG_OK); |