Ticket #4836 (new bug)
literate markdown not handled correctly by unlit
| Reported by: | guest | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 7.6.2 |
| Component: | Compiler | Version: | 7.0.1 |
| Keywords: | Cc: | dagitj@…, jmg@…, trevor@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | GHC rejects valid program | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: | #7120 |
Description
This simple program in literate haskell, using markdown in the comments gives unlit problems:
### Ok so lets try this again. ### A page that loads and compiles: > myfact 0 = 1 > myfact n = n * n-1 Lets see if it works!
If I run unlit and collect the output I can see where it went wrong:
$ ~/lib/ghc-7.0.1/unlit Main.lhs Main.lpp $ cat Main.lpp ### Ok so lets try this again. ### A page that loads and compiles: myfact 0 = 1 myfact n = n * n-1
When I look through the source code of unlit.c I think the place to check for this would be here:
if ( c == '#' ) {
if ( ignore_shebang ) {
c1 = egetc(istream);
if ( c1 == '!' ) {
while (c=egetc(istream), !isLineTerm(c)) ;
return SHEBANG;
}
myputc(c, ostream);
c=c1;
}
if ( leavecpp ) {
myputc(c, ostream);
while (c=egetc(istream), !isLineTerm(c))
myputc(c,ostream);
myputc('\n',ostream);
return HASH;
}
}
It seems that cabal has a similar unlit function: http://www.haskell.org/ghc/docs/latest/html/libraries/Cabal-1.10.0.0/src/Distribution-Simple-PreProcess-Unlit.html#unlit
I haven't tested it but, I think the cabal version would handle this case correctly (or be easier to fix than a C program from 1990). Would it be possible/wise/feasible to extract the cabal version and make it a permanent replacement for the current unlit.c code?
