From: simonmar Date: Tue, 22 Jan 2002 13:09:37 +0000 (+0000) Subject: [project @ 2002-01-22 13:09:36 by simonmar] X-Git-Tag: Approximately_9120_patches~278 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c1980f1ddbe8b5a3ee5fb28dd0236bf4900881c5;p=ghc-hetmet.git [project @ 2002-01-22 13:09:36 by simonmar] Fix for a change in CPP's behaviour in gcc 2.96 relative to 2.95. Unlit used to inject '# ' at the beginning of the output file, but in gcc 2.96 this is ignored. Instead we have to inject '#line ', which in turn means that GHC's lexer has to understand this kind of pragma in addition to the plain '#' form, in the case when we aren't running CPP after unlitting. --- diff --git a/ghc/compiler/parser/Lex.lhs b/ghc/compiler/parser/Lex.lhs index 5880ee1..1a7855c 100644 --- a/ghc/compiler/parser/Lex.lhs +++ b/ghc/compiler/parser/Lex.lhs @@ -455,9 +455,15 @@ lexer cont buf s@(PState{ -- special GHC extension: we grok cpp-style #line pragmas '#'# | lexemeIndex buf ==# bol -> -- the '#' must be in column 0 - case expandWhile# is_space (stepOn buf) of { buf1 -> - if is_digit (currentChar# buf1) - then line_prag next_line buf1 s' + let buf1 | lookAhead# buf 1# `eqChar#` 'l'# && + lookAhead# buf 2# `eqChar#` 'i'# && + lookAhead# buf 3# `eqChar#` 'n'# && + lookAhead# buf 4# `eqChar#` 'e'# = stepOnBy# buf 5# + | otherwise = stepOn buf + in + case expandWhile# is_space buf1 of { buf2 -> + if is_digit (currentChar# buf2) + then line_prag next_line buf2 s' else is_a_token } where diff --git a/ghc/utils/unlit/unlit.c b/ghc/utils/unlit/unlit.c index 8c170e5..a454351 100644 --- a/ghc/utils/unlit/unlit.c +++ b/ghc/utils/unlit/unlit.c @@ -348,8 +348,8 @@ char **argv; { } /* Prefix the output with line pragmas */ - if (prefix_str) { - fprintf(ostream, "# 1 \"%s\"\n{-# LINE 1 \"%s\" #-}\n", prefix_str, prefix_str); + if (add_line_prag_long) { + fprintf(ostream, "# 1 \"%s\"\n");{-# LINE 1 \"%s\" #-}\n", prefix_str, prefix_str); } unlit(file, istream, ostream);