[comp.std.c] End user implications of trigraphs

msw@cisunx.UUCP (Matt S Wartell) (04/27/89)

First, thanks to Rex, et al. for the helpful explanations about the
various standards committees.

I hesitate to ask such a ethnocentric question after all of the careful
international discussion, but:

If the ISO-646 trigraphs become incorporated in the ANSI X3J11 specification,
will I (as a programmer in the US) have to be careful not to put, for example,

	puts("Is this a trigraph??");

in my programs?
-- 
...............................................................................
: disclaimer: "I am the Lorax, I speak                                        :
:              for the trees."                       university of pittsburgh :
:                    -T. Geisel                   msw@unix.cis.pittsburgh.edu :

msw@cisunx.UUCP (Matt S Wartell) (05/03/89)

Thanks to all who responded to my somewhat naive question about trigraphs.
As was pointed out by all of the respondants, my question was ill-formed.
I had asked if
	puts("trigraph??");
would break under the pANS.  Since ??" is not a ISO-646 trigraph, my example
would work fine.  If the question were:
	puts("trigraph??!");
the answer would be: yes, this will generate "trigraph|" instead of 
"trigraph??!".

It was also pointed out that ISO-646 trigraphs _have_ been incorporated
into the proposed standard.  For what it's worth, trigraphs are here.

However, a few people noted that self-respecting ANSI compilers would
probably have a "disable-trigraphs" or "enable-trigraphs" option.

A helpful solution came from Karl Heuer via Mark Brader's .signature:
	sed -e "s;??\\([-=(/)'<!>]\\);?\\\\?\\1;g"
will protect trigraphs-that-weren't-meant-to-be-trigraphs in existing
code.  Thus, the ??! from my example would become ?\?! when transformed
by sed.  One caveat: the ?\? construction may fail on pre-ANSI compilers.

Thanks again to Karl Heuer, Marv Rubinstein, Gordon L. Burditt, 
Stephen J. Friedl, Mark Brader and David H. Wolfskill for their kind
responses. 
-- 
matt wartell, university of pittsburgh             msw@unix.cis.pittsburgh.edu