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

Function pad_at

src/od.c:518–525  ·  view source on GitHub ↗

If there are FIELDS fields, return the total padding up to the start of field I, where I < FIELDS. PAD is the total padding for all fields. The result equals (PAD * I) / FIELDS, except it does not suffer from internal overflow. */

Source from the content-addressed store, hash-verified

516 all fields. The result equals (PAD * I) / FIELDS, except it does
517 not suffer from internal overflow. */
518static idx_t
519pad_at (idx_t fields, idx_t i, idx_t pad)
520{
521 /* This implementation assumes that (FIELDS - 1)^2 does not overflow
522 intmax_t, an assumption checked by pad_at_overflow. */
523 intmax_t m = pad % fields;
524 return pad / fields * i + m * i / fields;
525}
526static bool
527pad_at_overflow (idx_t fields)
528{

Callers 3

print_named_asciiFunction · 0.85
print_asciiFunction · 0.85
write_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected