[project @ 2003-08-20 15:10:22 by simonmar]
[ghc-hetmet.git] / ghc / utils / unlit / unlit.c
index a454351..78d8de0 100644 (file)
@@ -41,6 +41,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 
 #define NULLSTR        ((char *)0)
@@ -348,8 +349,15 @@ char **argv; {
         }
 
     /* Prefix the output with line pragmas */
-    if (add_line_prag_long) {
-      fprintf(ostream, "# 1 \"%s\"\n");{-# LINE 1 \"%s\" #-}\n", prefix_str, prefix_str);
+    if (prefix_str) {
+      /* Both GHC and CPP understand the #line pragma.
+       * We used to throw in both a #line and a {-# LINE #-} pragma
+       * here, but CPP doesn't understand {-# LINE #-} so it thought
+       * the line numbers were off by one.  We could put the {-# LINE
+       * #-} before the #line, but there's no point since GHC
+       * understands #line anyhow.  --SDM 8/2003
+       */
+      fprintf(ostream, "#line 1 \"%s\"\n", prefix_str, prefix_str);
     }
 
     unlit(file, istream, ostream);