2 # Patch managed by http://www.holgerschurig.de/patcher.html
4 # This patch is against htmldoc 1.8.24, and it hacks in support for
5 # correctly indenting the <div class=""> sections in the SWIG manual.
6 # This patch should only be used until the 1.9 branch of htmldoc
7 # stabalizes, since the 1.9 branch includes true CSS1 support.
9 # This patch only affects the PDF generation, an unpatched htmldoc
10 # creates the one-page html documentation just fine.
12 --- htmldoc-1.8.24/htmldoc/ps-pdf.cxx~margin-left
13 +++ htmldoc-1.8.24/htmldoc/ps-pdf.cxx
18 +extern int lookup_div_class(uchar *);
22 @@ -4188,9 +4189,24 @@
23 para->child = para->last_child = NULL;
26 - parse_doc(t->child, left, right, bottom, top, x, y, page, NULL,
31 + if (cname = htmlGetVariable(t, (uchar *)"class")) {
32 + num_indent = lookup_div_class(cname);
33 + *left += 5.0f * num_indent;
37 + parse_doc(t->child, left, right, bottom, top, x, y, page, NULL,
40 + if (num_indent > 0) {
41 + *left -= 5.0f * num_indent;
45 if (para->child != NULL)
47 parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace);
48 --- htmldoc-1.8.24/htmldoc/htmldoc.cxx~margin-left
49 +++ htmldoc-1.8.24/htmldoc/htmldoc.cxx
51 const char *__XOS2RedirRoot(const char *);
55 +extern void parse_style(char *);
59 @@ -2140,6 +2142,10 @@
61 else if (strcmp(temp, "--cookies") == 0)
63 + else if (strcmp(temp, "--stylesheet") == 0)
71 +++ htmldoc-1.8.24/htmldoc/style.cxx
73 +/* Extreamly simple parsing routines for CSS style sheets.
74 + * We only parse div.class { } sections, and only look
75 + * for margin-left: <num>em;
77 + * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu>
79 + * Released under GNU GPL v2 or above.
90 +#define BUFF_SIZE 512
93 + uchar class_name[BUFF_SIZE];
95 + struct div_entry *next;
98 +static struct div_entry *head = 0;
100 +/* These are the parsing states */
101 +#define IGNORE_TILL_SEMI 0
102 +#define IGNORE_TILL_CLOSE_BRACE 1
103 +#define READING_DIV 2
104 +#define READING_CLASS 3
105 +#define READING_ATTRIBUTE 4
106 +#define READING_NUM 5
107 +#define CHECKING_ONLY_DIV 6
109 +static int at_eof = 0;
111 +static int strucmp(uchar *a, uchar *b) {
113 + for (i = 0; a[i] && b[i]; i++) {
114 + if (a[i] < b[i]) return -1;
115 + if (a[i] > b[i]) return 1;
117 + /* This isn't right, but who cares...*/
118 + if (a[i] || b[i]) return 1;
122 +static int read_word(FILE *f, const char *word) {
124 + for (int idx = 0; word[idx]; idx++) {
130 + if (c != word[idx])
136 +int lookup_div_class(uchar *name) {
137 + struct div_entry *node = head;
140 + if (strucmp(node->class_name, name) == 0)
141 + return node->indent;
148 +void parse_style(char *fname) {
152 + struct div_entry *cur = 0;
154 + char num[BUFF_SIZE];
157 + if (!fname) return;
159 + f = fopen(fname, "r");
161 + fprintf(stderr, "Unable to parse style\n");
165 + state = READING_DIV;
166 + while (!at_eof && (c = getc(f)) != EOF) {
169 + case IGNORE_TILL_SEMI:
171 + state = READING_ATTRIBUTE;
174 + case IGNORE_TILL_CLOSE_BRACE:
176 + state = READING_DIV;
180 + if (c != ' ' && c != '\t' && c != '\n') {
181 + if (c == 'd' && read_word(f, "iv.")) {
182 + state = READING_CLASS;
183 + cur = (struct div_entry *) malloc(sizeof(struct div_entry));
184 + memset(cur, 0, sizeof(struct div_entry));
187 + state = IGNORE_TILL_CLOSE_BRACE;
191 + case READING_CLASS:
193 + if (class_idx >= BUFF_SIZE-1) {
194 + fprintf(stderr, "class size %s too long\n", cur->class_name);
196 + state = IGNORE_TILL_CLOSE_BRACE;
198 + cur->class_name[class_idx++] = c;
204 + state = READING_ATTRIBUTE;
206 + state = CHECKING_ONLY_DIV;
210 + case READING_ATTRIBUTE:
211 + if (c != ' ' && c != '\t' && c != '\n') {
213 + state = READING_DIV;
215 + if (c == 'm' && read_word(f, "argin-left:")) {
217 + memset(num, 0, sizeof(num));
218 + state = READING_NUM;
220 + state = IGNORE_TILL_SEMI;
228 + if (num_idx >= BUFF_SIZE - 1) {
229 + fprintf(stderr, "Number too long\n");
230 + state = IGNORE_TILL_SEMI;
232 + num[num_idx++] = c;
234 + } else if (c != ' ' && c != '\t') {
235 + if (num_idx > 0 && c == 'e' && read_word(f, "m"))
236 + cur->indent = atoi(num);
237 + state = IGNORE_TILL_SEMI;
241 + case CHECKING_ONLY_DIV:
242 + if (c != ' ' && c != '\t' && c != '\n') {
246 + state = READING_ATTRIBUTE;
249 + state = IGNORE_TILL_CLOSE_BRACE;
258 --- htmldoc-1.8.24/htmldoc/Makefile~margin-left
259 +++ htmldoc-1.8.24/htmldoc/Makefile
262 OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o http.o \
263 http-addr.o http-support.o image.o iso8859.o license.o md5.o \
264 - progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o
265 + progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o style.o