ANSI draft interpretation questions

Karl Heuer karl at haddock.ima.isc.com
Fri Jan 12 06:07:56 AEST 1990


In article <15618 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
>Suppose MB_LEN_MAX == 2 and that '@' is a two-byte character whose bytes are
>{0x84, 0x30}.  If I call scanf("@") and the input stream contains 0x84 0x31,
>does it push back one byte or two?

To answer my own question: one, apparently.  Each ordinary multibyte character
is a single directive, which causes characters (bytes) to be read from the
stream, and in case of mismatch the differing and subsequent characters remain
unread.  If "character" had been intended to mean "multibyte character" here,
they would have said so, and it would have been singular instead of plural.

So it seems that the forces in favor of minimal pushback felt so strongly
about it that they were even willing to leave the input stream in an unknown
shift state!

Karl W. Z. Heuer (karl at haddock.isc.com or ima!haddock!karl), The Walking Lint



More information about the Comp.std.c mailing list