Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/mdocml/dist Initial import mdocml-1.9.9.



details:   https://anonhg.NetBSD.org/src/rev/4fc1aeec541f
branches:  trunk
changeset: 748351:4fc1aeec541f
user:      joerg <joerg%NetBSD.org@localhost>
date:      Wed Oct 21 17:45:02 2009 +0000

description:
Initial import mdocml-1.9.9.

mdocml provides a fast parser for man(7) and mdoc(7) formated documents.
It supports validation and can currently create output as plain text
with overstriking and HTML.

diffstat:

 external/bsd/mdocml/dist/arch.c          |    32 +
 external/bsd/mdocml/dist/arch.in         |    52 +
 external/bsd/mdocml/dist/att.c           |    32 +
 external/bsd/mdocml/dist/att.in          |    37 +
 external/bsd/mdocml/dist/chars.c         |   204 ++
 external/bsd/mdocml/dist/chars.h         |    34 +
 external/bsd/mdocml/dist/chars.in        |   418 +++++
 external/bsd/mdocml/dist/compat.c        |    90 +
 external/bsd/mdocml/dist/external.png.uu |     7 +
 external/bsd/mdocml/dist/html.c          |   653 ++++++++
 external/bsd/mdocml/dist/html.h          |   133 +
 external/bsd/mdocml/dist/lib.c           |    32 +
 external/bsd/mdocml/dist/lib.in          |    57 +
 external/bsd/mdocml/dist/libman.h        |   116 +
 external/bsd/mdocml/dist/libmandoc.h     |    26 +
 external/bsd/mdocml/dist/libmdoc.h       |   188 ++
 external/bsd/mdocml/dist/main.c          |   676 +++++++++
 external/bsd/mdocml/dist/main.h          |    47 +
 external/bsd/mdocml/dist/man.3           |   283 +++
 external/bsd/mdocml/dist/man.7           |   589 +++++++
 external/bsd/mdocml/dist/man.c           |   632 ++++++++
 external/bsd/mdocml/dist/man.h           |   116 +
 external/bsd/mdocml/dist/man_action.c    |   222 ++
 external/bsd/mdocml/dist/man_argv.c      |    99 +
 external/bsd/mdocml/dist/man_hash.c      |    77 +
 external/bsd/mdocml/dist/man_html.c      |   701 +++++++++
 external/bsd/mdocml/dist/man_macro.c     |   375 +++++
 external/bsd/mdocml/dist/man_term.c      |   992 +++++++++++++
 external/bsd/mdocml/dist/man_validate.c  |   281 +++
 external/bsd/mdocml/dist/mandoc.1        |   416 +++++
 external/bsd/mdocml/dist/mandoc.c        |   105 +
 external/bsd/mdocml/dist/mandoc_char.7   |   616 ++++++++
 external/bsd/mdocml/dist/manuals.7       |   236 +++
 external/bsd/mdocml/dist/mdoc.3          |   336 ++++
 external/bsd/mdocml/dist/mdoc.7          |  1775 +++++++++++++++++++++++
 external/bsd/mdocml/dist/mdoc.c          |   755 ++++++++++
 external/bsd/mdocml/dist/mdoc.h          |   304 ++++
 external/bsd/mdocml/dist/mdoc_action.c   |   984 +++++++++++++
 external/bsd/mdocml/dist/mdoc_argv.c     |   771 ++++++++++
 external/bsd/mdocml/dist/mdoc_hash.c     |    88 +
 external/bsd/mdocml/dist/mdoc_html.c     |  2222 ++++++++++++++++++++++++++++++
 external/bsd/mdocml/dist/mdoc_macro.c    |  1352 ++++++++++++++++++
 external/bsd/mdocml/dist/mdoc_strings.c  |   241 +++
 external/bsd/mdocml/dist/mdoc_term.c     |  2072 +++++++++++++++++++++++++++
 external/bsd/mdocml/dist/mdoc_validate.c |  1311 +++++++++++++++++
 external/bsd/mdocml/dist/msec.c          |    32 +
 external/bsd/mdocml/dist/msec.in         |    40 +
 external/bsd/mdocml/dist/out.c           |   119 +
 external/bsd/mdocml/dist/out.h           |    58 +
 external/bsd/mdocml/dist/st.c            |    32 +
 external/bsd/mdocml/dist/st.in           |    68 +
 external/bsd/mdocml/dist/style.css       |    68 +
 external/bsd/mdocml/dist/term.c          |   638 ++++++++
 external/bsd/mdocml/dist/term.h          |    61 +
 external/bsd/mdocml/dist/tree.c          |   208 ++
 external/bsd/mdocml/dist/vol.c           |    32 +
 external/bsd/mdocml/dist/vol.in          |    35 +
 57 files changed, 22176 insertions(+), 0 deletions(-)

