diff options
author | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
---|---|---|
committer | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
commit | 84c2ad99582391005b5e873198b15e9e9eb4f78d (patch) | |
tree | caa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /utils/unlit | |
parent | 8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff) | |
parent | e68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff) | |
download | haskell-wip/T13904.tar.gz |
update to current master againwip/T13904
Diffstat (limited to 'utils/unlit')
-rw-r--r-- | utils/unlit/ghc.mk | 2 | ||||
-rw-r--r-- | utils/unlit/unlit.c | 19 | ||||
-rw-r--r-- | utils/unlit/unlit.cabal | 17 |
3 files changed, 28 insertions, 10 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 new file mode 100644 index 0000000000..622a55934d --- /dev/null +++ b/utils/unlit/unlit.cabal @@ -0,0 +1,17 @@ +cabal-version: 2.1 +Name: unlit +Version: 0.1 +Copyright: XXX +License: BSD-3-Clause +Author: XXX +Maintainer: XXX +Synopsis: Literate program filter +Description: XXX +Category: Development +build-type: Simple + +Executable unlit + Default-Language: Haskell2010 + Main-Is: unlit.c + C-Sources: unlit.c, fs.c + Includes: fs.h |