Module Name: src Committed By: kre Date: Wed May 19 22:41:19 UTC 2021
Modified Files: src/usr.bin/printf: printf.c Log Message: Changes for POSIX conformance. 1. exit(1) with an error message on stderr if an I/O error occurs. 1a. To work properly when built into /bin/sh sprinkle clearerr() at appropriate places. 2. Verify that when a 'X data value is used with one of the numeric conversions, that nothing follows the 'X'. It used to be unclear in the standard whether this was required or not, it is clear that with numeric conversions the entire data value must be used, or an error must result. But with string conversions, that isn't the case and unused parts are simply ignored. This one is a numeric conversion with a string value, so which applies? The standard used to contain an example of '+3 being converted, producing the same as '+ ignoring the '3' with no mention of any error, so that's the approach we adopted, The forthcoming version now explicitly states that an error would also be generated from that case, as the '3' was not used by the numeric conversion. 2a. We support those conversions with floating as well as integer conversions, as the standard used to suggest that was required (but it makes no sense, the values are always integers, printing them in a floating format is dumb). The standard has been revised to make it clear that only the integer numeric conversions %d %u %x (etc) are supposed to handle the 'X form of data value. We still allow it with the floating formats as an extension, for backward compat, just in case someone (other than the ATF tests) is using it. It might go away. 2b. These formats are sypposed to convert 'X where 'X' is a character (perhaps multibyte encoded) in the current LC_CTYPE locale category. We don't handle that, only 1 byte characters are handled currently. However the framework is now there to allow code to (one hopes, easily) be added to handle multi-byte locales. (Note that for the purposes of #2 above, 'X' must be a single character, not a single byte.) To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.bin/printf/printf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.