trigraphs (was Why are character arrays special)

Henry Spencer henry at utzoo.uucp
Sun Feb 19 16:03:11 AEST 1989


In article <9650 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>Note that trigraphs may best be dealt with by a separate translator,
>ideally a separate program that could practically be skipped except
>the first time that code is imported from another site...

And let us not forget that in a Unix-like environment, a reasonably (not
wonderfully, but reasonably) efficient implementation of such a translator
is the following:

	#! /bin/sh
	sed "/??/ {
		s/??=/#/g
		s/??(/[/g
		s;??/;\\\\;g
		s/??)/]/g
		s/??'/^/g
		s/??</{/g
		s/??!/|/g
		s/??>/}/g
		s/??-/~/g
		}" $*

The one possible problem here is that old implementations of sed may have
annoyingly low limits on input line length.
-- 
The Earth is our mother;       |     Henry Spencer at U of Toronto Zoology
our nine months are up.        | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list