Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: trigraphs (was Why are character arrays special) Message-ID: <1989Feb19.060311.9533@utzoo.uucp> Organization: U of Toronto Zoology References: <19742@uflorida.cis.ufl.EDU> <225800126@uxe.cso.uiuc.edu> <1875@dataio.Data-IO.COM> <15941@mimsy.UUCP> <9650@smoke.BRL.MIL> Date: Sun, 19 Feb 89 06:03:11 GMT In article <9650@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) 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 }" $* 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@zoo.toronto.edu