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 Import mdocml-1.9.14:



details:   https://anonhg.NetBSD.org/src/rev/0f0f41d057d6
branches:  trunk
changeset: 749078:0f0f41d057d6
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Nov 16 22:26:45 2009 +0000

description:
Import mdocml-1.9.14:
- fixed proper font cascading (no double-mode in -Tascii)
- added correct scoping of \f
- fixed handling of \c for all input/outputs

diffstat:

 external/bsd/mdocml/dist/chars.c       |    7 +-
 external/bsd/mdocml/dist/chars.in      |   11 +-
 external/bsd/mdocml/dist/html.c        |  234 ++++++++++-----------
 external/bsd/mdocml/dist/html.h        |   14 +-
 external/bsd/mdocml/dist/man.7         |   66 ++++-
 external/bsd/mdocml/dist/man_html.c    |   74 +++---
 external/bsd/mdocml/dist/man_term.c    |  160 ++++-----------
 external/bsd/mdocml/dist/mandoc.1      |  193 +++++++++++++-----
 external/bsd/mdocml/dist/mandoc.c      |   83 +++++++-
 external/bsd/mdocml/dist/mandoc_char.7 |   22 +-
 external/bsd/mdocml/dist/mdoc.7        |   63 +++++-
 external/bsd/mdocml/dist/mdoc_html.c   |   17 +-
 external/bsd/mdocml/dist/mdoc_term.c   |  145 +++++++------
 external/bsd/mdocml/dist/out.c         |  190 ++++++++++++++++++-
 external/bsd/mdocml/dist/out.h         |   27 ++-
 external/bsd/mdocml/dist/style.css     |    2 +-
 external/bsd/mdocml/dist/term.c        |  346 ++++++++++++++++----------------
 external/bsd/mdocml/dist/term.h        |   21 +-
 18 files changed, 1045 insertions(+), 630 deletions(-)

diffs (truncated from 2882 to 300 lines):

diff -r 2ee87301969b -r 0f0f41d057d6 external/bsd/mdocml/dist/chars.c
--- a/external/bsd/mdocml/dist/chars.c  Mon Nov 16 19:40:17 2009 +0000
+++ b/external/bsd/mdocml/dist/chars.c  Mon Nov 16 22:26:45 2009 +0000
@@ -1,4 +1,4 @@
-/*     $Vendor-Id: chars.c,v 1.12 2009/11/01 07:44:32 kristaps Exp $ */
+/*     $Vendor-Id: chars.c,v 1.13 2009/11/05 07:21:01 kristaps Exp $ */
 /*
  * Copyright (c) 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
  *
@@ -47,9 +47,10 @@
 #define BOTH(w, x, y, z, a, b) \
        { NULL, (w), (y), (a), (x), (z), (b), CHARS_BOTH },
 
-static struct ln lines[LINES_MAX] = {
+#define        CHAR_TBL_START    static struct ln lines[LINES_MAX] = {
+#define        CHAR_TBL_END      };
+
 #include "chars.in"
-};
 
 struct tbl {
        enum chars        type;
diff -r 2ee87301969b -r 0f0f41d057d6 external/bsd/mdocml/dist/chars.in
--- a/external/bsd/mdocml/dist/chars.in Mon Nov 16 19:40:17 2009 +0000
+++ b/external/bsd/mdocml/dist/chars.in Mon Nov 16 22:26:45 2009 +0000
@@ -1,4 +1,4 @@
-/*     $Vendor-Id: chars.in,v 1.18 2009/09/24 11:55:28 kristaps Exp $ */
+/*     $Vendor-Id: chars.in,v 1.19 2009/11/05 07:21:02 kristaps Exp $ */
 /*
  * Copyright (c) 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
  *
@@ -30,11 +30,16 @@
  * XXX - update LINES_MAX if adding more!
  */
 
