Admin message

Due to a large amount of spam we do not allow new users to create repositories, they are "external" users. If you are a new user and want to create a repository, for example for forking GHC, open a new issue on ghc/ghc using the "get-verified" issue template

literate markdown not handled correctly by unlit
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? <details><summary>Trac metadata</summary> | Trac field | Value | | ---------------------- | ---------------- | | Version | 7.0.1 | | Type | Bug | | TypeOfFailure | OtherFailure | | Priority | normal | | Resolution | Unresolved | | Component | Compiler | | Test case | | | Differential revisions | | | BlockedBy | | | Related | | | Blocking | | | CC | dagitj@gmail.com | | Operating system | | | Architecture | | </details> <!-- {"blocked_by":[],"summary":"literate markdown not handled correctly by unlit","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["dagitj@gmail.com"],"type":"Bug","description":"This simple program in literate haskell, using markdown in the comments gives unlit problems:\r\n{{{\r\n### Ok so lets try this again.\r\n\r\n### A page that loads and compiles:\r\n\r\n> myfact 0 = 1 \r\n> myfact n = n * n-1\r\n\r\nLets see if it works!\r\n}}}\r\n\r\nIf I run unlit and collect the output I can see where it went wrong:\r\n{{{\r\n$ ~/lib/ghc-7.0.1/unlit Main.lhs Main.lpp\r\n$ cat Main.lpp\r\n### Ok so lets try this again.\r\n\r\n### A page that loads and compiles:\r\n\r\n myfact 0 = 1 \r\n myfact n = n * n-1\r\n\r\n\r\n}}}\r\n\r\nWhen I look through the source code of unlit.c I think the place to check for this would be here:\r\n{{{\r\n if ( c == '#' ) {\r\n if ( ignore_shebang ) {\r\n c1 = egetc(istream);\r\n if ( c1 == '!' ) {\r\n while (c=egetc(istream), !isLineTerm(c)) ;\r\n return SHEBANG;\r\n }\r\n myputc(c, ostream);\r\n c=c1;\r\n }\r\n if ( leavecpp ) {\r\n myputc(c, ostream);\r\n while (c=egetc(istream), !isLineTerm(c))\r\n myputc(c,ostream);\r\n myputc('\\n',ostream);\r\n return HASH;\r\n }\r\n }\r\n}}}\r\n\r\nIt seems that cabal has a similar unlit function:\r\nhttp://www.haskell.org/ghc/docs/latest/html/libraries/Cabal-1.10.0.0/src/Distribution-Simple-PreProcess-Unlit.html#unlit\r\n\r\nI 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?","type_of_failure":"OtherFailure","blocking":[]} -->
issue