| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,14 @@ | |||
| 1 | + 2011-03-07 Bastian Maerkisch <bmaerkisch@web.de> | ||
| 2 | + | ||
| 3 | + * docs/windows/doc2html.c (main): change command line options, | ||
| 4 | + (convert, header, footer) optionally split html files manually | ||
| 5 | + [SPLIT_FILES] (Note: this will produce ~500 files!), optionally | ||
| 6 | + create index file manually [CREATE_INDEX], always use hard-coded | ||
| 7 | + links as none of the open source viewers seem to support k-links | ||
| 8 | + | ||
| 9 | + * config/makefile.mgw, config/watcom/Makefile, config/mingw/Makefile: | ||
| 10 | + change command line accordingly | ||
| 11 | + | ||
| 1 | 12 | 2011-03-06 Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de> | |
| 2 | 13 | ||
| 3 | 14 | * config/watcom/.cvsignore: Set up list of files to be ignored. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | #ifndef lint | |
| 2 | - static char *RCSid() { return RCSid("$Id: doc2html.c,v 1.2 2011/02/28 11:40:40 markisch Exp $"); } | ||
| 2 | + static char *RCSid() { return RCSid("$Id: doc2html.c,v 1.3 2011/02/28 11:53:40 markisch Exp $"); } | ||
| 3 | 3 | #endif | |
| 4 | 4 | ||
| 5 | 5 | /* GNUPLOT - doc2html.c */ | |
@@ -40,7 +40,7 @@ static char *RCSid() { return RCSid("$Id: doc2html.c,v 1.2 2011/02/28 11:40:40 m | |||
| 40 | 40 | * | |
| 41 | 41 | * Derived from doc2rtf and doc2html (version 3.7.3) by B. Maerkisch | |
| 42 | 42 | * | |
| 43 | - * usage: doc2html file.doc file.html file.htc [-d] | ||
| 43 | + * usage: doc2html file.doc outputdirectory [-d] | ||
| 44 | 44 | * | |
| 45 | 45 | */ | |
| 46 | 46 | ||
@@ -51,6 +51,14 @@ static char *RCSid() { return RCSid("$Id: doc2html.c,v 1.2 2011/02/28 11:40:40 m | |||
| 51 | 51 | # include "config.h" | |
| 52 | 52 | #endif | |
| 53 | 53 | ||
| 54 | + #ifdef WXHELP | ||
| 55 | + /* The Microsoft help compiler splits topics and creates the index automatically. | ||
| 56 | + To create help files for wxWidgets we need to do this manually. | ||
| 57 | + Note that this might overwrite the stub index file from CVS. */ | ||
| 58 | + #define SPLIT_FILES | ||
| 59 | + #define CREATE_INDEX | ||
| 60 | + #endif | ||
| 61 | + | ||
| 54 | 62 | #include "syscfg.h" | |
| 55 | 63 | #include "stdfn.h" | |
| 56 | 64 | #define MAX_LINE_LEN 10230 | |
@@ -59,90 +67,137 @@ static char *RCSid() { return RCSid("$Id: doc2html.c,v 1.2 2011/02/28 11:40:40 m | |||
| 59 | 67 | #include "version.h" | |
| 60 | 68 | ||
| 61 | 69 | static TBOOLEAN debug = FALSE; | |
| 70 | + static char path[PATH_MAX]; | ||
| 71 | + static const char basename[] = "wgnuplot"; | ||
| 62 | 72 | ||
| 63 | - void convert __PROTO((FILE *, FILE *, FILE *)); | ||
| 64 | - void process_line __PROTO((char *, FILE *, FILE *)); | ||
| 73 | + void convert __PROTO((FILE *, FILE *, FILE *, FILE *)); | ||
| 74 | + void process_line __PROTO((char *, FILE *, FILE *, FILE *)); | ||
| 65 | 75 | ||
| 66 | 76 | int | |
| 67 | 77 | main (int argc, char **argv) | |
| 68 | 78 | { | |
| 69 | 79 | FILE *infile; | |
| 70 | 80 | FILE *outfile; | |
| 71 | 81 | FILE *contents; | |
| 72 | - if (argc == 5 && argv[4][0] == '-' && argv[4][1] == 'd') | ||
| 73 | - debug = TRUE; | ||
| 82 | + FILE *index = NULL; | ||
| 83 | + char filename[PATH_MAX]; | ||
| 84 | + char *last_char; | ||
| 74 | 85 | ||
| 75 | - if (argc != 4 && !debug) { | ||
| 76 | - fprintf(stderr, "Usage: %s infile outfile contentfile\n", argv[0]); | ||
| 86 | + if (argc == 4 && argv[3][0] == '-' && argv[3][1] == 'd') | ||
| 87 | + debug = TRUE; | ||
| 88 | + if (argc != 3 && !debug) { | ||
| 89 | + fprintf(stderr, "Usage: %s infile outpath\n", argv[0]); | ||
| 77 | 90 | exit(EXIT_FAILURE); | |
| 78 | 91 | } | |
| 79 | 92 | if ((infile = fopen(argv[1], "r")) == (FILE *) NULL) { | |
| 80 | 93 | fprintf(stderr, "%s: Can't open %s for reading\n", | |
| 81 | 94 | argv[0], argv[1]); | |
| 82 | 95 | exit(EXIT_FAILURE); | |
| 83 | 96 | } | |
| 84 | - if ((outfile = fopen(argv[2], "w")) == (FILE *) NULL) { | ||
| 97 | + strcpy(path, argv[2]); | ||
| 98 | + /* make sure there's a path separator at the end */ | ||
| 99 | + last_char = path + strlen(path); | ||
| 100 | + if ((*last_char != DIRSEP1) && (*last_char != DIRSEP2)) { | ||
| 101 | + *last_char++ = DIRSEP1; | ||
| 102 | + *last_char = 0; | ||
| 103 | + } | ||
| 104 | + strcpy(filename, path); | ||
| 105 | + strcat(filename, basename); | ||
| 106 | + strcat(filename, ".html"); | ||
| 107 | + if ((outfile = fopen(filename, "w")) == (FILE *) NULL) { | ||
| 108 | + fprintf(stderr, "%s: Can't open %s for writing\n", | ||
| 109 | + argv[0], filename); | ||
| 110 | + fclose(infile); | ||
| 111 | + exit(EXIT_FAILURE); | ||
| 112 | + } | ||
| 113 | + strcpy(filename, path); | ||
| 114 | + strcat(filename, basename); | ||
| 115 | + strcat(filename, ".hhc"); | ||
| 116 | + if ((contents = fopen(filename, "w")) == (FILE *) NULL) { | ||
| 85 | 117 | fprintf(stderr, "%s: Can't open %s for writing\n", | |
| 86 | - argv[0], argv[2]); | ||
| 118 | + argv[0], filename); | ||
| 87 | 119 | fclose(infile); | |
| 120 | + fclose(outfile); | ||
| 88 | 121 | exit(EXIT_FAILURE); | |
| 89 | 122 | } | |
| 90 | - if ((contents = fopen(argv[3], "w")) == (FILE *) NULL) { | ||
| 123 | + #ifdef CREATE_INDEX | ||
| 124 | + strcpy(filename, path); | ||
| 125 | + strcat(filename, basename); | ||
| 126 | + strcat(filename, ".hhk"); | ||
| 127 | + if ((index = fopen(filename, "w")) == (FILE *) NULL) { | ||
| 91 | 128 | fprintf(stderr, "%s: Can't open %s for writing\n", | |
| 92 | - argv[0], argv[3]); | ||
| 129 | + argv[0], filename); | ||
| 93 | 130 | fclose(infile); | |
| 94 | 131 | fclose(outfile); | |
| 132 | + fclose(contents); | ||
| 95 | 133 | exit(EXIT_FAILURE); | |
| 96 | 134 | } | |
| 135 | + #endif | ||
| 97 | 136 | parse(infile); | |
| 98 | - convert(infile, outfile, contents); | ||
| 137 | + convert(infile, outfile, contents, index); | ||
| 99 | 138 | return EXIT_SUCCESS; | |
| 100 | 139 | } | |
| 101 | 140 | ||
| 102 | 141 | ||
| 103 | 142 | void | |
| 104 | - convert(FILE *a, FILE *b, FILE *c) | ||
| 143 | + header(FILE *a, char * title) | ||
| 144 | + { | ||
| 145 | + /* generate html header */ | ||
| 146 | + fprintf(a, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); | ||
| 147 | + fprintf(a, "<html>\n"); | ||
| 148 | + fprintf(a, "<head>\n"); | ||
| 149 | + fprintf(a, "<meta http-equiv=\"Content-type\" content=\"text/html; charset=windows-1252\">\n"); | ||
| 150 | + fprintf(a, "<title>%s</title>\n", title); | ||
| 151 | + fprintf(a, "</head>\n"); | ||
| 152 | + fprintf(a, "<body>\n"); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + | ||
| 156 | + void | ||
| 157 | + footer(FILE *a) | ||
| 158 | + { | ||
| 159 | + /* close final page and generate trailer */ | ||
| 160 | + fprintf(a, "</body>\n"); | ||
| 161 | + fprintf(a, "</html>\n"); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + | ||
| 165 | + void | ||
| 166 | + convert(FILE *a, FILE *b, FILE *c, FILE *d) | ||
| 105 | 167 | { | |
| 106 | 168 | static char line[MAX_LINE_LEN+1]; | |
| 107 | 169 | ||
| 108 | - /* generate html header */ | ||
| 109 | - fprintf(b, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); | ||
| 110 | - fprintf(b, "<html>\n"); | ||
| 111 | - fprintf(b, "<head>\n"); | ||
| 112 | - fprintf(b, "<meta http-equiv=\"Content-type\" content=\"text/html; charset=windows-1252\">\n"); | ||
| 113 | - fprintf(b, "<title>gnuplot help</title>\n"); | ||
| 114 | - fprintf(b, "</head>\n"); | ||
| 115 | - fprintf(b, "<body>\n"); | ||
| 170 | + header(b, "gnuplot help"); | ||
| 116 | 171 | fprintf(b, "<h1 align=\"center\">gnuplot %s patchlevel %s</h1>\n", gnuplot_version, gnuplot_patchlevel); | |
| 117 | 172 | ||
| 118 | - /* generate html header */ | ||
| 119 | - fprintf(c, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); | ||
| 120 | - fprintf(c, "<html>\n"); | ||
| 121 | - fprintf(c, "<head>\n"); | ||
| 122 | - fprintf(c, "<meta http-equiv=\"Content-type\" content=\"text/html; charset=windows-1252\">\n"); | ||
| 123 | - fprintf(c, "<title>gnuplot help contents</title>\n"); | ||
| 124 | - fprintf(c, "</head>\n"); | ||
| 125 | - fprintf(c, "<body>\n"); | ||
| 173 | + header(c, "gnuplot help contents"); | ||
| 126 | 174 | fprintf(c, "<ul>\n"); | |
| 127 | 175 | ||
| 176 | + if (d) { | ||
| 177 | + header(d, "gnuplot help index"); | ||
| 178 | + fprintf(d, "<ul>\n"); | ||
| 179 | + } | ||
| 180 | + | ||
| 128 | 181 | /* process each line of the file */ | |
| 129 | 182 | while (get_line(line, sizeof(line), a)) { | |
| 130 | - process_line(line, b, c); | ||
| 183 | + process_line(line, b, c, d); | ||
| 131 | 184 | } | |
| 132 | 185 | ||
| 133 | - /* close final page and generate trailer */ | ||
| 134 | - fprintf(b, "</BODY>\n"); | ||
| 135 | - fprintf(b, "</HTML>\n"); | ||
| 186 | + footer(b); | ||
| 136 | 187 | ||
| 137 | - /* close final page and generate trailer */ | ||
| 138 | 188 | fprintf(c, "</ul>\n"); | |
| 139 | - fprintf(c, "</BODY>\n"); | ||
| 140 | - fprintf(c, "</HTML>\n"); | ||
| 189 | + footer(c); | ||
| 190 | + | ||
| 191 | + if (d) { | ||
| 192 | + fprintf(d, "</ul>\n"); | ||
| 193 | + footer(d); | ||
| 194 | + } | ||
| 195 | + | ||
| 141 | 196 | list_free(); | |
| 142 | 197 | } | |
| 143 | 198 | ||
| 144 | 199 | void | |
| 145 | - process_line(char *line, FILE *b, FILE *c) | ||
| 200 | + process_line(char *line, FILE *b, FILE *c, FILE *d) | ||
| 146 | 201 | { | |
| 147 | 202 | static int line_count = 0; | |
| 148 | 203 | static char line2[MAX_LINE_LEN+1]; | |
@@ -159,12 +214,11 @@ process_line(char *line, FILE *b, FILE *c) | |||
| 159 | 214 | static TBOOLEAN inquote = FALSE; | |
| 160 | 215 | static int inref = 0; | |
| 161 | 216 | static int klink = 0; /* link number counter */ | |
| 162 | - | ||
| 217 | + static char location[PATH_MAX+1] = {0}; | ||
| 163 | 218 | struct LIST *klist; | |
| 164 | - | ||
| 165 | 219 | int i, j, k, l; | |
| 166 | - line_count++; | ||
| 167 | 220 | ||
| 221 | + line_count++; | ||
| 168 | 222 | i = 0; | |
| 169 | 223 | j = 0; | |
| 170 | 224 | while (line[i] != NUL) { | |
@@ -204,8 +258,10 @@ process_line(char *line, FILE *b, FILE *c) | |||
| 204 | 258 | klist = lookup(topic); | |
| 205 | 259 | if (klist && (k = klist->line) > 0 && (k != last_line)) { | |
| 206 | 260 | char hyplink1[MAX_LINE_LEN+1]; | |
| 261 | + #if 0 | ||
| 262 | + /* K-link: index lookup via ActiveX and JavaScript. */ | ||
| 263 | + /* Deactivated, as none of the open source viewers seem to support this */ | ||
| 207 | 264 | char id[15]; | |
| 208 | - #ifndef HTML_HARDLINKS | ||
| 209 | 265 | sprintf(id, "link%i", ++klink); | |
| 210 | 266 | sprintf(hyplink1, "<OBJECT id=%s type=\"application/x-oleobject\" classid=\"clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11\">\n" | |
| 211 | 267 | " <PARAM name=\"Command\" value=\"KLink\">\n" | |
@@ -217,10 +273,11 @@ process_line(char *line, FILE *b, FILE *c) | |||
| 217 | 273 | if (debug) | |
| 218 | 274 | fprintf(stderr, "hyper link \"%s\" - %s on line %d\n", topic, id, line_count); | |
| 219 | 275 | #else | |
| 276 | + /* explicit links */ | ||
| 220 | 277 | if ((klist->line) > 1) | |
| 221 | 278 | sprintf(hyplink1, "<a href=\"loc%d.html\">", klist->line); | |
| 222 | 279 | else | |
| 223 | - sprintf(hyplink1, "<a href=\"wgnuplot.html\">"); | ||
| 280 | + sprintf(hyplink1, "<a href=\"%s.html\">", basename); | ||
| 224 | 281 | if (debug) | |
| 225 | 282 | fprintf(stderr, "hyper link \"%s\" - loc%d.html on line %d\n", topic, klist->line, line_count); | |
| 226 | 283 | #endif | |
@@ -276,13 +333,21 @@ process_line(char *line, FILE *b, FILE *c) | |||
| 276 | 333 | case '?': /* interactive help entry */ | |
| 277 | 334 | case '=': /* latex index entry */ | |
| 278 | 335 | if ((line2[1] != NUL) && (line2[1] != ' ')) { | |
| 336 | + #ifndef CREATE_INDEX | ||
| 279 | 337 | if (!inkey) { | |
| 280 | 338 | /* open keyword object */ | |
| 281 | 339 | fprintf(b, "<OBJECT type=\"application/x-oleobject\" classid=\"clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e\">\n"); | |
| 282 | 340 | inkey = TRUE; | |
| 283 | 341 | } | |
| 284 | 342 | /* add keyword */ | |
| 285 | 343 | fprintf(b, " <param name=\"Keyword\" value=\"%s\">\n", &line2[1]); | |
| 344 | + #else | ||
| 345 | + fprintf(d, "<li> <object type=\"text/sitemap\">\n"); | ||
| 346 | + fprintf(d, " <param name=\"Name\" value=\"%s\">\n", &line2[1]); | ||
| 347 | + fprintf(d, " <param name=\"Local\" value=\"%s.html\">\n", location); | ||
| 348 | + fprintf(d, " </object>\n"); | ||
| 349 | + /* NB: don't set inkey here */ | ||
| 350 | + #endif | ||
| 286 | 351 | if (debug) | |
| 287 | 352 | fprintf(stderr,"keyword defintion: \"%s\" on line %d.\n", line2 + 1, line_count); | |
| 288 | 353 | } | |
@@ -377,7 +442,6 @@ process_line(char *line, FILE *b, FILE *c) | |||
| 377 | 442 | } | |
| 378 | 443 | default:{ | |
| 379 | 444 | if (isdigit((int)line[0])) { /* start of section */ | |
| 380 | - char location[MAX_LINE_LEN+1]; | ||
| 381 | 445 | int newlevel = line[0]-'0'; | |
| 382 | 446 | char spacer[10]; | |
| 383 | 447 | ||
@@ -398,16 +462,41 @@ process_line(char *line, FILE *b, FILE *c) | |||
| 398 | 462 | fprintf(b, "\n"); | |
| 399 | 463 | ||
| 400 | 464 | /* output unique ID */ | |
| 401 | - sprintf(location, "loc%d", line_count); | ||
| 465 | + if (!startpage) | ||
| 466 | + sprintf(location, "loc%d", line_count); | ||
| 467 | + else | ||
| 468 | + strcpy(location, basename); | ||
| 402 | 469 | ||
| 403 | - /* split contents */ | ||
| 470 | + #ifndef SPLIT_FILES | ||
| 471 | + /* let hhc auomatically split contents */ | ||
| 404 | 472 | if (!startpage) { | |
| 405 | 473 | fprintf(b, "<OBJECT type=\"application/x-oleobject\" classid=\"clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e\">\n"); | |
| 406 | 474 | fprintf(b, "<param name=\"New HTML file\" value=\"%s.html\">\n", location); | |
| 407 | 475 | fprintf(b, "<param name=\"New HTML title\" value=\"%s\">\n", &line2[2]); | |
| 408 | 476 | fprintf(b, "</OBJECT>\n"); | |
| 409 | 477 | fprintf(b, "<h2>%s</h2>\n", &line2[2]); | |
| 410 | 478 | } | |
| 479 | + #else | ||
| 480 | + /* split contents manually */ | ||
| 481 | + if (!startpage) { | ||
| 482 | + char newfile[PATH_MAX]; | ||
| 483 | + | ||
| 484 | + /* close current file */ | ||
| 485 | + footer(b); | ||
| 486 | + fclose(b); | ||
| 487 | + | ||
| 488 | + /* open new file */ | ||
| 489 | + sprintf(newfile, "%s%s.html", path, location); | ||
| 490 | + /* fprintf(stderr, "%s\n", newfile); */ | ||
| 491 | + if (!(b = fopen(newfile, "w"))) { | ||
| 492 | + fprintf(stderr, "%s: Can't open %s for writing\n", | ||
| 493 | + "doc2html", newfile); | ||
| 494 | + exit(EXIT_FAILURE); | ||
| 495 | + } | ||
| 496 | + header(b, &line2[2]); | ||
| 497 | + fprintf(b, "<h2>%s</h2>\n", &line2[2]); | ||
| 498 | + } | ||
| 499 | + #endif | ||
| 411 | 500 | ||
| 412 | 501 | /* create toc entry */ | |
| 413 | 502 | if (newlevel > level) { | |
@@ -427,7 +516,7 @@ process_line(char *line, FILE *b, FILE *c) | |||
| 427 | 516 | spacer[level] = NUL; | |
| 428 | 517 | fprintf(c, "%s<li> <OBJECT type=\"text/sitemap\">\n", spacer); | |
| 429 | 518 | fprintf(c, "%s <param name=\"Name\" value=\"%s\">\n", spacer, &line2[2]); | |
| 430 | - fprintf(c, "%s <param name=\"Local\" value=\"%s.html\">\n", spacer, startpage ? "wgnuplot" : location); | ||
| 519 | + fprintf(c, "%s <param name=\"Local\" value=\"%s.html\">\n", spacer, location); | ||
| 431 | 520 | fprintf(c, "%s </OBJECT>\n", spacer); | |
| 432 | 521 | if (debug) | |
| 433 | 522 | fprintf(stderr, "Section \"%s\", Level %i, ID=%s on line %d\n", line2 + 2, level, location, line_count); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments