# HG changeset patch # User Mike Becker # Date 1373456726 -7200 # Node ID 7ce5c4b51959d729b34b78955338865f82176ac5 # Parent c59fe73459fd42da7c67e1d78432306e6432df20 option for plaintext diff -r c59fe73459fd -r 7ce5c4b51959 Makefile --- a/Makefile Wed Jul 10 13:38:28 2013 +0200 +++ b/Makefile Wed Jul 10 13:45:26 2013 +0200 @@ -37,7 +37,7 @@ $(MKDIR) build test: compile - ./build/$(BIN) src/c2html.c > build/body.html + ./build/$(BIN) $(ARGS) src/c2html.c > build/body.html cat test/header.html build/body.html test/footer.html > build/code.html clean: diff -r c59fe73459fd -r 7ce5c4b51959 src/c2html.c --- a/src/c2html.c Wed Jul 10 13:38:28 2013 +0200 +++ b/src/c2html.c Wed Jul 10 13:45:26 2013 +0200 @@ -47,6 +47,7 @@ typedef struct { char* outfilename; char* infilename; + int highlight; } settings_t; typedef struct { @@ -227,15 +228,19 @@ settings_t settings; settings.outfilename = NULL; + settings.highlight = 1; char optc; - while ((optc = getopt(argc, argv, "ho:")) != -1) { + while ((optc = getopt(argc, argv, "ho:p")) != -1) { switch (optc) { case 'o': if (!(optarg[0] == '-' && optarg[1] == 0)) { settings.outfilename = optarg; } break; + case 'p': + settings.highlight = 0; + break; case 'h': printhelp(); return 0; @@ -259,10 +264,15 @@ fout = stdout; } fprintf(fout, "
\n");
-      char *line = (char*) malloc(inputfile->maxlinewidth*64);
+      char *line = (char*) malloc(inputfile->maxlinewidth
+          * (settings.highlight?64:0));
       int lnw = lnint(inputfile->count);
       for (int i = 0 ; i < inputfile->count ; i++) {
-        parseline(inputfile->lines[i], line);
+        if (settings.highlight) {
+          parseline(inputfile->lines[i], line);
+        } else {
+          line = inputfile->lines[i];
+        }
         fprintf(fout, "%*d: %s",
             lnw, i, line);
       }