[project @ 2002-01-22 13:09:36 by simonmar]
authorsimonmar <unknown>
Tue, 22 Jan 2002 13:09:37 +0000 (13:09 +0000)
committersimonmar <unknown>
Tue, 22 Jan 2002 13:09:37 +0000 (13:09 +0000)
Fix for a change in CPP's behaviour in gcc 2.96 relative to 2.95.
Unlit used to inject '# <line> <file>' at the beginning of the output
file, but in gcc 2.96 this is ignored.  Instead we have to inject
'#line <line> <file>', 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.

ghc/compiler/parser/Lex.lhs
ghc/utils/unlit/unlit.c

index 5880ee1..1a7855c 100644 (file)
@@ -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
index 8c170e5..a454351 100644 (file)
@@ -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);