printf: diagnose empty args correctly
commit91e95f1f86977a66ac0d6165f6db554eff174128
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 19 Nov 2024 02:19:54 +0000 (18 18:19 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 19 Nov 2024 16:41:34 +0000 (19 08:41 -0800)
tree0dc32c079cb078f986086a0c14c223c1b1b7147b
parenta665aa4f6df54806d0e16e3a950791b9a63142cb
printf: diagnose empty args correctly

Also, port better to macOS.
* src/printf.c (verify_numeric): Don’t assume that when s == end
then errno is zero; it is EINVAL on macOS, and POSIX allows this.
(print_direc): Treat missing arg as zero for numeric conversions,
and as an empty string for the others.
(print_formatted): Use null pointer, not an empty string,
to represent missing arg.
* tests/printf/printf.sh: Test empty and space widths and precisions.
src/printf.c
tests/printf/printf.sh