90 |
|
load_file(MEMLOAD *mp, FILE *fp) |
91 |
|
{ |
92 |
|
int fd; |
93 |
< |
off_t skip, flen, skipped; |
93 |
> |
off_t skip, flen, fpos; |
94 |
|
|
95 |
|
#if defined(_WIN32) || defined(_WIN64) |
96 |
|
/* too difficult to fix this */ |
117 |
|
mp->mapped = 1; |
118 |
|
return(1); /* mmap() success */ |
119 |
|
} |
120 |
< |
mp->base = NULL; /* fall back to reading it in... */ |
120 |
> |
mp->base = NULL; /* else fall back to reading it in... */ |
121 |
|
} |
122 |
|
#endif |
123 |
|
if (lseek(fd, skip, SEEK_SET) != skip || |
125 |
|
mp->len = 0; |
126 |
|
return(-1); |
127 |
|
} |
128 |
< |
skipped = skip; /* read() fails on really big buffers */ |
129 |
< |
while (skipped < flen) { |
130 |
< |
ssize_t nread = read(fd, (char *)mp->base+(skipped-skip), |
131 |
< |
(flen-skipped <= 1L<<30) ? flen-skipped : 1L<<30); |
128 |
> |
fpos = skip; |
129 |
> |
while (fpos < flen) { /* read() fails if n > 2 GBytes */ |
130 |
> |
ssize_t nread = read(fd, (char *)mp->base+(fpos-skip), |
131 |
> |
(flen-fpos < 1L<<24) ? flen-fpos : 1L<<24); |
132 |
|
if (nread <= 0) { |
133 |
|
free_load(mp); |
134 |
|
return(-1); |
135 |
|
} |
136 |
< |
skipped += nread; |
136 |
> |
fpos += nread; |
137 |
|
} |
138 |
|
return(1); |
139 |
|
} |
370 |
|
putc(tabEOL[j >= no_columns-1], stdout); |
371 |
|
} else { /* binary output */ |
372 |
|
putbinary((char *)mp->base + |
373 |
< |
(unsigned long)(n_comp*comp_size)*(j*ni_columns + i), |
373 |
> |
(size_t)(n_comp*comp_size)*(j*ni_columns + i), |
374 |
|
comp_size, n_comp, stdout); |
375 |
|
} |
376 |
|
if (ferror(stdout)) { |