#3921: hsc2hs and Windows line endings on linux
-------------------------------------+--------------------------------------
    Reporter:  guest                 |        Owner:                    
        Type:  bug                   |       Status:  new               
    Priority:  normal                |    Milestone:                    
   Component:  hsc2hs                |      Version:  6.12.1            
    Keywords:  Windows line endings  |   Difficulty:                    
          Os:  Unknown/Multiple      |     Testcase:                    
Architecture:  Unknown/Multiple      |      Failure:  Compile-time crash
-------------------------------------+--------------------------------------
Description changed by igloo:

Old description:

> There seems to be a problem when compiling a file under Linux which has
> Windows line endings and uses #let 's in the file.
>
> A simple example would be
>
> module Main where
>
> #let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t
> (y__); }, y__)
>
> main :: IO ()
> main = return ()
>
> which does nothing really, but should compile.
>
> this fails under linux (when the file was saved using windows line
> endings) with the error
>
> 1.Broken.hsc:4: error: expected identifier or ‘(’ before ‘)’ token
> 2.compiling Broken_hsc_make.c failed
>
> looking at the generated .c file
>
> 4.#include "/usr/lib/ghc-6.12.1/template-hsc.h"
> 5.#line 3 "Broken.hsc"
> 6.#define hsc_alignment(t ) printf ( "%lu", (unsigned
> long)offsetof(struct {char x__; t (y__); }, y__)
> 7.);
> 8.  <truncated>
>
> on line 6 the closing ");" was pushed to a new line, 7, but this causes
> the define to end unexpectedly and cauzes the syntax error mention above.
> This is presumably because only the "\n" and the "\r" are left in there.
>
> also the generated code contains a mixture of both endings, which is no
> problem for ghc and gcc but might be for some editors:
>
> 18.    fputs ("\r\n"
> 19.           "", stdout);
> 20.    fputs ("\n"
> 21.           "", stdout);

New description:

 There seems to be a problem when compiling a file under Linux which has
 Windows line endings and uses #let 's in the file.

 A simple example would be
 {{{
 module Main where

 #let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t
 (y__); }, y__)

 main :: IO ()
 main = return ()
 }}}
 which does nothing really, but should compile.

 this fails under linux (when the file was saved using windows line
 endings) with the error
 {{{
 1.Broken.hsc:4: error: expected identifier or ‘(’ before ‘)’ token
 2.compiling Broken_hsc_make.c failed
 }}}
 looking at the generated .c file
 {{{
 4.#include "/usr/lib/ghc-6.12.1/template-hsc.h"
 5.#line 3 "Broken.hsc"
 6.#define hsc_alignment(t ) printf ( "%lu", (unsigned long)offsetof(struct
 {char x__; t (y__); }, y__)
 7.);
 8.  <truncated>
 }}}
 on line 6 the closing ");" was pushed to a new line, 7, but this causes
 the define to end unexpectedly and cauzes the syntax error mention above.
 This is presumably because only the "\n" and the "\r" are left in there.

 also the generated code contains a mixture of both endings, which is no
 problem for ghc and gcc but might be for some editors:
 {{{
 18.    fputs ("\r\n"
 19.           "", stdout);
 20.    fputs ("\n"
 21.           "", stdout);
 }}}

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3921#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to