+/* Non-breaking, non-collapsing space uses unit separator. */
+static const char ascii_nbrsp[2] = { 31, 0 };
+
+CHAR_TBL_START
+
 /* Spacing. */
 CHAR("c",                      1,      "",             0,      "",             0)
 CHAR("0",                      1,      " ",            1,      "&#8194;",      7)
 CHAR(" ",                      1,      " ",            1,      "&#8194;",      7)
-CHAR("~",                      1,      " ",            1,      "&#160;",       6)
+CHAR("~",                      1,      ascii_nbrsp,    1,      "&#160;",       6)
 CHAR("%",                      1,      "",             0,      "",             0)
 CHAR("&",                      1,      "",             0,      "",             0)
 CHAR("^",                      1,      "",             0,      "",             0)
@@ -416,3 +421,5 @@
 CHAR("fm",                     2,      "\'",           1,      "&#8242;",      7)
 CHAR("sd",                     2,      "\"",           1,      "&#8243;",      7)
 CHAR("mc",                     2,      "mu",           2,      "&#181;",       6)
+
+CHAR_TBL_END
diff -r 2ee87301969b -r 0f0f41d057d6 external/bsd/mdocml/dist/html.c
--- a/external/bsd/mdocml/dist/html.c   Mon Nov 16 19:40:17 2009 +0000
+++ b/external/bsd/mdocml/dist/html.c   Mon Nov 16 22:26:45 2009 +0000
@@ -1,4 +1,4 @@
-/*     $Vendor-Id: html.c,v 1.80 2009/11/02 06:22:44 kristaps Exp $ */
+/*     $Vendor-Id: html.c,v 1.91 2009/11/16 08:46:58 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
  *
@@ -66,7 +66,13 @@
        {"base",        HTML_CLRLINE | HTML_NOSTACK}, /* TAG_BASE */
 };
 
