IEEE Standards Interpretations for IEEE Std 1003.2™-1992 IEEE Standard for Information Technology--Portable Operating System Interfaces (POSIX®)--Part 2: Shell and Utilities
Copyright © 1996 by the Institute of Electrical and Electronics Engineers, Inc. 345 East 47th Street New York, New York 10017 USA All Rights Reserved.
These are interpretations of IEEE Std 1003.2-1992. Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.
IEEE Standards Department, Copyrights and Permissions, 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA
Interpretation Request #76
Topic: bc large numbers and lines Relevant Clauses: 4.3
POSIX.2 Subclause 4.3 specifies the semantics of the "bc" utility.
In subclause 18.104.22.168, lines 1385-1387 state: Very large numbers shall be split across lines with 70 characters per line in the POSIX locale; other locales may split at different character boundaries. Lines that are continued shall end with a backslash. The issue that I would like resolved is: does either the terminating backslash, or the newline, or both, count against the 70 characters in the continued line? In other words, in the POSIX locale, if "bc" needs to display an integer longer than 70 digits, how many digit characters are displayed before the backslash on the first line? I note that the definition of a "line" in POSIX.2 subclause 22.214.171.124 is A sequence of text consisting of zero or more non-<newline> characters plus a terminating <newline> character. From this definition I would conclude that the newline is counted as one of the 70 characters. Thus my understanding of the standard is that under the circumstances described above "bc" would display 68 digits followed by a backslash followed by a newline followed by the remaining digits (split across more lines if necessary).
The definition of line includes the newline character, and bc does not override that definition, therefore the <backslash> and <newline> characters are counted as part of the 70 length. The standard clearly states the behaviour for bc and the definition of a line, and conforming implementations must conform to this.
Rationale for Interpretation
Note that this is a change to historical practice.