--- ray/src/common/readwfobj.c 2020/05/02 00:12:45 2.4 +++ ray/src/common/readwfobj.c 2023/02/07 20:28:16 2.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: readwfobj.c,v 2.4 2020/05/02 00:12:45 greg Exp $"; +static const char RCSid[] = "$Id: readwfobj.c,v 2.10 2023/02/07 20:28:16 greg Exp $"; #endif /* * readobj.c @@ -160,7 +160,7 @@ add_face(Scene *sc, const VNDX ondx, int ac, char *av[ if (i < 0) /* create face if indices OK */ f = addFace(sc, varr, ac); if (varr != vdef) - efree((char *)varr); + efree(varr); return(f != NULL); } @@ -171,7 +171,7 @@ loadOBJ(Scene *sc, const char *fspec) FILE *fp; char *argv[MAXARG]; int argc; - char buf[256]; + char buf[1024]; int nstats=0, nunknown=0; int onfaces; VNDX ondx; @@ -192,6 +192,9 @@ loadOBJ(Scene *sc, const char *fspec) error(SYSTEM, errmsg); return(NULL); } +#ifdef getc_unlocked /* avoid stupid semaphores */ + flockfile(fp); +#endif if (sc == NULL) sc = newScene(); lineno = 0; @@ -276,13 +279,27 @@ loadOBJ(Scene *sc, const char *fspec) fprintf(stderr, " %8d statements\r", nstats); } #if POPEN_SUPPORT - if (fspec[0] == '!') - pclose(fp); - else + if (fspec[0] == '!') { + if (pclose(fp) != 0) { + sprintf(errmsg, "Bad return status from: %s", fspec+1); + error(USER, errmsg); + freeScene(sc); + return(NULL); + } + } else #endif if (fp != stdin) fclose(fp); - sprintf(buf, "%d statements read from \"%s\"", nstats, fspec); +#ifdef getc_unlocked + else + funlockfile(fp); +#endif + if (verbose) + fprintf(stderr, "Read %d statements\n", nstats); + if (strlen(fspec) < sizeof(buf)-32) + sprintf(buf, "%d statements read from \"%s\"", nstats, fspec); + else + sprintf(buf, "%d statements read from (TOO LONG TO SHOW)", nstats); addComment(sc, buf); if (nunknown) { sprintf(buf, "\t%d unrecognized", nunknown);