-
- /* Write the buffer to stdout, wrapping at 60 chars
- * starting from the column the last buffer ran out
- */
- do {
- /* Setup a new row if required */
- if (column == 0) {
- putchar('\n');
- if (tbl == tbl_std) {
- putchar('M');
- }
- }
- /* Write to the 60th column */
- if (fwrite(&dst_buf[buffer_offset], 1, write_size, stdout) != write_size) {
- perror("Couldnt finish writing");
- }
- /* Update variables based on last write */
- buffer_offset += write_size;
- remaining -= write_size;
- column += write_size;
- if (column % 60 == 0) {
- column = 0;
- }
-
- /* working next amount to write */
- write_size = (60 - column) % 60;
- if (write_size < remaining) {
- write_size = remaining;
- }
- if (write_size == 0) {
- write_size = 60;
- }
- } while (remaining > 0);