[FEATURE] Add native integer printf formatting and diagnostics #13

Open
opened 2026-10-26 05:54:43 +01:00 by erikinkinen · 0 comments
Owner

Problem and motivation

Native printf handles byte and string output, but build scripts also need integer formatting and useful diagnostics for malformed numbers.

Proposed behavior and scope

Add %d, %i, %u, %o, %x and %X with integer flags and literal decimal width and precision. Document signs, bases, quoted operands and numeric bounds under a fixed C byte policy. Preserve format reuse, missing operands, binary output and the existing %b command stop.

Numeric operand errors must retain converted output, report diagnostics and finish with status 2. Reachable malformed format syntax still fails before output. Extend the shared formatter and native consumer together; provide an explicit diagnostic buffer for buffered callers.

Authority, security and reliability

Use the original argument view and admitted stdout/stderr descriptions. Parsing and rendering acquire no allocation, locale, environment or service authority. Keep generated, staged and accepted bytes separate for each stream, including callback failures and cleanup uncertainty.

Acceptance criteria

  • Implement integer conversion, signs, bases, quoted operands, bounds, missing operands and format reuse with independent byte expectations.
  • Implement flags, width and precision with checked accounting and chunked output, without a fixed output-size limit.
  • Preserve byte/string conversions, command-stop behavior and reachable syntax preflight.
  • Preserve stdout, diagnostics, final status and original stream ownership through partial writes, failures and teardown.
  • Add buffered, native and VM regression cases and update the command and technical manuals.

Alternatives and tradeoffs

The stdout-only buffered interface cannot represent numeric diagnostics. An explicit diagnostic-output interface keeps one parser for buffered and native callers; the legacy interface must refuse diagnostic-producing input rather than discard errors.

Tracking and rollout

Extends the byte/string formatter in #12. Coordinate Coreutils and Integration through #2 and erix/integration#12. Phase tracking: erix/integration#65.

## Problem and motivation Native printf handles byte and string output, but build scripts also need integer formatting and useful diagnostics for malformed numbers. ## Proposed behavior and scope Add %d, %i, %u, %o, %x and %X with integer flags and literal decimal width and precision. Document signs, bases, quoted operands and numeric bounds under a fixed C byte policy. Preserve format reuse, missing operands, binary output and the existing %b command stop. Numeric operand errors must retain converted output, report diagnostics and finish with status 2. Reachable malformed format syntax still fails before output. Extend the shared formatter and native consumer together; provide an explicit diagnostic buffer for buffered callers. ## Authority, security and reliability Use the original argument view and admitted stdout/stderr descriptions. Parsing and rendering acquire no allocation, locale, environment or service authority. Keep generated, staged and accepted bytes separate for each stream, including callback failures and cleanup uncertainty. ## Acceptance criteria - [ ] Implement integer conversion, signs, bases, quoted operands, bounds, missing operands and format reuse with independent byte expectations. - [ ] Implement flags, width and precision with checked accounting and chunked output, without a fixed output-size limit. - [ ] Preserve byte/string conversions, command-stop behavior and reachable syntax preflight. - [ ] Preserve stdout, diagnostics, final status and original stream ownership through partial writes, failures and teardown. - [ ] Add buffered, native and VM regression cases and update the command and technical manuals. ## Alternatives and tradeoffs The stdout-only buffered interface cannot represent numeric diagnostics. An explicit diagnostic-output interface keeps one parser for buffered and native callers; the legacy interface must refuse diagnostic-producing input rather than discard errors. ## Tracking and rollout Extends the byte/string formatter in https://git.erikinkinen.fi/erix/coreutils/issues/12. Coordinate Coreutils and Integration through https://git.erikinkinen.fi/erix/coreutils/pulls/2 and https://git.erikinkinen.fi/erix/integration/pulls/12. Phase tracking: https://git.erikinkinen.fi/erix/integration/issues/65.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:33:36 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/coreutils#13
No description provided.