A NOTE has been added to this issue. ====================================================================== http://austingroupbugs.net/view.php?id=1202 ====================================================================== Reported By: kre Assigned To: ====================================================================== Project: 1003.1(2016)/Issue7+TC2 Issue ID: 1202 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section: XCU 4 -- printf Page Number: 3113 Line Number: 104118 - 104120, 104123 - 104126 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2018-08-29 19:26 UTC Last Modified: 2018-08-30 14:43 UTC ====================================================================== Summary: printf %.Nb with \c in arg (more than N chars into arg) behaviour unclear ======================================================================
---------------------------------------------------------------------- (0004093) shware_systems (reporter) - 2018-08-30 14:43 http://austingroupbugs.net/view.php?id=1202#c4093 ---------------------------------------------------------------------- I think the controlling language here is, at Line 104121: "The interpretation of a <backslash> followed by any other sequence of characters is unspecified. Bytes from the converted string shall be written until the end of the string or the number of bytes indicated by the precision specification is reached. If the precision is omitted, it shall be taken to be infinite, so all bytes up to the end of the converted string shall be written." which indicates the entire argument shall be processed before applying the precision specifier, and \c taking effect as described for the second option, to leave open the possibility of other sequences being used as extensions that may convert to one or more final characters subject to the precision, or treated as a syntax error abort without outputting anything. Because of the possibility of embedded <NUL> characters, this means the conversion has to be treated as a counted string, not a nul-delimited one, to satisfy the last sentence quoted; since it does not have an explicit 'or a NUL character is encountered'. As example, a platform might define a \u to expand to the current GMT with microsecond precision, which would be at least 8 characters (HH:MM:SS) replacing the \u. On another platform it might output Syntax Error on the next line, without 'a X' or 'a ' at all. Issue History Date Modified Username Field Change ====================================================================== 2018-08-29 19:26 kre New Issue 2018-08-29 19:26 kre Name => Robert Elz 2018-08-29 19:26 kre Section => XCU 4 -- printf 2018-08-29 19:26 kre Page Number => 3113 2018-08-29 19:26 kre Line Number => 104118 - 104120, 104123 - 104126 2018-08-30 12:46 joerg Note Added: 0004092 2018-08-30 14:43 shware_systems Note Added: 0004093 ======================================================================