-static const char       *const htmlattrs[ATTR_MAX] = {
+static const char      *const htmlfonts[HTMLFONT_MAX] = {
+       "roman",
+       "bold",
+       "italic"
+};
+
+static const char      *const htmlattrs[ATTR_MAX] = {
        "http-equiv",
        "content",
        "name",
@@ -87,6 +93,14 @@
 extern int               getsubopt(char **, char * const *, char **);
 #endif
 
+
+static void              print_spec(struct html *, const char *, size_t);
+static void              print_res(struct html *, const char *, size_t);
+static void              print_ctag(struct html *, enum htmltag);
+static int               print_encode(struct html *, const char *, int);
+static void              print_metaf(struct html *, enum roffdeco);
+
+
 void *
 html_alloc(char *outopts)
 {
@@ -186,12 +200,12 @@
 
 
 static void
-print_spec(struct html *h, const char *p, int len)
+print_spec(struct html *h, const char *p, size_t len)
 {
        const char      *rhs;
        size_t           sz;
 
-       rhs = chars_a2ascii(h->symtab, p, (size_t)len, &sz);
+       rhs = chars_a2ascii(h->symtab, p, len, &sz);
 
        if (NULL == rhs) 
                return;
@@ -200,12 +214,12 @@
 
 
 static void
-print_res(struct html *h, const char *p, int len)
+print_res(struct html *h, const char *p, size_t len)
 {
        const char      *rhs;
        size_t           sz;
 
-       rhs = chars_a2res(h->symtab, p, (size_t)len, &sz);
+       rhs = chars_a2res(h->symtab, p, len, &sz);
 
        if (NULL == rhs)
                return;
@@ -213,110 +227,61 @@
 }
 
 
-static void
-print_escape(struct html *h, const char **p)
+struct tag *
+print_ofont(struct html *h, enum htmlfont font)
 {
-       int              j, type;
-       const char      *wp;
-
-       wp = *p;
-       type = 1;
-
-       if (0 == *(++wp)) {
-               *p = wp;
-               return;
-       }
+       struct htmlpair  tag;
 
-       if ('(' == *wp) {
-               wp++;
-               if (0 == *wp || 0 == *(wp + 1)) {
-                       *p = 0 == *wp ? wp : wp + 1;
-                       return;
-               }
-
-               print_spec(h, wp, 2);
-               *p = ++wp;
-               return;
-
-       } else if ('*' == *wp) {
-               if (0 == *(++wp)) {
-                       *p = wp;
-                       return;
-               }
-
-               switch (*wp) {
-               case ('('):
-                       wp++;
-                       if (0 == *wp || 0 == *(wp + 1)) {
-                               *p = 0 == *wp ? wp : wp + 1;
-                               return;
-                       }
+       h->metal = h->metac;
+       h->metac = font;
 
-                       print_res(h, wp, 2);
-                       *p = ++wp;
-                       return;
-               case ('['):
-                       type = 0;
-                       break;
-               default:
-                       print_res(h, wp, 1);
-                       *p = wp;
-                       return;
-               }
-       
-       } else if ('f' == *wp) {
-               if (0 == *(++wp)) {
-                       *p = wp;
-                       return;
-               }
+       /* FIXME: DECO_ROMAN should just close out preexisting. */
 
-               switch (*wp) {
-               case ('B'):
-                       /* TODO */
-                       break;
-               case ('I'):
-                       /* TODO */
-                       break;
-               case ('P'):
-                       /* FALLTHROUGH */
-               case ('R'):
-                       /* TODO */
-                       break;
-               default:
-                       break;
-               }
-
-               *p = wp;
-               return;
+       if (h->metaf && h->tags.head == h->metaf)
+               print_tagq(h, h->metaf);
 
-       } else if ('[' != *wp) {
-               print_spec(h, wp, 1);
-               *p = wp;
-               return;
-       }
-
-       wp++;
-       for (j = 0; *wp && ']' != *wp; wp++, j++)
-               /* Loop... */ ;
-
-       if (0 == *wp) {
-               *p = wp;
-               return;
-       }
-
-       if (type)
-               print_spec(h, wp - j, j);
-       else
-               print_res(h, wp - j, j);
-
-       *p = wp;
+       PAIR_CLASS_INIT(&tag, htmlfonts[font]);
+       h->metaf = print_otag(h, TAG_SPAN, 1, &tag);
+       return(h->metaf);
 }
 
 
 static void
-print_encode(struct html *h, const char *p)
+print_metaf(struct html *h, enum roffdeco deco)
+{
+       enum htmlfont    font;
+
+       switch (deco) {
+       case (DECO_PREVIOUS):
+               font = h->metal;
+               break;
+       case (DECO_ITALIC):
+               font = HTMLFONT_ITALIC;
+               break;
+       case (DECO_BOLD):
+               font = HTMLFONT_BOLD;
+               break;
+       case (DECO_ROMAN):
+               font = HTMLFONT_NONE;
+               break;
+       default:
+               abort();
+               /* NOTREACHED */
+       }
+
+       (void)print_ofont(h, font);
+}
+
+
+static int
+print_encode(struct html *h, const char *p, int norecurse)
 {
        size_t           sz;
+       int              len, nospace;
+       const char      *seq;
+       enum roffdeco    deco;
+
+       nospace = 0;
 
        for (; *p; p++) {
                sz = strcspn(p, "\\<>&");
@@ -325,19 +290,50 @@
                p += /* LINTED */
                        sz;
 
-               if ('\\' == *p) {
-                       print_escape(h, &p);
+               if ('<' == *p) {
+                       printf("&lt;");
+                       continue;
+               } else if ('>' == *p) {
+                       printf("&gt;");
+                       continue;
+               } else if ('&' == *p) {
+                       printf("&amp;");
                        continue;
                } else if ('\0' == *p)
                        break;
 
-               if ('<' == *p)
-                       printf("&lt;");
-               else if ('>' == *p)



Home | Main Index | Thread Index | Old Index