aboutsummaryrefslogtreecommitdiff
path: root/Doc/Manual/margin-left.patch
diff options
context:
space:
mode:
authorJohn Lenz <jlenz2@math.uiuc.edu>2005-03-30 05:55:46 +0000
committerJohn Lenz <jlenz2@math.uiuc.edu>2005-03-30 05:55:46 +0000
commitdf8516b78200789ccf3f69153e4f87817dcbf9d3 (patch)
treeed722c73f896509c9a75538a8d5cfdaee11ef755 /Doc/Manual/margin-left.patch
parent803084552f92532f09da3198d02b7e35631a90e4 (diff)
downloadswig-df8516b78200789ccf3f69153e4f87817dcbf9d3.tar.gz
Update documentation and add margin-left.patch file for htmldoc
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7117 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Doc/Manual/margin-left.patch')
-rw-r--r--Doc/Manual/margin-left.patch269
1 files changed, 269 insertions, 0 deletions
diff --git a/Doc/Manual/margin-left.patch b/Doc/Manual/margin-left.patch
new file mode 100644
index 000000000..70f087b92
--- /dev/null
+++ b/Doc/Manual/margin-left.patch
@@ -0,0 +1,269 @@
+#
+# Patch managed by http://www.holgerschurig.de/patcher.html
+#
+# This patch is against htmldoc 1.8.24, and it hacks in support for
+# correctly indenting the <div class=""> sections in the SWIG manual.
+# This patch should only be used until the 1.9 branch of htmldoc
+# stabalizes, since the 1.9 branch includes true CSS1 support.
+#
+# This patch only affects the PDF generation, an unpatched htmldoc
+# creates the one-page html documentation just fine.
+#
+--- htmldoc-1.8.24/htmldoc/ps-pdf.cxx~margin-left
++++ htmldoc-1.8.24/htmldoc/ps-pdf.cxx
+@@ -158,6 +158,7 @@
+ # undef page_t
+ #endif // __hpux
+
++extern int lookup_div_class(uchar *);
+
+ /*
+ * Constants...
+@@ -4188,9 +4189,24 @@
+ para->child = para->last_child = NULL;
+ }
+
+- parse_doc(t->child, left, right, bottom, top, x, y, page, NULL,
++ {
++ int num_indent = 0;
++ uchar *cname;
++
++ if (cname = htmlGetVariable(t, (uchar *)"class")) {
++ num_indent = lookup_div_class(cname);
++ *left += 5.0f * num_indent;
++ *x = *left;
++ }
++
++ parse_doc(t->child, left, right, bottom, top, x, y, page, NULL,
+ needspace);
+
++ if (num_indent > 0) {
++ *left -= 5.0f * num_indent;
++ }
++ }
++
+ if (para->child != NULL)
+ {
+ parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace);
+--- htmldoc-1.8.24/htmldoc/htmldoc.cxx~margin-left
++++ htmldoc-1.8.24/htmldoc/htmldoc.cxx
+@@ -62,6 +62,8 @@
+ const char *__XOS2RedirRoot(const char *);
+ }
+ #endif
++
++extern void parse_style(char *);
+
+
+ /*
+@@ -2140,6 +2142,10 @@
+ }
+ else if (strcmp(temp, "--cookies") == 0)
+ file_cookies(temp2);
++ else if (strcmp(temp, "--stylesheet") == 0)
++ {
++ parse_style(temp2);
++ }
+ }
+ }
+
+--- /dev/null
++++ htmldoc-1.8.24/htmldoc/style.cxx
+@@ -0,0 +1,185 @@
++/* Extreamly simple parsing routines for CSS style sheets.
++ * We only parse div.class { } sections, and only look
++ * for margin-left: <num>em;
++ *
++ * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu>
++ *
++ * Released under GNU GPL v2 or above.
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <fcntl.h>
++#include <string.h>
++#include <ctype.h>
++
++#include "types.h"
++
++#define BUFF_SIZE 512
++
++struct div_entry {
++ uchar class_name[BUFF_SIZE];
++ int indent;
++ struct div_entry *next;
++};
++
++static struct div_entry *head = 0;
++
++/* These are the parsing states */
++#define IGNORE_TILL_SEMI 0
++#define IGNORE_TILL_CLOSE_BRACE 1
++#define READING_DIV 2
++#define READING_CLASS 3
++#define READING_ATTRIBUTE 4
++#define READING_NUM 5
++#define CHECKING_ONLY_DIV 6
++
++static int at_eof = 0;
++
++static int strucmp(uchar *a, uchar *b) {
++ int i;
++ for (i = 0; a[i] && b[i]; i++) {
++ if (a[i] < b[i]) return -1;
++ if (a[i] > b[i]) return 1;
++ }
++ /* This isn't right, but who cares...*/
++ if (a[i] || b[i]) return 1;
++ return 0;
++}
++
++static int read_word(FILE *f, const char *word) {
++ char c;
++ for (int idx = 0; word[idx]; idx++) {
++ c = getc(f);
++ if (c == EOF) {
++ at_eof = 1;
++ return 0;
++ }
++ if (c != word[idx])
++ return 0;
++ }
++ return 1;
++}
++
++int lookup_div_class(uchar *name) {
++ struct div_entry *node = head;
++
++ while (node) {
++ if (strucmp(node->class_name, name) == 0)
++ return node->indent;
++ node = node->next;
++ }
++
++ return 0;
++}
++
++void parse_style(char *fname) {
++ FILE *f;
++ char c;
++ int state;
++ struct div_entry *cur = 0;
++ int class_idx = 0;
++ char num[BUFF_SIZE];
++ int num_idx = 0;
++
++ if (!fname) return;
++
++ f = fopen(fname, "r");
++ if (!f) {
++ fprintf(stderr, "Unable to parse style\n");
++ return;
++ }
++
++ state = READING_DIV;
++ while (!at_eof && (c = getc(f)) != EOF) {
++ switch (state) {
++
++ case IGNORE_TILL_SEMI:
++ if (c == ';')
++ state = READING_ATTRIBUTE;
++ break;
++
++ case IGNORE_TILL_CLOSE_BRACE:
++ if (c == '}')
++ state = READING_DIV;
++ break;
++
++ case READING_DIV:
++ if (c != ' ' && c != '\t' && c != '\n') {
++ if (c == 'd' && read_word(f, "iv.")) {
++ state = READING_CLASS;
++ cur = (struct div_entry *) malloc(sizeof(struct div_entry));
++ memset(cur, 0, sizeof(struct div_entry));
++ class_idx = 0;
++ } else
++ state = IGNORE_TILL_CLOSE_BRACE;
++ }
++ break;
++
++ case READING_CLASS:
++ if (isalpha(c)) {
++ if (class_idx >= BUFF_SIZE-1) {
++ fprintf(stderr, "class size %s too long\n", cur->class_name);
++ free(cur);
++ state = IGNORE_TILL_CLOSE_BRACE;
++ } else {
++ cur->class_name[class_idx++] = c;
++ }
++ } else {
++ if (c == '{') {
++ cur->next = head;
++ head = cur;
++ state = READING_ATTRIBUTE;
++ } else
++ state = CHECKING_ONLY_DIV;
++ }
++ break;
++
++ case READING_ATTRIBUTE:
++ if (c != ' ' && c != '\t' && c != '\n') {
++ if (c == '}')
++ state = READING_DIV;
++ else {
++ if (c == 'm' && read_word(f, "argin-left:")) {
++ num_idx = 0;
++ memset(num, 0, sizeof(num));
++ state = READING_NUM;
++ } else {
++ state = IGNORE_TILL_SEMI;
++ }
++ }
++ }
++ break;
++
++ case READING_NUM:
++ if (isdigit(c)) {
++ if (num_idx >= BUFF_SIZE - 1) {
++ fprintf(stderr, "Number too long\n");
++ state = IGNORE_TILL_SEMI;
++ } else {
++ num[num_idx++] = c;
++ }
++ } else if (c != ' ' && c != '\t') {
++ if (num_idx > 0 && c == 'e' && read_word(f, "m"))
++ cur->indent = atoi(num);
++ state = IGNORE_TILL_SEMI;
++ }
++ break;
++
++ case CHECKING_ONLY_DIV:
++ if (c != ' ' && c != '\t' && c != '\n') {
++ if (c == '{') {
++ cur->next = head;
++ head = cur;
++ state = READING_ATTRIBUTE;
++ } else {
++ free(cur);
++ state = IGNORE_TILL_CLOSE_BRACE;
++ }
++ }
++ break;
++ }
++ }
++
++ fclose(f);
++}
+--- htmldoc-1.8.24/htmldoc/Makefile~margin-left
++++ htmldoc-1.8.24/htmldoc/Makefile
+@@ -35,7 +35,7 @@
+
+ OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o http.o \
+ http-addr.o http-support.o image.o iso8859.o license.o md5.o \
+- progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o
++ progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o style.o
+
+
+ #
+