MCPcopy Create free account
hub / github.com/coreutils/coreutils / wrap_write

Function wrap_write

src/basenc.c:1442–1471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1440
1441
1442static void
1443wrap_write (char const *buffer, idx_t len,
1444 idx_t wrap_column, idx_t *current_column, FILE *out)
1445{
1446 if (wrap_column == 0)
1447 {
1448 /* Simple write. */
1449 if (fwrite (buffer, 1, len, stdout) < len)
1450 write_error ();
1451 }
1452 else
1453 for (idx_t written = 0; written < len; )
1454 {
1455 idx_t to_write = MIN (wrap_column - *current_column, len - written);
1456
1457 if (to_write == 0)
1458 {
1459 if (fputc ('\n', out) == EOF)
1460 write_error ();
1461 *current_column = 0;
1462 }
1463 else
1464 {
1465 if (fwrite (buffer + written, 1, to_write, stdout) < to_write)
1466 write_error ();
1467 *current_column += to_write;
1468 written += to_write;
1469 }
1470 }
1471}
1472
1473static _Noreturn void
1474finish_and_exit (FILE *in, char const *infile)

Callers 1

do_encodeFunction · 0.85

Calls 1

write_errorFunction · 0.85

Tested by

no test coverage detected