Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!s09-10.readnews.com!not-for-mail From: Patrick Scheible Newsgroups: comp.lang.c Subject: Re: trigraphs, yecch References: <4f2808f4.648026530@text.giganews.com> Date: Tue, 31 Jan 2012 17:01:18 -0800 Message-ID: <86aa53e59d.fsf@zipcon.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (berkeley-unix) Cancel-Lock: sha1:BeskdcH4cwCb3Papyev1YGyC9mw= MIME-Version: 1.0 Content-Type: text/plain Lines: 41 Organization: The Zip Connection (zipcon.net) NNTP-Posting-Host: d39ad5ad.news.zipcon.net X-Trace: DXC=2LA;_Z4H1Mmg3`h;<25Q8aU>Dm5d6:E6mSVbGcmW@i>e?ZjaKW[K5W`_A>1gcoFWomLMaiNchOoFj X-Complaints-To: abuse@zipcon.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:16539 Keith Thompson writes: > cri@tiac.net (Richard Harter) writes: >> The other day I wanted to put three successive question marks in a >> string. Frex, "(???).%s.%s". My trusty antique gcc compiler >> converted the last two '?'s into a ']' along with a warning that it >> was doing a trigraph conversion. >> >> Now, me, I know from nothing about trigraphs - never used them, hope >> never to use them - so I was caught by surprise. My elderly copy of >> K&R described them but I didn't see anything about getting around >> them. >> >> So. How is one supposed to get three successive question marks into a >> string? > > For reference, there are exactly 9 trigraphs. C99 5.2.1.1: > > All occurrences in a source file of the following sequences of three > characters (called trigraph sequences) are replaced with the > corresponding single character. > > ??= # ??) ] ??! | > ??( [ ??' ^ ??> } > ??/ \ ??< { ??- ~ > > No other trigraph sequences exist. Each ? that does not begin one of > the trigraphs listed above is not changed. > > In your case, "???" is not a trigraph, but ??) is. Has the C standards committee been flamed enough for trigraphs? I don't think so. I bet there's 1000 programmers bitten by them for every 1 who's been helped. By 1989 anyone who didn't have an editor capable of typing any 7-bit ASCII character was a hopeless luddite who would be better served making their own pre-preprocessing phase for C and leaving the language unchanged instead of another phase in the preprocessor for every C program forever and ever. -- Patrick