394 |
|
} else if (transpose) /* transpose only */ |
395 |
|
n = (long)c*ni_columns + r; |
396 |
|
else /* XXX should never happen! */ |
397 |
< |
n = (long)r*ni_columns + c; |
397 |
> |
n = (long)r*no_columns + c; |
398 |
|
return(n); |
399 |
|
} |
400 |
|
|
421 |
|
} else if ((ni_rows > 0) & (ni_columns > 0)) { |
422 |
|
nrecords = ni_rows*ni_columns; |
423 |
|
if (nrecords > mp->len/(n_comp*comp_size)) { |
424 |
< |
fprintf(stderr, |
425 |
< |
"Input too small for specified size and type\n"); |
424 |
> |
fputs("Input too small for specified size and type\n", |
425 |
> |
stderr); |
426 |
|
return(0); |
427 |
|
} |
428 |
|
} else |
446 |
|
no_columns = ni_columns; |
447 |
|
if (no_rows <= 0) |
448 |
|
no_rows = ni_rows; |
449 |
– |
if ((no_rows != ni_rows) | (no_columns != ni_columns)) |
450 |
– |
goto badspec; |
449 |
|
} |
450 |
+ |
if (ni_rows*ni_columns != no_rows*no_columns) { |
451 |
+ |
fputs("Number of input and output records do not match\n", |
452 |
+ |
stderr); |
453 |
+ |
return(0); |
454 |
+ |
} |
455 |
|
/* reorder records */ |
456 |
|
for (i = 0; i < no_rows; i++) { |
457 |
|
for (j = 0; j < no_columns; j++) { |
458 |
|
long n = get_input_pos(i, j); |
459 |
+ |
if (n >= nrecords) { |
460 |
+ |
fputs("Index past end-of-file\n", stderr); |
461 |
+ |
return(0); |
462 |
+ |
} |
463 |
|
if (rp != NULL) { /* ASCII output */ |
464 |
|
print_record(rp, n); |
465 |
|
putc(tabEOL[j >= no_columns-1], stdout); |