4 ms·
Has anyone ever encountered trigraphs in the wild? (in real code, IOCCC doesn't count) I've seen K&R C a few times, even in modern (well, "modern") code, but I
by arp242 3y ago
Has anyone ever encountered trigraphs in the wild? (in real code, IOCCC doesn't count)
I've seen K&R C a few times, even in modern (well, "modern") code, but I don't think I've ever encountered trigraphs. The proposal mentions that "instances of trigraphs being deliberately used in production code" via a codesearch.com query, but that's public code only (and probably only recent, and incomplete?)
[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2940.pdf https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2940.pdf
- AlotOfReading 3y agoNever seen intentional trigraphs in the wild and I doubt most people have given that they're disabled by default in GCC. A search did turn up whatever the fuck this is though: https://searchcode.com/file/12650181/blib/lib/prawda/grammar/english_russian/sub.h/ https://searchcode.com/file/12650181/blib/lib/prawda/grammar... Doesn't turn into anything meaningful with trigraph replacement. I'd guess that it's essentially a giant regex matching a header in some horrible, unknown dialect, but I'm not brave enough to look through the codebase to find out.
- yakubin 3y ago> they're disabled by default in GCC They’re disabled for gnuXX values of the -std= flag, but enabled for cXX. And for the latter you can’t disable them by any finer-grained flag.
- AlotOfReading 3y agoThe Gnu dialect is assumed if you don't specify arguments, hence default.
- arp242 3y agoThat file got mangled moving across encodings; the original[1] is in KOI8. https://imgur.com/a/xLUw0p8 https://imgur.com/a/xLUw0p8 [1]: https://code.google.com/archive/p/pravda https://code.google.com/archive/p/pravda
- technion 3y agoI feel like it's been one of the great identifiers of blog spam - articles on "worst c mistakes" where someone writes about all the problems trigraphs cause, I guess because they are banned in some standards like misra. No I've never seen them anywhere .
- tjalfi 3y agoI've seen accidental trigraphs such as ??! come up a few times in pre-ANSI codebases. Trigraphs are still used in EBCDIC codebases[0], but I wouldn't expect to see them anywhere else or in public code. [0] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2910.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n29...
- retrac 3y agoI've never seen them. It doesn't surprise me. Trigraphs were added to support machines without full ASCII support, lacking characters like ~ # { } and so on. Such machines are extremely rare, in practice. For example, even an early 1980s Apple //e, has those characters on its keyboard and in its character set.
- skissane 3y ago> Has anyone ever encountered trigraphs in the wild? (in real code, IOCCC doesn't count) Here’s some real code which starts with trigraphs. Note it only uses the trigraph for the initial pragma to establish the EBCDIC code pages, later on it doesn’t use them. (Also, that file contains some invalid characters because it was converted from EBCDIC to ASCII using the wrong code page.) https://github.com/mainframed/CBTTAPE/blob/main/CBT880/CBT.V500.FILE880.PDS/ESA.PRJ.CBTDSSN.PPONLY/DSSDB.txt https://github.com/mainframed/CBTTAPE/blob/main/CBT880/CBT.V... This is a tool for storing dumps (basically mainframe equivalent of core dumps) on a networked Unix filesystem. Someone wrote it because they didn’t have enough space on their mainframe to store the dumps, but did on networked Unix storage. And then they released the source code (not clear what license) https://raw.githubusercontent.com/mainframed/CBTTAPE/main/CBT880/CBT.V500.FILE880.PDS/%23DOCPDF.pdf https://raw.githubusercontent.com/mainframed/CBTTAPE/main/CB... Never actually used it (I’ve never had cause to use mainframes professionally, I just like studying them in my spare time)