Dave Allan wrote:
...
It's valid to pass a negative value, so int is the correct type.
My
bad for using unsigned int in the first place.
>From man printf:
A negative field width is taken as a '-' flag followed by a positive
field width.
Hi Dave,
While it's true that a negative printf field width has meaning,
this code certainly does not try to take advantage of that.
The *meaning* (as it's used) of that variable is "a non-negative
indentation width". Hence, the fact that we've chosen a printf-based
implementation to output those spaces is just a detail, and should
not influence the type of the variable. Nor should it influence the
interfaces through which it is passed. We could easily switch to a
simple loop, in which case it'd be obvious there's no point in
accepting negative values.
The types used in variables and interfaces should be independent
of such implementation details.
This horse is now officially dead.