| 387 |
|
if (outLevels > 1) { /* block reordering */ |
| 388 |
|
n = get_block_pos(r, c, outArray, outLevels); |
| 389 |
|
if (transpose) { |
| 390 |
< |
r = n/no_columns; |
| 391 |
< |
c = n - r*no_columns; |
| 392 |
< |
n = (long)r*ni_columns + c; |
| 390 |
> |
r = n/ni_rows; |
| 391 |
> |
c = n - r*ni_rows; |
| 392 |
> |
n = (long)c*ni_columns + r; |
| 393 |
|
} |
| 394 |
|
} else if (transpose) /* transpose only */ |
| 395 |
|
n = (long)c*ni_columns + r; |
| 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 |
| 439 |
|
no_columns = ni_rows; |
| 440 |
|
if (no_rows <= 0) |
| 441 |
|
no_rows = ni_columns; |
| 442 |
< |
if ((no_rows != ni_columns) | (no_columns != ni_rows)) |
| 442 |
> |
if (outLevels <= 1 && |
| 443 |
> |
(no_rows != ni_columns) | (no_columns != ni_rows)) |
| 444 |
|
goto badspec; |
| 445 |
+ |
} else { |
| 446 |
+ |
if (no_columns <= 0) |
| 447 |
+ |
no_columns = ni_columns; |
| 448 |
+ |
if (no_rows <= 0) |
| 449 |
+ |
no_rows = ni_rows; |
| 450 |
|
} |
| 451 |
+ |
if (ni_rows*ni_columns != no_rows*no_columns) { |
| 452 |
+ |
fputs("Number of input and output records do not match\n", |
| 453 |
+ |
stderr); |
| 454 |
+ |
return(0); |
| 455 |
+ |
} |
| 456 |
|
/* reorder records */ |
| 457 |
|
for (i = 0; i < no_rows; i++) { |
| 458 |
|
for (j = 0; j < no_columns; j++) { |
| 459 |
|
long n = get_input_pos(i, j); |
| 460 |
+ |
if (n >= nrecords) { |
| 461 |
+ |
fputs("Index past end-of-file\n", stderr); |
| 462 |
+ |
return(0); |
| 463 |
+ |
} |
| 464 |
|
if (rp != NULL) { /* ASCII output */ |
| 465 |
|
print_record(rp, n); |
| 466 |
|
putc(tabEOL[j >= no_columns-1], stdout); |