summaryrefslogtreecommitdiff
path: root/utils/unlit
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2018-03-29 14:22:09 +0100
committerTamar Christina <tamar@zhox.com>2018-03-31 10:11:53 +0100
commit4de585a5c1ac3edc2914cebcac1753b514051a89 (patch)
tree09bfb4251808007bb4ad79c6f10f3e4fbe3e9312 /utils/unlit
parentafb686a88901d7d0c93627806d7e4d0444aa17e8 (diff)
downloadhaskell-4de585a5c1ac3edc2914cebcac1753b514051a89.tar.gz
Remove MAX_PATH restrictions from RTS, I/O manager and various utilities
Summary: This shims out fopen and sopen so that they use modern APIs under the hood along with namespaced paths. This lifts the MAX_PATH restrictions from Haskell programs and makes the new limit ~32k. There are only some slight caveats that have been documented. Some utilities have not been upgraded such as lndir, since all these things are different cabal packages I have been forced to copy the source in different places which is less than ideal. But it's the only way to keep sdist working. Test Plan: ./validate Reviewers: hvr, bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #10822 Differential Revision: https://phabricator.haskell.org/D4416
Diffstat (limited to 'utils/unlit')
-rw-r--r--utils/unlit/ghc.mk2
-rw-r--r--utils/unlit/unlit.c19
-rw-r--r--utils/unlit/unlit.cabal3
3 files changed, 13 insertions, 11 deletions
diff --git a/utils/unlit/ghc.mk b/utils/unlit/ghc.mk
index 8911f4e856..0560aa57b8 100644
--- a/utils/unlit/ghc.mk
+++ b/utils/unlit/ghc.mk
@@ -11,7 +11,7 @@
# -----------------------------------------------------------------------------
# built by ghc-stage0
-utils/unlit_dist_C_SRCS = unlit.c
+utils/unlit_dist_C_SRCS = unlit.c fs.c
utils/unlit_dist_PROGNAME = unlit
utils/unlit_dist_TOPDIR = YES
utils/unlit_dist_INSTALL_INPLACE = YES
diff --git a/utils/unlit/unlit.c b/utils/unlit/unlit.c
index 4eb91d71be..97f853b268 100644
--- a/utils/unlit/unlit.c
+++ b/utils/unlit/unlit.c
@@ -7,7 +7,7 @@
* column on each line. It is hoped that this style of programming will
* encourage the writing of accurate and clearly documented programs
* in which the writer may include motivating arguments, examples
- * and explanations.
+ * and explanations.
*
* Unlit is a filter that can be used to strip all of the comment lines
* out of a literate script file. The command format for unlit is:
@@ -40,6 +40,7 @@
* And \begin{pseudocode} ... \end{pseudocode}. -- LA
*/
+#include "fs.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@@ -115,7 +116,7 @@ static void myputc(char c, FILE *ostream)
{
if (putc(c,ostream) == EOF) {
writeerror();
- }
+ }
}
#define TABPOS 8
@@ -179,7 +180,7 @@ static line readline(FILE *istream, FILE *ostream) {
if (c==EOF)
return ENDFILE;
-
+
if ( c == '#' ) {
if ( ignore_shebang ) {
c1 = egetc(istream);
@@ -335,10 +336,10 @@ int main(int argc,char **argv)
else if (strcmp(*argv,"-h")==0) {
if (argc > 1) {
argc--; argv++;
- if (prefix_str)
+ if (prefix_str)
free(prefix_str);
prefix_str = (char*)malloc(sizeof(char)*(1+strlen(*argv)));
- if (prefix_str)
+ if (prefix_str)
strcpy(prefix_str, *argv);
}
} else if (strcmp(*argv,"-#")==0)
@@ -362,16 +363,16 @@ int main(int argc,char **argv)
file = "stdin";
}
else
- if ((istream=fopen(argv[0], "r")) == NULL) {
+ if ((istream=__hs_fopen(argv[0], "r")) == NULL) {
fprintf(stderr, CANNOTOPEN, argv[0]);
exit(1);
}
ofilename=argv[1];
- if (strcmp(argv[1], "-")==0)
- ostream = stdout;
+ if (strcmp(argv[1], "-")==0)
+ ostream = stdout;
else
- if ((ostream=fopen(argv[1], "w")) == NULL) {
+ if ((ostream=__hs_fopen(argv[1], "w")) == NULL) {
fprintf(stderr, CANNOTOPEN, argv[1]);
exit(1);
}
diff --git a/utils/unlit/unlit.cabal b/utils/unlit/unlit.cabal
index a621f04bc7..622a55934d 100644
--- a/utils/unlit/unlit.cabal
+++ b/utils/unlit/unlit.cabal
@@ -13,4 +13,5 @@ build-type: Simple
Executable unlit
Default-Language: Haskell2010
Main-Is: unlit.c
- C-Sources: unlit.c
+ C-Sources: unlit.c, fs.c
+ Includes: fs.h