35 |
|
mgetint(siz) /* get a siz-byte integer */ |
36 |
|
int siz; |
37 |
|
{ |
38 |
< |
long r; |
38 |
> |
long r = getint(siz, meshfp); |
39 |
|
|
40 |
< |
r = getint(siz, meshfp); |
41 |
< |
if (feof(meshfp)) |
40 |
> |
if (r == EOF && feof(meshfp)) |
41 |
|
mesherror(USER, "truncated mesh file"); |
42 |
+ |
|
43 |
|
return(r); |
44 |
|
} |
45 |
|
|
47 |
|
static double |
48 |
|
mgetflt() /* get a floating point number */ |
49 |
|
{ |
50 |
< |
double r; |
50 |
> |
double r = getflt(meshfp); |
51 |
|
|
52 |
< |
r = getflt(meshfp); |
53 |
< |
if (feof(meshfp)) |
52 |
> |
if (r == (double)EOF && feof(meshfp)) |
53 |
|
mesherror(USER, "truncated mesh file"); |
54 |
+ |
|
55 |
|
return(r); |
56 |
|
} |
57 |
|
|
250 |
|
error(SYSTEM, errmsg); |
251 |
|
} |
252 |
|
SET_FILE_BINARY(meshfp); |
253 |
+ |
#ifdef getc_unlocked /* avoid stupid semaphores */ |
254 |
+ |
flockfile(meshfp); |
255 |
+ |
#endif |
256 |
|
/* read header */ |
257 |
|
checkheader(meshfp, MESHFMT, flags&IO_INFO ? stdout : (FILE *)NULL); |
258 |
|
/* read format number */ |
293 |
|
getpatch(&mp->patch[i]); |
294 |
|
} |
295 |
|
/* clean up */ |
296 |
< |
fclose(meshfp); |
296 |
> |
if (meshfp != stdin) |
297 |
> |
fclose(meshfp); |
298 |
> |
#ifdef getc_unlocked |
299 |
> |
else |
300 |
> |
funlockfile(meshfp); |
301 |
> |
#endif |
302 |
|
mp->ldflags |= flags; |
303 |
|
/* verify data */ |
304 |
|
if ((err = checkmesh(mp)) != NULL) |