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 |
441 |
|
no_rows = ni_columns; |
442 |
|
if ((no_rows != ni_columns) | (no_columns != ni_rows)) |
443 |
|
goto badspec; |
444 |
+ |
} else { |
445 |
+ |
if (no_columns <= 0) |
446 |
+ |
no_columns = ni_columns; |
447 |
+ |
if (no_rows <= 0) |
448 |
+ |
no_rows = ni_rows; |
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); |