29 |
|
|
30 |
|
typedef struct { |
31 |
|
int nw_rec; /* number of words per record */ |
32 |
< |
long nrecs; /* number of records we found */ |
32 |
> |
ssize_t nrecs; /* number of records we found */ |
33 |
|
char *rec[1]; /* record array (extends struct) */ |
34 |
|
} RECINDEX; |
35 |
|
|
218 |
|
|
219 |
|
/* copy nth record from index to stdout */ |
220 |
|
static int |
221 |
< |
print_record(const RECINDEX *rp, long n) |
221 |
> |
print_record(const RECINDEX *rp, ssize_t n) |
222 |
|
{ |
223 |
|
int words2go = rp->nw_rec; |
224 |
|
char *scp; |
360 |
|
} |
361 |
|
|
362 |
|
/* call to compute block input position */ |
363 |
< |
static long |
363 |
> |
static ssize_t |
364 |
|
get_block_pos(int r, int c, int blklvl[][2], int nlvls) |
365 |
|
{ |
366 |
< |
long n = 0; |
366 |
> |
ssize_t n = 0; |
367 |
|
|
368 |
|
while (nlvls > 1) { |
369 |
|
int sr = r/blklvl[1][0]; |
379 |
|
} |
380 |
|
|
381 |
|
/* return input offset based on array ordering and transpose option */ |
382 |
< |
static long |
382 |
> |
static ssize_t |
383 |
|
get_input_pos(int r, int c) |
384 |
|
{ |
385 |
< |
long n; |
385 |
> |
ssize_t n; |
386 |
|
|
387 |
|
if (outLevels > 1) { /* block reordering */ |
388 |
|
n = get_block_pos(r, c, outArray, outLevels); |
389 |
|
if (transpose) { |
390 |
|
r = n/ni_rows; |
391 |
|
c = n - r*ni_rows; |
392 |
< |
n = (long)c*ni_columns + r; |
392 |
> |
n = (ssize_t)c*ni_columns + r; |
393 |
|
} |
394 |
|
} else if (transpose) /* transpose only */ |
395 |
< |
n = (long)c*ni_columns + r; |
395 |
> |
n = (ssize_t)c*ni_columns + r; |
396 |
|
else /* XXX should never happen! */ |
397 |
< |
n = (long)r*no_columns + c; |
397 |
> |
n = (ssize_t)r*no_columns + c; |
398 |
|
return(n); |
399 |
|
} |
400 |
|
|
404 |
|
{ |
405 |
|
static const char tabEOL[2] = {'\t','\n'}; |
406 |
|
RECINDEX *rp = NULL; |
407 |
< |
long nrecords; |
407 |
> |
ssize_t nrecords; |
408 |
|
int i, j; |
409 |
|
/* propogate sizes */ |
410 |
|
if (ni_rows <= 0) |
419 |
|
ni_columns = count_columns(rp); |
420 |
|
nrecords = rp->nrecs; |
421 |
|
} else if ((ni_rows > 0) & (ni_columns > 0)) { |
422 |
< |
nrecords = ni_rows*ni_columns; |
422 |
> |
nrecords = (ssize_t)ni_rows*ni_columns; |
423 |
|
if (nrecords > mp->len/(n_comp*comp_size)) { |
424 |
|
fputs("Input too small for specified size and type\n", |
425 |
|
stderr); |
432 |
|
ni_rows = nrecords/ni_columns; |
433 |
|
else if ((ni_columns <= 0) & (ni_rows > 0)) |
434 |
|
ni_columns = nrecords/ni_rows; |
435 |
< |
if (nrecords != ni_rows*ni_columns) |
435 |
> |
if (nrecords != (ssize_t)ni_rows*ni_columns) |
436 |
|
goto badspec; |
437 |
|
if (transpose) { |
438 |
|
if (no_columns <= 0) |
461 |
|
/* reorder records */ |
462 |
|
for (i = 0; i < no_rows; i++) { |
463 |
|
for (j = 0; j < no_columns; j++) { |
464 |
< |
long n = get_input_pos(i, j); |
464 |
> |
ssize_t n = get_input_pos(i, j); |
465 |
|
if (n >= nrecords) { |
466 |
|
fputs("Index past end-of-file\n", stderr); |
467 |
|
return(0); |
491 |
|
static int |
492 |
|
do_resize(FILE *fp) |
493 |
|
{ |
494 |
< |
long records2go = ni_rows*ni_columns; |
494 |
> |
ssize_t records2go = ni_rows*ni_columns; |
495 |
|
int columns2go = no_columns; |
496 |
|
char word[256]; |
497 |
|
|