Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #16498 > unrolled thread
| Started by | cri@tiac.net (Richard Harter) |
|---|---|
| First post | 2012-01-31 15:55 +0000 |
| Last post | 2012-02-01 16:52 +0000 |
| Articles | 20 on this page of 48 — 20 participants |
Back to article view | Back to comp.lang.c
trigraphs, yecch cri@tiac.net (Richard Harter) - 2012-01-31 15:55 +0000
Re: trigraphs, yecch pete <pfiland@mindspring.com> - 2012-01-31 11:05 -0500
Re: trigraphs, yecch Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-31 16:47 +0000
Re: trigraphs, yecch cri@tiac.net (Richard Harter) - 2012-01-31 17:21 +0000
Re: trigraphs, yecch James Kuyper <jameskuyper@verizon.net> - 2012-01-31 12:26 -0500
Re: trigraphs, yecch Robert Wessel <robertwessel2@yahoo.com> - 2012-01-31 11:40 -0600
Re: trigraphs, yecch Keith Thompson <kst-u@mib.org> - 2012-01-31 15:22 -0800
Re: trigraphs, yecch "BartC" <bc@freeuk.com> - 2012-02-01 01:09 +0000
Re: trigraphs, yecch James Kuyper <jameskuyper@verizon.net> - 2012-01-31 22:21 -0500
Re: trigraphs, yecch Keith Thompson <kst-u@mib.org> - 2012-01-31 21:25 -0800
Re: trigraphs, yecch "Charles Richmond" <netnews@aquaporin4.com> - 2012-01-31 23:40 -0600
Re: trigraphs, yecch Keith Thompson <kst-u@mib.org> - 2012-01-31 22:19 -0800
Re: trigraphs, yecch James Kuyper <jameskuyper@verizon.net> - 2012-02-01 08:27 -0500
Re: trigraphs, yecch Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-31 17:47 +0000
Re: trigraphs, yecch ImpalerCore <jadill33@gmail.com> - 2012-01-31 09:41 -0800
Re: trigraphs, yecch pete <pfiland@mindspring.com> - 2012-01-31 13:17 -0500
Re: trigraphs, yecch blp@cs.stanford.edu (Ben Pfaff) - 2012-01-31 09:56 -0800
Re: trigraphs, yecch Peter Nilsson <airia@acay.com.au> - 2012-01-31 13:55 -0800
Re: trigraphs, yecch Harald van Dijk <haraldvdijk@gmail.com> - 2012-01-31 14:02 -0800
Re: trigraphs, yecch blp@cs.stanford.edu (Ben Pfaff) - 2012-01-31 14:06 -0800
Re: trigraphs, yecch Harald van Dijk <haraldvdijk@gmail.com> - 2012-01-31 15:13 -0800
Re: trigraphs, yecch "Charles Richmond" <netnews@aquaporin4.com> - 2012-01-31 23:44 -0600
Re: trigraphs, yecch Keith Thompson <kst-u@mib.org> - 2012-01-31 22:20 -0800
Re: trigraphs, yecch James Harris <james.harris.1@googlemail.com> - 2012-01-31 22:56 -0800
Re: trigraphs, yecch Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-01 12:15 +0000
Re: trigraphs, yecch Keith Thompson <kst-u@mib.org> - 2012-01-31 15:27 -0800
Re: trigraphs, yecch Patrick Scheible <kkt@zipcon.net> - 2012-01-31 17:01 -0800
Re: trigraphs, yecch Keith Thompson <kst-u@mib.org> - 2012-01-31 19:50 -0800
Re: trigraphs, yecch Patrick Scheible <kkt@zipcon.net> - 2012-02-01 10:31 -0800
Re: trigraphs, yecch James Kuyper <jameskuyper@verizon.net> - 2012-01-31 23:17 -0500
Re: trigraphs, yecch "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2012-02-01 10:39 +0100
Re: trigraphs, yecch Kaz Kylheku <kaz@kylheku.com> - 2012-02-01 17:20 +0000
Re: trigraphs, yecch Patrick Scheible <kkt@zipcon.net> - 2012-02-01 11:11 -0800
Re: trigraphs, yecch "Charles Richmond" <netnews@aquaporin4.com> - 2012-01-31 23:50 -0600
Re: trigraphs, yecch ralph <nt_consulting64@yahoo.net> - 2012-02-01 11:56 -0600
Re: trigraphs, yecch Patrick Scheible <kkt@zipcon.net> - 2012-02-01 11:12 -0800
Re: trigraphs, yecch Stephen Sprunk <stephen@sprunk.org> - 2012-02-01 13:29 -0600
Re: trigraphs, yecch blp@cs.stanford.edu (Ben Pfaff) - 2012-02-01 11:35 -0800
Re: trigraphs, yecch Kaz Kylheku <kaz@kylheku.com> - 2012-02-01 19:59 +0000
Re: trigraphs, yecch blp@cs.stanford.edu (Ben Pfaff) - 2012-02-01 12:41 -0800
Re: trigraphs, yecch Kaz Kylheku <kaz@kylheku.com> - 2012-02-01 22:55 +0000
Re: trigraphs, yecch Stephen Sprunk <stephen@sprunk.org> - 2012-02-01 14:44 -0600
Re: trigraphs, yecch Kaz Kylheku <kaz@kylheku.com> - 2012-02-01 22:55 +0000
Re: trigraphs, yecch "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-02-02 14:19 -0800
Re: trigraphs, yecch Patrick Scheible <kkt@zipcon.net> - 2012-02-06 20:40 -0800
Re: trigraphs, yecch "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2012-02-07 11:40 +0100
Re: trigraphs, yecch jgk@panix.com (Joe keane) - 2012-02-02 14:15 +0000
Re: trigraphs, yecch cri@tiac.net (Richard Harter) - 2012-02-01 16:52 +0000
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | Harald van Dijk <haraldvdijk@gmail.com> |
|---|---|
| Date | 2012-01-31 15:13 -0800 |
| Message-ID | <531ec5f8-bd14-4939-8ed8-64952d38da31@q8g2000yqa.googlegroups.com> |
| In reply to | #16528 |
On Jan 31, 11:06 pm, b...@cs.stanford.edu (Ben Pfaff) wrote: > Harald van Dijk <haraldvd...@gmail.com> writes: > > Multicharacter constants are implementation-specific but valid in > > standard C, and at the same time \? is not. > > \? is a valid escape sequence in a character or string constant > in standard C, since C89. Oops, you're quire right. I'm not sure why I thought it was invalid.
[toc] | [prev] | [next] | [standalone]
| From | "Charles Richmond" <netnews@aquaporin4.com> |
|---|---|
| Date | 2012-01-31 23:44 -0600 |
| Message-ID | <jgajfr$pd7$1@dont-email.me> |
| In reply to | #16528 |
"Ben Pfaff" <blp@cs.stanford.edu> wrote in message
news:87fwev8r37.fsf@blp.benpfaff.org...
> Harald van Dijk <haraldvdijk@gmail.com> writes:
>
>> Multicharacter constants are implementation-specific but valid in
>> standard C, and at the same time \? is not.
>
> \? is a valid escape sequence in a character or string constant
> in standard C, since C89.
>
Yup... when in doubt, just escape them all:
printf(" These are \?\?\?\?\?.\n");
--
+<><><><><><><><><><><><><><><><><><><>+
| Charles Richmond numerist@aquaporin4.com |
+<><><><><><><><><><><><><><><><><><><>+
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2012-01-31 22:20 -0800 |
| Message-ID | <lnty3bulam.fsf@nuthaus.mib.org> |
| In reply to | #16559 |
"Charles Richmond" <netnews@aquaporin4.com> writes:
> "Ben Pfaff" <blp@cs.stanford.edu> wrote in message
> news:87fwev8r37.fsf@blp.benpfaff.org...
>> Harald van Dijk <haraldvdijk@gmail.com> writes:
>>
>>> Multicharacter constants are implementation-specific but valid in
>>> standard C, and at the same time \? is not.
>>
>> \? is a valid escape sequence in a character or string constant
>> in standard C, since C89.
>>
> Yup... when in doubt, just escape them all:
>
> printf(" These are \?\?\?\?\?.\n");
When in doubt, learn the rules, thereby removing the doubt.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | James Harris <james.harris.1@googlemail.com> |
|---|---|
| Date | 2012-01-31 22:56 -0800 |
| Message-ID | <8587caca-1d76-40dc-9e20-e0a8bd894761@m5g2000yqk.googlegroups.com> |
| In reply to | #16568 |
On Feb 1, 6:20 am, Keith Thompson <ks...@mib.org> wrote:
> "Charles Richmond" <netn...@aquaporin4.com> writes:
> > "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
...
> >> \? is a valid escape sequence in a character or string constant
> >> in standard C, since C89.
>
> > Yup... when in doubt, just escape them all:
>
> > printf(" These are \?\?\?\?\?.\n");
>
> When in doubt, learn the rules, thereby removing the doubt.
Easy to say. C has lots of rules, though. Charles' simplifying
suggestion looks good to me as it leaves a reader in no doubt of the
intention.
James
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2012-02-01 12:15 +0000 |
| Message-ID | <0.1e91a3958b545c6bdf4b.20120201121556GMT.871uqepx4z.fsf@bsb.me.uk> |
| In reply to | #16572 |
James Harris <james.harris.1@googlemail.com> writes:
> On Feb 1, 6:20 am, Keith Thompson <ks...@mib.org> wrote:
>> "Charles Richmond" <netn...@aquaporin4.com> writes:
>> > "Ben Pfaff" <b...@cs.stanford.edu> wrote in message
>
> ...
>
>> >> \? is a valid escape sequence in a character or string constant
>> >> in standard C, since C89.
>>
>> > Yup... when in doubt, just escape them all:
>>
>> > printf(" These are \?\?\?\?\?.\n");
>>
>> When in doubt, learn the rules, thereby removing the doubt.
>
> Easy to say. C has lots of rules, though. Charles' simplifying
> suggestion looks good to me as it leaves a reader in no doubt of the
> intention.
Only if you know the rules about \ in strings so you know that there
are no special rules that apply to sequences like \?\, say. Maybe
string characters are escaped before trigraph processing occurs, or
maybe... In the end, the meaning of a line of C can't really be in no
doubt unless the reader knows almost all of the rules.
But compilers know the rules and they can often help. For example, by
including -Werror=trigraphs in your gcc options, compilation will fail
if any trigraph gets translated.
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2012-01-31 15:27 -0800 |
| Message-ID | <ln4nvbxxkb.fsf@nuthaus.mib.org> |
| In reply to | #16498 |
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.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Patrick Scheible <kkt@zipcon.net> |
|---|---|
| Date | 2012-01-31 17:01 -0800 |
| Message-ID | <86aa53e59d.fsf@zipcon.net> |
| In reply to | #16533 |
Keith Thompson <kst-u@mib.org> 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
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2012-01-31 19:50 -0800 |
| Message-ID | <lnbopjw6sp.fsf@nuthaus.mib.org> |
| In reply to | #16539 |
Patrick Scheible <kkt@zipcon.net> writes:
[...]
> 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.
By 1989, there were plenty of C programmers using EBCDIC-based systems.
There probably still are, though not as many. I understand there were
also some C programmers using keyboards and character sets that replaced
some ASCII punctuation characters with accented letters; that's probably
not as much of a concern these days.
I would have preferred a solution in which trigraphs are disabled by
default, and can be enabled explicitly by a directive at the top of each
source file.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Patrick Scheible <kkt@zipcon.net> |
|---|---|
| Date | 2012-02-01 10:31 -0800 |
| Message-ID | <86ehuetnfr.fsf@zipcon.net> |
| In reply to | #16552 |
Keith Thompson <kst-u@mib.org> writes: > Patrick Scheible <kkt@zipcon.net> writes: > [...] >> 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. > > By 1989, there were plenty of C programmers using EBCDIC-based systems. I would argue with "plenty". C was not a popular language in IBM shops. IBM shops typically didn't do systems programing of the sort C is great for, and if they did they'd probably use PL/1. By 1989, EBCDIC was clearly on its way out. The PC used ASCII. People in shops that used EBCDIC mostly already had tools to convert to ASCII when needed. > There probably still are, though not as many. I understand there were > also some C programmers using keyboards and character sets that replaced > some ASCII punctuation characters with accented letters; that's probably > not as much of a concern these days. I think that was the standards committee's motivation. However, a crippled subset of ASCII was not a satisfactory approach to anyone. People in countries using those accented characters still needed brackets and braces sometimes. They pretty often needed to represent multiple languages with accented characters in the same document and a national character set doesn't allow that at all. > I would have preferred a solution in which trigraphs are disabled by > default, and can be enabled explicitly by a directive at the top of each > source file. They should have stuck to using a standalone independent preprocessor just for character set issues for another few years until Unicode came along. In 1991, the first volume of the Unicode standard was published. -- Patrick
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2012-01-31 23:17 -0500 |
| Message-ID | <jgaece$76o$1@dont-email.me> |
| In reply to | #16539 |
On 01/31/2012 08:01 PM, Patrick Scheible wrote:
> Keith Thompson <kst-u@mib.org> writes:
...
>> 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 ...
Every single one of the characters for which there's a corresponding
trigraph sequence, is on that list precisely it's not in the "invariant
set" supported by all of the national variants of the ISO/IEC 646 7-bit
encoding. If you lived in one of the nations for which those national
variants was created, an editor which supported only strict 7-bit ASCII
would not have been very useful - that's precisely why the national
variants were created.
There are work-arounds; such as standard conventions for transliterating
a German letter such as ö into oe, but those conventions implement
essentially the same idea as trigraphs: using multiple representable
characters to indirectly represent a single character that's not
directly representable.
> ... 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.
I'm not arguing that trigraphs were a good solution to the problem. But
restricting editors to 7-bit ASCII was not an acceptable solution,
either. That's why one of the Scandinavian countries (I forget which
one) refused to approve the C standard until some accomodation was made
to the needs of people for whom 7-bit ASCII was unacceptable. The result
was a political compromise, and like most such, it was equally
unattractive to all parties engaged in the negotiations.
--
James Kuyper
[toc] | [prev] | [next] | [standalone]
| From | "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> |
|---|---|
| Date | 2012-02-01 10:39 +0100 |
| Message-ID | <jgb180$24d$1@online.de> |
| In reply to | #16553 |
James Kuyper wrote: <snip> > There are work-arounds; such as standard conventions for > transliterating a German letter such as ö into oe, but those > conventions implement essentially the same idea as trigraphs: using > multiple representable characters to indirectly represent a single > character that's not directly representable. Not quite the same thing. while e.g. the German ö can get transcribed as oe, not every oe can get changed to ö, so the process is not reversible. Bye, Jojo
[toc] | [prev] | [next] | [standalone]
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Date | 2012-02-01 17:20 +0000 |
| Message-ID | <20120201091613.151@kylheku.com> |
| In reply to | #16553 |
On 2012-02-01, James Kuyper <jameskuyper@verizon.net> wrote: > I'm not arguing that trigraphs were a good solution to the problem. But > restricting editors to 7-bit ASCII was not an acceptable solution, > either. That's why one of the Scandinavian countries (I forget which > one) refused to approve the C standard until some accomodation was made > to the needs of people for whom 7-bit ASCII was unacceptable. The correct response would have been not to bother with them. There doesn't need to be an ISO standard for C; ANSI is good enough. Many fine languages have only ANSI standards. Actual programmers in that Scandinavian country do not require these trigraphs any more than they require words like "if", "for" and "unsigned" to be translated into their language, and were just as ill-served by this as everyone else.
[toc] | [prev] | [next] | [standalone]
| From | Patrick Scheible <kkt@zipcon.net> |
|---|---|
| Date | 2012-02-01 11:11 -0800 |
| Message-ID | <86aa52tlli.fsf@zipcon.net> |
| In reply to | #16553 |
James Kuyper <jameskuyper@verizon.net> writes:
> On 01/31/2012 08:01 PM, Patrick Scheible wrote:
>> Keith Thompson <kst-u@mib.org> writes:
> ...
>>> 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 ...
>
> Every single one of the characters for which there's a corresponding
> trigraph sequence, is on that list precisely it's not in the "invariant
> set" supported by all of the national variants of the ISO/IEC 646 7-bit
> encoding. If you lived in one of the nations for which those national
> variants was created, an editor which supported only strict 7-bit ASCII
> would not have been very useful - that's precisely why the national
> variants were created.
The invariant subset of ASCII was an unsatisfactory solution to
everyone, including people working in the languages for which it was
created. The characters lost by accented characters are used for many
purposes, not just C. And many people need to be able to represent
accented characters from several different languages in the same
document. The Unicode committe was already meeting in 1989. The C
committee should have stuck to ad-hoc preprocessors for people using C
in a non-full-ASCII language until Unicode was ready, only another few
years.
> There are work-arounds; such as standard conventions for transliterating
> a German letter such as ö into oe, but those conventions implement
> essentially the same idea as trigraphs: using multiple representable
> characters to indirectly represent a single character that's not
> directly representable.
>
>> ... 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.
>
> I'm not arguing that trigraphs were a good solution to the problem. But
> restricting editors to 7-bit ASCII was not an acceptable solution,
> either. That's why one of the Scandinavian countries (I forget which
> one) refused to approve the C standard until some accomodation was made
> to the needs of people for whom 7-bit ASCII was unacceptable. The result
> was a political compromise, and like most such, it was equally
> unattractive to all parties engaged in the negotiations.
Thankfully, Ritchie didn't have get an international committee's
blessing in order to create C.
-- Patrick
[toc] | [prev] | [next] | [standalone]
| From | "Charles Richmond" <netnews@aquaporin4.com> |
|---|---|
| Date | 2012-01-31 23:50 -0600 |
| Message-ID | <jgak72$s1u$1@dont-email.me> |
| In reply to | #16539 |
"Patrick Scheible" <kkt@zipcon.net> wrote in message
news:86aa53e59d.fsf@zipcon.net...
> Keith Thompson <kst-u@mib.org> 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.
>
So just *remove* trigraphs from the *next* C standard. Or require the
preprocessor symbol "__TRIGRAPH_IMPLEMENTED__" to be defined, or relegate
this to a PRAGMA... before trigraphs would be recognized by the compiler.
Make it *extra* hard for the ordinary C programmer to step on this land
mine.
--
+<><><><><><><><><><><><><><><><><><><>+
| Charles Richmond numerist@aquaporin4.com |
+<><><><><><><><><><><><><><><><><><><>+
[toc] | [prev] | [next] | [standalone]
| From | ralph <nt_consulting64@yahoo.net> |
|---|---|
| Date | 2012-02-01 11:56 -0600 |
| Message-ID | <odrii75khfocg8gg4u1a5rmmgqspt8ajl6@4ax.com> |
| In reply to | #16563 |
On Tue, 31 Jan 2012 23:50:30 -0600, "Charles Richmond"
<netnews@aquaporin4.com> wrote:
>"Patrick Scheible" <kkt@zipcon.net> wrote in message
>news:86aa53e59d.fsf@zipcon.net...
>> Keith Thompson <kst-u@mib.org> 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.
>>
>
>So just *remove* trigraphs from the *next* C standard. Or require the
>preprocessor symbol "__TRIGRAPH_IMPLEMENTED__" to be defined, or relegate
>this to a PRAGMA... before trigraphs would be recognized by the compiler.
>Make it *extra* hard for the ordinary C programmer to step on this land
>mine.
Just to add to the pile don't all current mainstream* compilers
already offer options to toggle trigraph (and digraph) parsing?
And have for quite awhile now. For example, no trigraph parsing has
been the default for MSC since MSC 5.1 (1985?) or at least MSC 6
(v12).
[* by mainstream I meant major popular "3rd party" compilers and
developer packages, and not the compilers often included with O/Ss,
particularily in the UNIX world.]
-ralph
[toc] | [prev] | [next] | [standalone]
| From | Patrick Scheible <kkt@zipcon.net> |
|---|---|
| Date | 2012-02-01 11:12 -0800 |
| Message-ID | <8662fqtljd.fsf@zipcon.net> |
| In reply to | #16563 |
"Charles Richmond" <netnews@aquaporin4.com> writes:
> "Patrick Scheible" <kkt@zipcon.net> wrote in message
> news:86aa53e59d.fsf@zipcon.net...
>> Keith Thompson <kst-u@mib.org> 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.
>>
>
> So just *remove* trigraphs from the *next* C standard. Or require the
> preprocessor symbol "__TRIGRAPH_IMPLEMENTED__" to be defined, or
> relegate this to a PRAGMA... before trigraphs would be recognized by
> the compiler. Make it *extra* hard for the ordinary C programmer to
> step on this land mine.
Yes, this is the best thing to do now, since it's to late to have never
put them in the language in the first place.
-- Patrick
[toc] | [prev] | [next] | [standalone]
| From | Stephen Sprunk <stephen@sprunk.org> |
|---|---|
| Date | 2012-02-01 13:29 -0600 |
| Message-ID | <jgc3qn$t83$1@dont-email.me> |
| In reply to | #16563 |
On 31-Jan-12 23:50, Charles Richmond wrote:
>> Keith Thompson <kst-u@mib.org> writes:
>>> 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.
>>>
>>> ??= # ??) ] ??! |
>>> ??( [ ??' ^ ??> }
>>> ??/ \ ??< { ??- ~
...
> So just *remove* trigraphs from the *next* C standard. Or require the
> preprocessor symbol "__TRIGRAPH_IMPLEMENTED__" to be defined,
How would that help? If someone knows to check for that symbol,
presumably they also know not to inadvertently use trigraphs.
> or relegate this to a PRAGMA... before trigraphs would be recognized
> by the compiler.
You couldn't use a #pragma to enable trigraphs since # is one of the
characters that may require a trigraph. See above.
S
--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking
[toc] | [prev] | [next] | [standalone]
| From | blp@cs.stanford.edu (Ben Pfaff) |
|---|---|
| Date | 2012-02-01 11:35 -0800 |
| Message-ID | <87vcnql53a.fsf@blp.benpfaff.org> |
| In reply to | #16607 |
Stephen Sprunk <stephen@sprunk.org> writes:
> On 31-Jan-12 23:50, Charles Richmond wrote:
>> or relegate this to a PRAGMA... before trigraphs would be recognized
>> by the compiler.
>
> You couldn't use a #pragma to enable trigraphs since # is one of the
> characters that may require a trigraph. See above.
You could use a %:pragma to enable trigraphs.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
[toc] | [prev] | [next] | [standalone]
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Date | 2012-02-01 19:59 +0000 |
| Message-ID | <20120201115334.897@kylheku.com> |
| In reply to | #16608 |
On 2012-02-01, Ben Pfaff <blp@cs.stanford.edu> wrote: > Stephen Sprunk <stephen@sprunk.org> writes: > >> On 31-Jan-12 23:50, Charles Richmond wrote: >>> or relegate this to a PRAGMA... before trigraphs would be recognized >>> by the compiler. >> >> You couldn't use a #pragma to enable trigraphs since # is one of the >> characters that may require a trigraph. See above. > > You could use a %:pragma to enable trigraphs. Even better: ??=pragma :)
[toc] | [prev] | [next] | [standalone]
| From | blp@cs.stanford.edu (Ben Pfaff) |
|---|---|
| Date | 2012-02-01 12:41 -0800 |
| Message-ID | <87r4yel216.fsf@blp.benpfaff.org> |
| In reply to | #16612 |
Kaz Kylheku <kaz@kylheku.com> writes:
> On 2012-02-01, Ben Pfaff <blp@cs.stanford.edu> wrote:
>> Stephen Sprunk <stephen@sprunk.org> writes:
>>
>>> On 31-Jan-12 23:50, Charles Richmond wrote:
>>>> or relegate this to a PRAGMA... before trigraphs would be recognized
>>>> by the compiler.
>>>
>>> You couldn't use a #pragma to enable trigraphs since # is one of the
>>> characters that may require a trigraph. See above.
>>
>> You could use a %:pragma to enable trigraphs.
>
> Even better:
>
> ??=pragma
You couldn't use ??=pragma to enable trigraphs because ??= is a
trigraph. See above.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | comp.lang.c
csiph-web