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); |
751 |
|
static char *p4ent[5] = {mg_ename[MG_E_POINT],p4[0],p4[1],p4[2]}; |
752 |
|
static char *n4ent[5] = {mg_ename[MG_E_NORMAL],n4[0],n4[1],n4[2]}; |
753 |
|
static char *fent[6] = {mg_ename[MG_E_FACE],"_cv1","_cv2","_cv3","_cv4"}; |
754 |
+ |
char *v1n; |
755 |
|
register C_VERTEX *cv1, *cv2; |
756 |
|
register int i, j; |
757 |
|
FVECT u, v, w; |
767 |
|
if ((cv1 = c_getvert(av[1])) == NULL || |
768 |
|
(cv2 = c_getvert(av[3])) == NULL) |
769 |
|
return(MG_EUNDEF); |
770 |
+ |
v1n = av[1]; |
771 |
|
if (!isflt(av[2]) || !isflt(av[4])) |
772 |
|
return(MG_ETYPE); |
773 |
|
rad1 = atof(av[2]); |
786 |
|
cv = cv1; |
787 |
|
cv1 = cv2; |
788 |
|
cv2 = cv; |
789 |
+ |
v1n = av[3]; |
790 |
|
d = rad1; |
791 |
|
rad1 = rad2; |
792 |
|
rad2 = d; |
820 |
|
if ((rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK) |
821 |
|
return(rv); |
822 |
|
if (rad1 == 0.) { /* triangles */ |
823 |
< |
v1ent[3] = av[1]; |
823 |
> |
v1ent[3] = v1n; |
824 |
|
if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK) |
825 |
|
return(rv); |
826 |
|
for (j = 0; j < 3; j++) |