diffs (truncated from 22404 to 300 lines):

diff -r 7b838a1fcbbc -r 4fc1aeec541f external/bsd/mdocml/dist/arch.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/mdocml/dist/arch.c   Wed Oct 21 17:45:02 2009 +0000
@@ -0,0 +1,32 @@
+/*     $Vendor-Id: arch.c,v 1.4 2009/06/10 20:18:43 kristaps Exp $ */
+/*
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "libmdoc.h"
+
+#define LINE(x, y) \
+       if (0 == strcmp(p, x)) return(y);
+
+const char *
+mdoc_a2arch(const char *p)
+{
+
+#include "arch.in" 
+
+       return(NULL);
+}
diff -r 7b838a1fcbbc -r 4fc1aeec541f external/bsd/mdocml/dist/arch.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/mdocml/dist/arch.in  Wed Oct 21 17:45:02 2009 +0000
@@ -0,0 +1,52 @@
+/*     $Vendor-Id: arch.in,v 1.5 2009/06/10 20:18:43 kristaps Exp $ */
+/*
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This file defines the architecture token of the .Dt prologue macro.
+ * All architectures that your system supports (or the manuals of your
+ * system) should be included here.  The right-hand-side is the
+ * formatted output.
+ *
+ * Be sure to escape strings.
+ */
+
+LINE("alpha",          "Alpha")
+LINE("amd64",          "AMD64")
+LINE("amiga",          "Amiga")
+LINE("arc",            "ARC")
+LINE("arm",            "ARM")
+LINE("armish",         "ARMISH")
+LINE("aviion",         "AViiON")
+LINE("hp300",          "HP300")
+LINE("hppa",           "HPPA")
+LINE("hppa64",         "HPPA64")
+LINE("i386",           "i386")
+LINE("landisk",                "LANDISK")
+LINE("luna88k",                "Luna88k")
+LINE("mac68k",         "Mac68k")
+LINE("macppc",         "MacPPC")
+LINE("mvme68k",                "MVME68k")
+LINE("mvme88k",                "MVME88k")
+LINE("mvmeppc",                "MVMEPPC")
+LINE("pmax",           "PMAX")
+LINE("sgi",            "SGI")
+LINE("socppc",         "SOCPPC")
+LINE("sparc",          "SPARC")
+LINE("sparc64",                "SPARC64")
+LINE("sun3",           "Sun3")
+LINE("vax",            "VAX")
+LINE("zaurus",         "Zaurus")
diff -r 7b838a1fcbbc -r 4fc1aeec541f external/bsd/mdocml/dist/att.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/mdocml/dist/att.c    Wed Oct 21 17:45:02 2009 +0000
@@ -0,0 +1,32 @@
+/*     $Vendor-Id: att.c,v 1.4 2009/06/10 20:18:43 kristaps Exp $ */
+/*
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "libmdoc.h"
+
+#define LINE(x, y) \
+       if (0 == strcmp(p, x)) return(y);
+
+const char *
+mdoc_a2att(const char *p)
+{
+
+#include "att.in" 
+
+       return(NULL);
+}
diff -r 7b838a1fcbbc -r 4fc1aeec541f external/bsd/mdocml/dist/att.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/mdocml/dist/att.in   Wed Oct 21 17:45:02 2009 +0000
@@ -0,0 +1,37 @@
+/*     $Vendor-Id: att.in,v 1.5 2009/06/10 20:18:43 kristaps Exp $ */
+/*
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This file defines the AT&T versions of the .At macro.  This probably
+ * isn't going to change.  The right-hand side is the formatted string.
+ *
+ * Be sure to escape strings.
+ */
+
+LINE("v1",             "Version 1 AT&T UNIX")
+LINE("v2",             "Version 2 AT&T UNIX")
+LINE("v3",             "Version 3 AT&T UNIX")
+LINE("v4",             "Version 4 AT&T UNIX")
+LINE("v5",             "Version 5 AT&T UNIX")
+LINE("v6",             "Version 6 AT&T UNIX")
+LINE("v7",             "Version 7 AT&T UNIX")
+LINE("32v",            "Version 32V AT&T UNIX")
+LINE("V",              "AT&T System V UNIX")
+LINE("V.1",            "AT&T System V.1 UNIX")
+LINE("V.2",            "AT&T System V.2 UNIX")
+LINE("V.3",            "AT&T System V.3 UNIX")
+LINE("V.4",            "AT&T System V.4 UNIX")
diff -r 7b838a1fcbbc -r 4fc1aeec541f external/bsd/mdocml/dist/chars.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/mdocml/dist/chars.c  Wed Oct 21 17:45:02 2009 +0000
@@ -0,0 +1,204 @@
+/*     $Vendor-Id: chars.c,v 1.9 2009/09/23 11:02:21 kristaps Exp $ */
+/*
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "chars.h"
+
+#define        PRINT_HI         126
+#define        PRINT_LO         32
+
+struct ln {
+       struct ln        *next;
+       const char       *code;
+       const char       *ascii;
+       const char       *html;
+       size_t            codesz;
+       size_t            asciisz;
+       size_t            htmlsz;
+       int               type;
+#define        CHARS_CHAR       (1 << 0)
+#define        CHARS_STRING     (1 << 1)
+#define CHARS_BOTH      (0x03)
+};
+
+#define        LINES_MAX         351
+
+#define CHAR(w, x, y, z, a, b) \
+       { NULL, (w), (y), (a), (x), (z), (b), CHARS_CHAR },
+#define STRING(w, x, y, z, a, b) \
+       { NULL, (w), (y), (a), (x), (z), (b), CHARS_STRING },
+#define BOTH(w, x, y, z, a, b) \
+       { NULL, (w), (y), (a), (x), (z), (b), CHARS_BOTH },
+
+static struct ln lines[LINES_MAX] = {
+#include "chars.in"
+};
+
+struct tbl {
+       enum chars        type;
+       struct ln       **htab;
+};
+
+static inline int        match(const struct ln *,
+                               const char *, size_t, int);
+static const char       *find(struct tbl *, const char *, 
+                               size_t, size_t *, int);
+
+
+void
+chars_free(void *arg)
+{
+       struct tbl      *tab;
+
+       tab = (struct tbl *)arg;
+
+       free(tab->htab);
+       free(tab);
+}
+
+
+void *
+chars_init(enum chars type)
+{
+       struct tbl       *tab;
+       struct ln       **htab;
+       struct ln        *pp;
+       int               i, hash;
+
+       /*
+        * Constructs a very basic chaining hashtable.  The hash routine
+        * is simply the integral value of the first character.
+        * Subsequent entries are chained in the order they're processed
+        * (they're in-line re-ordered during lookup).
+        */
+
+       if (NULL == (tab = malloc(sizeof(struct tbl))))
+               err(1, "malloc");
+       tab->type = type;
+
+       htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **));
+       if (NULL == htab)
+               err(1, "malloc");
+
+       for (i = 0; i < LINES_MAX; i++) {
+               hash = (int)lines[i].code[0] - PRINT_LO;
+
+               if (NULL == (pp = htab[hash])) {
+                       htab[hash] = &lines[i];
+                       continue;
+               }
+
+               for ( ; pp->next; pp = pp->next)
+                       /* Scan ahead. */ ;
+               pp->next = &lines[i];
+       }
+
+       tab->htab = htab;
+       return(tab);
+}
+
+
+const char *
+chars_a2ascii(void *arg, const char *p, size_t sz, size_t *rsz)
+{
+
+       return(find((struct tbl *)arg, p, sz, rsz, CHARS_CHAR));
+}
+
+
+const char *
+chars_a2res(void *arg, const char *p, size_t sz, size_t *rsz)



Home | Main Index | Thread Index | Old Index