Re: trigraphs, yecch

Discussion in 'C Programming' started by Keith Thompson, Jan 31, 2012.

  1. (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) <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"
     
    Keith Thompson, Jan 31, 2012
    #1
    1. Advertising

  2. Keith Thompson <> writes:

    > (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
     
    Patrick Scheible, Feb 1, 2012
    #2
    1. Advertising

  3. Patrick Scheible <> 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) <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"
     
    Keith Thompson, Feb 1, 2012
    #3
  4. Keith Thompson

    James Kuyper Guest

    On 01/31/2012 08:01 PM, Patrick Scheible wrote:
    > Keith Thompson <> 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
     
    James Kuyper, Feb 1, 2012
    #4
  5. "Patrick Scheible" <> wrote in message
    news:...
    > Keith Thompson <> writes:
    >
    >> (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 |
    +<><><><><><><><><><><><><><><><><><><>+
     
    Charles Richmond, Feb 1, 2012
    #5
  6. 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
     
    Joachim Schmitz, Feb 1, 2012
    #6
  7. Keith Thompson

    Kaz Kylheku Guest

    On 2012-02-01, James Kuyper <> 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.
     
    Kaz Kylheku, Feb 1, 2012
    #7
  8. Keith Thompson

    ralph Guest

    On Tue, 31 Jan 2012 23:50:30 -0600, "Charles Richmond"
    <> wrote:

    >"Patrick Scheible" <> wrote in message
    >news:...
    >> Keith Thompson <> writes:
    >>
    >>> (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
     
    ralph, Feb 1, 2012
    #8
  9. Keith Thompson <> writes:

    > Patrick Scheible <> 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
     
    Patrick Scheible, Feb 1, 2012
    #9
  10. James Kuyper <> writes:

    > On 01/31/2012 08:01 PM, Patrick Scheible wrote:
    >> Keith Thompson <> 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
     
    Patrick Scheible, Feb 1, 2012
    #10
  11. "Charles Richmond" <> writes:

    > "Patrick Scheible" <> wrote in message
    > news:...
    >> Keith Thompson <> writes:
    >>
    >>> (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
     
    Patrick Scheible, Feb 1, 2012
    #11
  12. On 31-Jan-12 23:50, Charles Richmond wrote:
    >> Keith Thompson <> 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
     
    Stephen Sprunk, Feb 1, 2012
    #12
  13. Keith Thompson

    Ben Pfaff Guest

    Stephen Sprunk <> 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;}}}
     
    Ben Pfaff, Feb 1, 2012
    #13
  14. Keith Thompson

    Kaz Kylheku Guest

    On 2012-02-01, Ben Pfaff <> wrote:
    > Stephen Sprunk <> 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

    :)
     
    Kaz Kylheku, Feb 1, 2012
    #14
  15. Keith Thompson

    Ben Pfaff Guest

    Kaz Kylheku <> writes:

    > On 2012-02-01, Ben Pfaff <> wrote:
    >> Stephen Sprunk <> 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;}}}
     
    Ben Pfaff, Feb 1, 2012
    #15
  16. On 01-Feb-12 13:35, Ben Pfaff wrote:
    > Stephen Sprunk <> 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.


    Or, to avoid creating yet another bizarre sequence of symbols, you could
    create a special exception for "??=pragma trigraph", without recognizing
    any other trigraphs by default.

    However, that still seems like a hack; it seems more straightforward to
    allow implementations to optionally ignore trigraphs via some external
    means, which is the status quo anyway.

    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
     
    Stephen Sprunk, Feb 1, 2012
    #16
  17. Keith Thompson

    Kaz Kylheku Guest

    On 2012-02-01, Stephen Sprunk <> wrote:
    > On 01-Feb-12 13:35, Ben Pfaff wrote:
    >> Stephen Sprunk <> 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.

    >
    > Or, to avoid creating yet another bizarre sequence of symbols, you could
    > create a special exception for "??=pragma trigraph", without recognizing
    > any other trigraphs by default.


    No special exception! ??=pragma trigraph enables trigraphs, but ??= is not
    recognized until trigraphs are enabled.

    That is the perfect solution.
     
    Kaz Kylheku, Feb 1, 2012
    #17
  18. Keith Thompson

    Kaz Kylheku Guest

    On 2012-02-01, Ben Pfaff <> wrote:
    > Kaz Kylheku <> writes:
    >
    >> On 2012-02-01, Ben Pfaff <> wrote:
    >>> Stephen Sprunk <> 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.


    So you understand the point perfectly!
     
    Kaz Kylheku, Feb 1, 2012
    #18
  19. Keith Thompson

    Joe keane Guest

    Joe keane, Feb 2, 2012
    #19
  20. "christian.bau" <> writes:

    > On Feb 1, 5:50 am, "Charles Richmond" <> wrote:
    >
    >> 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.

    >
    > A change that would silently break existing code.


    How much existing code uses trigraphs?

    -- Patrick
     
    Patrick Scheible, Feb 7, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher Benson-Manica

    Trigraphs

    Christopher Benson-Manica, Sep 12, 2003, in forum: C Programming
    Replies:
    33
    Views:
    1,333
    Tom Zych
    Sep 18, 2003
  2. Vijay Kumar R Zanvar

    Trigraphs & entry

    Vijay Kumar R Zanvar, Nov 4, 2003, in forum: C Programming
    Replies:
    14
    Views:
    677
    Mark McIntyre
    Nov 5, 2003
  3. Daniel Rudy

    Trigraphs

    Daniel Rudy, Nov 7, 2005, in forum: C Programming
    Replies:
    39
    Views:
    1,343
    Michael Wojcik
    Jan 6, 2006
  4. Ben Bacarisse

    Re: trigraphs, yecch

    Ben Bacarisse, Jan 31, 2012, in forum: C Programming
    Replies:
    9
    Views:
    278
    James Kuyper
    Feb 1, 2012
  5. Peter Nilsson

    Re: trigraphs, yecch

    Peter Nilsson, Jan 31, 2012, in forum: C Programming
    Replies:
    7
    Views:
    242
    Ben Bacarisse
    Feb 1, 2012
Loading...

Share This Page