Merge bsd.lv version 1.10.5: last larger batch of bug fixes before release.
authorschwarze <schwarze@openbsd.org>
Sat, 31 Jul 2010 21:43:07 +0000 (21:43 +0000)
committerschwarze <schwarze@openbsd.org>
Sat, 31 Jul 2010 21:43:07 +0000 (21:43 +0000)
NOT including Kristaps' .Bd -literal changes which cause regressions.
Features:
* -Tpdf now fully working
Bugfixes:
* proper handling of quoted strings by .ds in roff(7)
* allow empty .Dd
* make .Sm start no-spacing after the first output word
* underline .Ad
* minor fixes in -Thtml
and some optimisations in terminal output.

13 files changed:
usr.bin/mandoc/Makefile
usr.bin/mandoc/chars.c
usr.bin/mandoc/chars.in
usr.bin/mandoc/html.c
usr.bin/mandoc/mdoc_action.c
usr.bin/mandoc/mdoc_html.c
usr.bin/mandoc/mdoc_term.c
usr.bin/mandoc/mdoc_validate.c
usr.bin/mandoc/roff.7
usr.bin/mandoc/roff.c
usr.bin/mandoc/term.c
usr.bin/mandoc/term.h
usr.bin/mandoc/term_ps.c

index 45cb799..60705bd 100644 (file)
@@ -1,8 +1,8 @@
-#      $OpenBSD: Makefile,v 1.43 2010/07/13 01:09:12 schwarze Exp $
+#      $OpenBSD: Makefile,v 1.44 2010/07/31 21:43:07 schwarze Exp $
 
 .include <bsd.own.mk>
 
-VERSION=1.10.4
+VERSION=1.10.5
 CFLAGS+=-DVERSION=\"${VERSION}\"
 CFLAGS+=-W -Wall -Wstrict-prototypes
 
index ed1f8b0..dfa2515 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: chars.c,v 1.9 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: chars.c,v 1.10 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -29,7 +29,6 @@ struct        ln {
        struct ln        *next;
        const char       *code;
        const char       *ascii;
-       size_t            asciisz;
        int               unicode;
        int               type;
 #define        CHARS_CHAR       (1 << 0)
@@ -39,12 +38,12 @@ struct      ln {
 
 #define        LINES_MAX         370
 
-#define CHAR(in, ch, chsz, code) \
-       { NULL, (in), (ch), (chsz), (code), CHARS_CHAR },
-#define STRING(in, ch, chsz, code) \
-       { NULL, (in), (ch), (chsz), (code), CHARS_STRING },
-#define BOTH(in, ch, chsz, code) \
-       { NULL, (in), (ch), (chsz), (code), CHARS_BOTH },
+#define CHAR(in, ch, code) \
+       { NULL, (in), (ch), (code), CHARS_CHAR },
+#define STRING(in, ch, code) \
+       { NULL, (in), (ch), (code), CHARS_STRING },
+#define BOTH(in, ch, code) \
+       { NULL, (in), (ch), (code), CHARS_BOTH },
 
 #define        CHAR_TBL_START    static struct ln lines[LINES_MAX] = {
 #define        CHAR_TBL_END      };
@@ -161,7 +160,7 @@ chars_spec2str(void *arg, const char *p, size_t sz, size_t *rsz)
        if (NULL == ln)
                return(NULL);
 
-       *rsz = ln->asciisz;
+       *rsz = strlen(ln->ascii);
        return(ln->ascii);
 }
 
@@ -178,7 +177,7 @@ chars_res2str(void *arg, const char *p, size_t sz, size_t *rsz)
        if (NULL == ln)
                return(NULL);
 
-       *rsz = ln->asciisz;
+       *rsz = strlen(ln->ascii);
        return(ln->ascii);
 }
 
index ddb7729..f632ffd 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: chars.in,v 1.9 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: chars.in,v 1.10 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
  */
 
 /* Non-breaking, non-collapsing space uses unit separator. */
-static const char ascii_nbrsp[2] = { ASCII_NBRSP, 0 };
+static const char ascii_nbrsp[2] = { ASCII_NBRSP, '\0' };
 
 CHAR_TBL_START
 
 /* Spacing. */
-CHAR("c",                      "",             0,      -1)
-CHAR("0",                      " ",            1,      8194)
-CHAR(" ",                      ascii_nbrsp,    1,      160)
-CHAR("~",                      ascii_nbrsp,    1,      160)
-CHAR("%",                      "",             0,      -1)
-CHAR("&",                      "",             0,      -1)
-CHAR("^",                      "",             0,      -1)
-CHAR("|",                      "",             0,      -1)
-CHAR("}",                      "",             0,      -1)
+CHAR("c",                      "",             0)
+CHAR("0",                      " ",            8194)
+CHAR(" ",                      ascii_nbrsp,    160)
+CHAR("~",                      ascii_nbrsp,    160)
+CHAR("%",                      "",             0)
+CHAR("&",                      "",             0)
+CHAR("^",                      "",             0)
+CHAR("|",                      "",             0)
+CHAR("}",                      "",             0)
 
 /* Accents. */
-CHAR("a\"",                    "\"",           1,      779)
-CHAR("a-",                     "-",            1,      175)
-CHAR("a.",                     ".",            1,      729)
-CHAR("a^",                     "^",            1,      770)
-BOTH("\'",                     "\'",           1,      769)
-BOTH("aa",                     "\'",           1,      769)
-BOTH("ga",                     "`",            1,      768)
-BOTH("`",                      "`",            1,      768)
-CHAR("ab",                     "`",            1,      774)
-CHAR("ac",                     ",",            1,      807)
-CHAR("ad",                     "\"",           1,      776)
-CHAR("ah",                     "v",            1,      711)
-CHAR("ao",                     "o",            1,      730)
-CHAR("a~",                     "~",            1,      771)
-CHAR("ho",                     ",",            1,      808)
-CHAR("ha",                     "^",            1,      94)
-CHAR("ti",                     "~",            1,      126)
+CHAR("a\"",                    "\"",           779)
+CHAR("a-",                     "-",            175)
+CHAR("a.",                     ".",            729)
+CHAR("a^",                     "^",            770)
+BOTH("\'",                     "\'",           769)
+BOTH("aa",                     "\'",           769)
+BOTH("ga",                     "`",            768)
+BOTH("`",                      "`",            768)
+CHAR("ab",                     "`",            774)
+CHAR("ac",                     ",",            807)
+CHAR("ad",                     "\"",           776)
+CHAR("ah",                     "v",            711)
+CHAR("ao",                     "o",            730)
+CHAR("a~",                     "~",            771)
+CHAR("ho",                     ",",            808)
+CHAR("ha",                     "^",            94)
+CHAR("ti",                     "~",            126)
 
 /* Quotes. */
-CHAR("Bq",                     ",,",           2,      8222)
-CHAR("bq",                     ",",            1,      8218)
-BOTH("lq",                     "``",           2,      8220)
-BOTH("rq",                     "\'\'",         2,      8221)
-CHAR("oq",                     "`",            1,      8216)
-CHAR("cq",                     "\'",           1,      8217)
-CHAR("aq",                     "\'",           1,      39)
-CHAR("dq",                     "\"",           1,      34)
-CHAR("Fo",                     "<<",           2,      171)
-CHAR("Fc",                     ">>",           2,      187)
-CHAR("fo",                     "<",            1,      8249)
-CHAR("fc",                     ">",            1,      8250)
+CHAR("Bq",                     ",,",           8222)
+CHAR("bq",                     ",",            8218)
+BOTH("lq",                     "``",           8220)
+BOTH("rq",                     "\'\'",         8221)
+CHAR("oq",                     "`",            8216)
+CHAR("cq",                     "\'",           8217)
+CHAR("aq",                     "\'",           39)
+CHAR("dq",                     "\"",           34)
+CHAR("Fo",                     "<<",           171)
+CHAR("Fc",                     ">>",           187)
+CHAR("fo",                     "<",            8249)
+CHAR("fc",                     ">",            8250)
 
 /* Brackets. */
-CHAR("lB",                     "[",            1,      91)
-CHAR("rB",                     "]",            1,      93)
-CHAR("lC",                     "{",            1,      123)
-CHAR("rC",                     "}",            1,      125)
-CHAR("la",                     "<",            1,      60)
-CHAR("ra",                     ">",            1,      62)
-CHAR("bv",                     "|",            1,      9130)
-CHAR("braceex",                        "|",            1,      9130)
-CHAR("bracketlefttp",          "|",            1,      9121)
-CHAR("bracketleftbp",          "|",            1,      9123)
-CHAR("bracketleftex",          "|",            1,      9122)
-CHAR("bracketrighttp",         "|",            1,      9124)
-CHAR("bracketrightbp",         "|",            1,      9126)
-CHAR("bracketrightex",         "|",            1,      9125)
-CHAR("lt",                     ",-",           2,      9127)
-CHAR("bracelefttp",            ",-",           2,      9127)
-CHAR("lk",                     "{",            1,      9128)
-CHAR("braceleftmid",           "{",            1,      9128)
-CHAR("lb",                     ",-",           2,      9129)
-CHAR("braceleftbp",            "`-",           2,      9129)
-CHAR("braceleftex",            "|",            1,      9130)
-CHAR("rt",                     "-.",           2,      9131)
-CHAR("bracerighttp",           "-.",           2,      9131)
-CHAR("rk",                     "}",            1,      9132)
-CHAR("bracerightmid",          "}",            1,      9132)
-CHAR("rb",                     "-\'",          2,      9133)
-CHAR("bracerightbp",           "-\'",          2,      9133)
-CHAR("bracerightex",           "|",            1,      9130)
-CHAR("parenlefttp",            "/",            1,      9115)
-CHAR("parenleftbp",            "\\",           1,      9117)
-CHAR("parenleftex",            "|",            1,      9116)
-CHAR("parenrighttp",           "\\",           1,      9118)
-CHAR("parenrightbp",           "/",            1,      9120)
-CHAR("parenrightex",           "|",            1,      9119)
+CHAR("lB",                     "[",            91)
+CHAR("rB",                     "]",            93)
+CHAR("lC",                     "{",            123)
+CHAR("rC",                     "}",            125)
+CHAR("la",                     "<",            60)
+CHAR("ra",                     ">",            62)
+CHAR("bv",                     "|",            9130)
+CHAR("braceex",                        "|",            9130)
+CHAR("bracketlefttp",          "|",            9121)
+CHAR("bracketleftbp",          "|",            9123)
+CHAR("bracketleftex",          "|",            9122)
+CHAR("bracketrighttp",         "|",            9124)
+CHAR("bracketrightbp",         "|",            9126)
+CHAR("bracketrightex",         "|",            9125)
+CHAR("lt",                     ",-",           9127)
+CHAR("bracelefttp",            ",-",           9127)
+CHAR("lk",                     "{",            9128)
+CHAR("braceleftmid",           "{",            9128)
+CHAR("lb",                     ",-",           9129)
+CHAR("braceleftbp",            "`-",           9129)
+CHAR("braceleftex",            "|",            9130)
+CHAR("rt",                     "-.",           9131)
+CHAR("bracerighttp",           "-.",           9131)
+CHAR("rk",                     "}",            9132)
+CHAR("bracerightmid",          "}",            9132)
+CHAR("rb",                     "-\'",          9133)
+CHAR("bracerightbp",           "-\'",          9133)
+CHAR("bracerightex",           "|",            9130)
+CHAR("parenlefttp",            "/",            9115)
+CHAR("parenleftbp",            "\\",           9117)
+CHAR("parenleftex",            "|",            9116)
+CHAR("parenrighttp",           "\\",           9118)
+CHAR("parenrightbp",           "/",            9120)
+CHAR("parenrightex",           "|",            9119)
 
 /* Greek characters. */
-CHAR("*A",                     "A",            1,      913)
-CHAR("*B",                     "B",            1,      914)
-CHAR("*G",                     "|",            1,      915)
-CHAR("*D",                     "/\\",          2,      916)
-CHAR("*E",                     "E",            1,      917)
-CHAR("*Z",                     "Z",            1,      918)
-CHAR("*Y",                     "H",            1,      919)
-CHAR("*H",                     "O",            1,      920)
-CHAR("*I",                     "I",            1,      921)
-CHAR("*K",                     "K",            1,      922)
-CHAR("*L",                     "/\\",          2,      923)
-CHAR("*M",                     "M",            1,      924)
-CHAR("*N",                     "N",            1,      925)
-CHAR("*C",                     "H",            1,      926)
-CHAR("*O",                     "O",            1,      927)
-CHAR("*P",                     "TT",           2,      928)
-CHAR("*R",                     "P",            1,      929)
-CHAR("*S",                     ">",            1,      931)
-CHAR("*T",                     "T",            1,      932)
-CHAR("*U",                     "Y",            1,      933)
-CHAR("*F",                     "O_",           1,      934)
-CHAR("*X",                     "X",            1,      935)
-CHAR("*Q",                     "Y",            1,      936)
-CHAR("*W",                     "O",            1,      937)
-CHAR("*a",                     "a",            1,      945)
-CHAR("*b",                     "B",            1,      946)
-CHAR("*g",                     "y",            1,      947)
-CHAR("*d",                     "d",            1,      948)
-CHAR("*e",                     "e",            1,      949)
-CHAR("*z",                     "C",            1,      950)
-CHAR("*y",                     "n",            1,      951)
-CHAR("*h",                     "0",            1,      952)
-CHAR("*i",                     "i",            1,      953)
-CHAR("*k",                     "k",            1,      954)
-CHAR("*l",                     "\\",           1,      955)
-CHAR("*m",                     "u",            1,      956)
-CHAR("*n",                     "v",            1,      957)
-CHAR("*c",                     "E",            1,      958)
-CHAR("*o",                     "o",            1,      959)
-CHAR("*p",                     "n",            1,      960)
-CHAR("*r",                     "p",            1,      961)
-CHAR("*s",                     "o",            1,      963)
-CHAR("*t",                     "t",            1,      964)
-CHAR("*u",                     "u",            1,      965)
-CHAR("*f",                     "o",            1,      981)
-CHAR("*x",                     "x",            1,      967)
-CHAR("*q",                     "u",            1,      968)
-CHAR("*w",                     "w",            1,      969)
-CHAR("+h",                     "0",            1,      977)
-CHAR("+f",                     "o",            1,      966)
-CHAR("+p",                     "w",            1,      982)
-CHAR("+e",                     "e",            1,      1013)
-CHAR("ts",                     "s",            1,      962)
+CHAR("*A",                     "A",            913)
+CHAR("*B",                     "B",            914)
+CHAR("*G",                     "|",            915)
+CHAR("*D",                     "/\\",          916)
+CHAR("*E",                     "E",            917)
+CHAR("*Z",                     "Z",            918)
+CHAR("*Y",                     "H",            919)
+CHAR("*H",                     "O",            920)
+CHAR("*I",                     "I",            921)
+CHAR("*K",                     "K",            922)
+CHAR("*L",                     "/\\",          923)
+CHAR("*M",                     "M",            924)
+CHAR("*N",                     "N",            925)
+CHAR("*C",                     "H",            926)
+CHAR("*O",                     "O",            927)
+CHAR("*P",                     "TT",           928)
+CHAR("*R",                     "P",            929)
+CHAR("*S",                     ">",            931)
+CHAR("*T",                     "T",            932)
+CHAR("*U",                     "Y",            933)
+CHAR("*F",                     "O_",           934)
+CHAR("*X",                     "X",            935)
+CHAR("*Q",                     "Y",            936)
+CHAR("*W",                     "O",            937)
+CHAR("*a",                     "a",            945)
+CHAR("*b",                     "B",            946)
+CHAR("*g",                     "y",            947)
+CHAR("*d",                     "d",            948)
+CHAR("*e",                     "e",            949)
+CHAR("*z",                     "C",            950)
+CHAR("*y",                     "n",            951)
+CHAR("*h",                     "0",            952)
+CHAR("*i",                     "i",            953)
+CHAR("*k",                     "k",            954)
+CHAR("*l",                     "\\",           955)
+CHAR("*m",                     "u",            956)
+CHAR("*n",                     "v",            957)
+CHAR("*c",                     "E",            958)
+CHAR("*o",                     "o",            959)
+CHAR("*p",                     "n",            960)
+CHAR("*r",                     "p",            961)
+CHAR("*s",                     "o",            963)
+CHAR("*t",                     "t",            964)
+CHAR("*u",                     "u",            965)
+CHAR("*f",                     "o",            981)
+CHAR("*x",                     "x",            967)
+CHAR("*q",                     "u",            968)
+CHAR("*w",                     "w",            969)
+CHAR("+h",                     "0",            977)
+CHAR("+f",                     "o",            966)
+CHAR("+p",                     "w",            982)
+CHAR("+e",                     "e",            1013)
+CHAR("ts",                     "s",            962)
 
 /* Accented letters. */
-CHAR(",C",                     "C",            1,      199)
-CHAR(",c",                     "c",            1,      231)
-CHAR("/L",                     "L",            1,      321)
-CHAR("/O",                     "O",            1,      216)
-CHAR("/l",                     "l",            1,      322)
-CHAR("/o",                     "o",            1,      248)
-CHAR("oA",                     "A",            1,      197)
-CHAR("oa",                     "a",            1,      229)
-CHAR(":A",                     "A",            1,      196)
-CHAR(":E",                     "E",            1,      203)
-CHAR(":I",                     "I",            1,      207)
-CHAR(":O",                     "O",            1,      214)
-CHAR(":U",                     "U",            1,      220)
-CHAR(":a",                     "a",            1,      228)
-CHAR(":e",                     "e",            1,      235)
-CHAR(":i",                     "i",            1,      239)
-CHAR(":o",                     "o",            1,      245)
-CHAR(":u",                     "u",            1,      252)
-CHAR(":y",                     "y",            1,      255)
-CHAR("\'A",                    "A",            1,      193)
-CHAR("\'E",                    "E",            1,      201)
-CHAR("\'I",                    "I",            1,      205)
-CHAR("\'O",                    "O",            1,      211)
-CHAR("\'U",                    "U",            1,      218)
-CHAR("\'a",                    "a",            1,      225)
-CHAR("\'e",                    "e",            1,      233)
-CHAR("\'i",                    "i",            1,      237)
-CHAR("\'o",                    "o",            1,      243)
-CHAR("\'u",                    "u",            1,      250)
-CHAR("^A",                     "A",            1,      194)
-CHAR("^E",                     "E",            1,      202)
-CHAR("^I",                     "I",            1,      206)
-CHAR("^O",                     "O",            1,      212)
-CHAR("^U",                     "U",            1,      219)
-CHAR("^a",                     "a",            1,      226)
-CHAR("^e",                     "e",            1,      234)
-CHAR("^i",                     "i",            1,      238)
-CHAR("^o",                     "o",            1,      244)
-CHAR("^u",                     "u",            1,      251)
-CHAR("`A",                     "A",            1,      192)
-CHAR("`E",                     "E",            1,      200)
-CHAR("`I",                     "I",            1,      204)
-CHAR("`O",                     "O",            1,      210)
-CHAR("`U",                     "U",            1,      217)
-CHAR("`a",                     "a",            1,      224)
-CHAR("`e",                     "e",            1,      232)
-CHAR("`i",                     "i",            1,      236)
-CHAR("`o",                     "o",            1,      242)
-CHAR("`u",                     "u",            1,      249)
-CHAR("~A",                     "A",            1,      195)
-CHAR("~N",                     "N",            1,      209)
-CHAR("~O",                     "O",            1,      213)
-CHAR("~a",                     "a",            1,      227)
-CHAR("~n",                     "n",            1,      241)
-CHAR("~o",                     "o",            1,      245)
+CHAR(",C",                     "C",            199)
+CHAR(",c",                     "c",            231)
+CHAR("/L",                     "L",            321)
+CHAR("/O",                     "O",            216)
+CHAR("/l",                     "l",            322)
+CHAR("/o",                     "o",            248)
+CHAR("oA",                     "A",            197)
+CHAR("oa",                     "a",            229)
+CHAR(":A",                     "A",            196)
+CHAR(":E",                     "E",            203)
+CHAR(":I",                     "I",            207)
+CHAR(":O",                     "O",            214)
+CHAR(":U",                     "U",            220)
+CHAR(":a",                     "a",            228)
+CHAR(":e",                     "e",            235)
+CHAR(":i",                     "i",            239)
+CHAR(":o",                     "o",            245)
+CHAR(":u",                     "u",            252)
+CHAR(":y",                     "y",            255)
+CHAR("\'A",                    "A",            193)
+CHAR("\'E",                    "E",            201)
+CHAR("\'I",                    "I",            205)
+CHAR("\'O",                    "O",            211)
+CHAR("\'U",                    "U",            218)
+CHAR("\'a",                    "a",            225)
+CHAR("\'e",                    "e",            233)
+CHAR("\'i",                    "i",            237)
+CHAR("\'o",                    "o",            243)
+CHAR("\'u",                    "u",            250)
+CHAR("^A",                     "A",            194)
+CHAR("^E",                     "E",            202)
+CHAR("^I",                     "I",            206)
+CHAR("^O",                     "O",            212)
+CHAR("^U",                     "U",            219)
+CHAR("^a",                     "a",            226)
+CHAR("^e",                     "e",            234)
+CHAR("^i",                     "i",            238)
+CHAR("^o",                     "o",            244)
+CHAR("^u",                     "u",            251)
+CHAR("`A",                     "A",            192)
+CHAR("`E",                     "E",            200)
+CHAR("`I",                     "I",            204)
+CHAR("`O",                     "O",            210)
+CHAR("`U",                     "U",            217)
+CHAR("`a",                     "a",            224)
+CHAR("`e",                     "e",            232)
+CHAR("`i",                     "i",            236)
+CHAR("`o",                     "o",            242)
+CHAR("`u",                     "u",            249)
+CHAR("~A",                     "A",            195)
+CHAR("~N",                     "N",            209)
+CHAR("~O",                     "O",            213)
+CHAR("~a",                     "a",            227)
+CHAR("~n",                     "n",            241)
+CHAR("~o",                     "o",            245)
 
 /* Arrows and lines. */
-CHAR("<-",                     "<-",           2,      8592)
-CHAR("->",                     "->",           2,      8594)
-CHAR("<>",                     "<>",           2,      8596)
-CHAR("da",                     "v",            1,      8595)
-BOTH("ua",                     "^",            1,      8593)
-BOTH("va",                     "^v",           2,      8597)
-CHAR("lA",                     "<=",           2,      8656)
-CHAR("rA",                     "=>",           2,      8658)
-CHAR("hA",                     "<=>",          3,      8660)
-CHAR("dA",                     "v",            1,      8659)
-CHAR("uA",                     "^",            1,      8657)
-CHAR("vA",                     "^=v",          3,      8661)
+CHAR("<-",                     "<-",           8592)
+CHAR("->",                     "->",           8594)
+CHAR("<>",                     "<>",           8596)
+CHAR("da",                     "v",            8595)
+BOTH("ua",                     "^",            8593)
+BOTH("va",                     "^v",           8597)
+CHAR("lA",                     "<=",           8656)
+CHAR("rA",                     "=>",           8658)
+CHAR("hA",                     "<=>",          8660)
+CHAR("dA",                     "v",            8659)
+CHAR("uA",                     "^",            8657)
+CHAR("vA",                     "^=v",          8661)
 
 /* Logic. */
-CHAR("AN",                     "^",            1,      8743)
-CHAR("OR",                     "v",            1,      8744)
-CHAR("no",                     "~",            1,      172)
-CHAR("tno",                    "~",            1,      172)
-CHAR("te",                     "3",            1,      8707)
-CHAR("fa",                     "V",            1,      8704)
-CHAR("st",                     "-)",           2,      8715)
-CHAR("tf",                     ".:.",          3,      8756)
-CHAR("3d",                     ".:.",          3,      8756)
-CHAR("or",                     "|",            1,      124)
+CHAR("AN",                     "^",            8743)
+CHAR("OR",                     "v",            8744)
+CHAR("no",                     "~",            172)
+CHAR("tno",                    "~",            172)
+CHAR("te",                     "3",            8707)
+CHAR("fa",                     "V",            8704)
+CHAR("st",                     "-)",           8715)
+CHAR("tf",                     ".:.",          8756)
+CHAR("3d",                     ".:.",          8756)
+CHAR("or",                     "|",            124)
 
 /* Mathematicals. */
-CHAR("pl",                     "+",            1,      43)
-CHAR("mi",                     "-",            1,      8722)
-CHAR("-",                      "-",            1,      45)
-CHAR("-+",                     "-+",           2,      8723)
-CHAR("+-",                     "+-",           2,      177)
-CHAR("t+-",                    "+-",           2,      177)
-CHAR("pc",                     ".",            1,      183)
-CHAR("md",                     ".",            1,      8901)
-CHAR("mu",                     "x",            1,      215)
-CHAR("tmu",                    "x",            1,      215)
-CHAR("c*",                     "x",            1,      8855)
-CHAR("c+",                     "+",            1,      8853)
-CHAR("di",                     "-:-",          3,      247)
-CHAR("tdi",                    "-:-",          3,      247)
-CHAR("f/",                     "/",            1,      8260)
-CHAR("**",                     "*",            1,      8727)
-BOTH("<=",                     "<=",           2,      8804)
-BOTH(">=",                     ">=",           2,      8805)
-CHAR("<<",                     "<<",           2,      8810)
-CHAR(">>",                     ">>",           2,      8811)
-CHAR("eq",                     "=",            1,      61)
-CHAR("!=",                     "!=",           2,      8800)
-CHAR("==",                     "==",           2,      8801)
-CHAR("ne",                     "!==",          3,      8802)
-CHAR("=~",                     "=~",           2,      8773)
-CHAR("-~",                     "-~",           2,      8771)
-CHAR("ap",                     "~",            1,      8764)
-CHAR("~~",                     "~~",           2,      8776)
-CHAR("~=",                     "~=",           2,      8780)
-CHAR("pt",                     "oc",           2,      8733)
-CHAR("es",                     "{}",           2,      8709)
-CHAR("mo",                     "E",            1,      8712)
-CHAR("nm",                     "!E",           2,      8713)
-CHAR("sb",                     "(=",           2,      8834)
-CHAR("nb",                     "(!=",          3,      8836)
-CHAR("sp",                     "=)",           2,      8835)
-CHAR("nc",                     "!=)",          3,      8837)
-CHAR("ib",                     "(=",           2,      8838)
-CHAR("ip",                     "=)",           2,      8839)
-CHAR("ca",                     "(^)",          3,      8745)
-CHAR("cu",                     "U",            1,      8746)
-CHAR("/_",                     "/_",           2,      8736)
-CHAR("pp",                     "_|_",          3,      8869)
-CHAR("is",                     "I",            1,      8747)
-CHAR("integral",               "I",            1,      8747)
-CHAR("sum",                    "E",            1,      8721)
-CHAR("product",                        "TT",           2,      8719)
-CHAR("coproduct",              "U",            1,      8720)
-CHAR("gr",                     "V",            1,      8711)
-CHAR("sr",                     "\\/",          2,      8730)
-CHAR("sqrt",                   "\\/",          2,      8730)
-CHAR("lc",                     "|~",           2,      8968)
-CHAR("rc",                     "~|",           2,      8969)
-CHAR("lf",                     "|_",           2,      8970)
-CHAR("rf",                     "_|",           2,      8971)
-CHAR("if",                     "oo",           2,      8734)
-CHAR("Ah",                     "N",            1,      8501)
-CHAR("Im",                     "I",            1,      8465)
-CHAR("Re",                     "R",            1,      8476)
-CHAR("pd",                     "a",            1,      8706)
-CHAR("-h",                     "/h",           2,      8463)
+CHAR("pl",                     "+",            43)
+CHAR("mi",                     "-",            8722)
+CHAR("-",                      "-",            45)
+CHAR("-+",                     "-+",           8723)
+CHAR("+-",                     "+-",           177)
+CHAR("t+-",                    "+-",           177)
+CHAR("pc",                     ".",            183)
+CHAR("md",                     ".",            8901)
+CHAR("mu",                     "x",            215)
+CHAR("tmu",                    "x",            215)
+CHAR("c*",                     "x",            8855)
+CHAR("c+",                     "+",            8853)
+CHAR("di",                     "-:-",          247)
+CHAR("tdi",                    "-:-",          247)
+CHAR("f/",                     "/",            8260)
+CHAR("**",                     "*",            8727)
+BOTH("<=",                     "<=",           8804)
+BOTH(">=",                     ">=",           8805)
+CHAR("<<",                     "<<",           8810)
+CHAR(">>",                     ">>",           8811)
+CHAR("eq",                     "=",            61)
+CHAR("!=",                     "!=",           8800)
+CHAR("==",                     "==",           8801)
+CHAR("ne",                     "!==",          8802)
+CHAR("=~",                     "=~",           8773)
+CHAR("-~",                     "-~",           8771)
+CHAR("ap",                     "~",            8764)
+CHAR("~~",                     "~~",           8776)
+CHAR("~=",                     "~=",           8780)
+CHAR("pt",                     "oc",           8733)
+CHAR("es",                     "{}",           8709)
+CHAR("mo",                     "E",            8712)
+CHAR("nm",                     "!E",           8713)
+CHAR("sb",                     "(=",           8834)
+CHAR("nb",                     "(!=",          8836)
+CHAR("sp",                     "=)",           8835)
+CHAR("nc",                     "!=)",          8837)
+CHAR("ib",                     "(=",           8838)
+CHAR("ip",                     "=)",           8839)
+CHAR("ca",                     "(^)",          8745)
+CHAR("cu",                     "U",            8746)
+CHAR("/_",                     "/_",           8736)
+CHAR("pp",                     "_|_",          8869)
+CHAR("is",                     "I",            8747)
+CHAR("integral",               "I",            8747)
+CHAR("sum",                    "E",            8721)
+CHAR("product",                        "TT",           8719)
+CHAR("coproduct",              "U",            8720)
+CHAR("gr",                     "V",            8711)
+CHAR("sr",                     "\\/",          8730)
+CHAR("sqrt",                   "\\/",          8730)
+CHAR("lc",                     "|~",           8968)
+CHAR("rc",                     "~|",           8969)
+CHAR("lf",                     "|_",           8970)
+CHAR("rf",                     "_|",           8971)
+CHAR("if",                     "oo",           8734)
+CHAR("Ah",                     "N",            8501)
+CHAR("Im",                     "I",            8465)
+CHAR("Re",                     "R",            8476)
+CHAR("pd",                     "a",            8706)
+CHAR("-h",                     "/h",           8463)
 
 /* Ligatures. */
-CHAR("ff",                     "ff",           2,      64256)
-CHAR("fi",                     "fi",           2,      64257)
-CHAR("fl",                     "fl",           2,      64258)
-CHAR("Fi",                     "ffi",          3,      64259)
-CHAR("Fl",                     "ffl",          3,      64260)
-BOTH("AE",                     "AE",           2,      198)
-BOTH("ae",                     "ae",           2,      230)
-CHAR("OE",                     "OE",           2,      338)
-CHAR("oe",                     "oe",           2,      339)
-CHAR("ss",                     "ss",           2,      223)
-CHAR("IJ",                     "IJ",           2,      306)
-CHAR("ij",                     "ij",           2,      307)
+CHAR("ff",                     "ff",           64256)
+CHAR("fi",                     "fi",           64257)
+CHAR("fl",                     "fl",           64258)
+CHAR("Fi",                     "ffi",          64259)
+CHAR("Fl",                     "ffl",          64260)
+BOTH("AE",                     "AE",           198)
+BOTH("ae",                     "ae",           230)
+CHAR("OE",                     "OE",           338)
+CHAR("oe",                     "oe",           339)
+CHAR("ss",                     "ss",           223)
+CHAR("IJ",                     "IJ",           306)
+CHAR("ij",                     "ij",           307)
 
 /* Special letters. */
-CHAR("-D",                     "D",            1,      208)
-CHAR("Sd",                     "o",            1,      240)
-CHAR("TP",                     "b",            1,      222)
-CHAR("Tp",                     "b",            1,      254)
-CHAR(".i",                     "i",            1,      305)
-CHAR(".j",                     "j",            1,      567)
+CHAR("-D",                     "D",            208)
+CHAR("Sd",                     "o",            240)
+CHAR("TP",                     "b",            222)
+CHAR("Tp",                     "b",            254)
+CHAR(".i",                     "i",            305)
+CHAR(".j",                     "j",            567)
 
 /* Currency. */
-CHAR("Do",                     "$",            1,      36)
-CHAR("ct",                     "c",            1,      162)
-CHAR("Eu",                     "EUR",          3,      8364)
-CHAR("eu",                     "EUR",          3,      8364)
-CHAR("Ye",                     "Y",            1,      165)
-CHAR("Po",                     "L",            1,      163)
-CHAR("Cs",                     "x",            1,      164)
-CHAR("Fn",                     "f",            1,      402)
+CHAR("Do",                     "$",            36)
+CHAR("ct",                     "c",            162)
+CHAR("Eu",                     "EUR",          8364)
+CHAR("eu",                     "EUR",          8364)
+CHAR("Ye",                     "Y",            165)
+CHAR("Po",                     "L",            163)
+CHAR("Cs",                     "x",            164)
+CHAR("Fn",                     "f",            402)
 
 /* pod2man holdovers. */
-STRING("--",                   "--",           2,      8212)
-STRING("PI",                   "pi",           2,      960)
-STRING("L\"",                  "``",           2,      8220)
-STRING("R\"",                  "\'\'",         2,      8221)
-STRING("C+",                   "C++",          3,      0)
-STRING("C`",                   "`",            1,      8216)
-STRING("C\'",                  "\'",           1,      8217)
-STRING("Aq",                   "\'",           1,      39)
-STRING("^",                    "^",            1,      94)
-STRING(",",                    ",",            1,      44)
-STRING("~",                    "~",            1,      126)
-STRING("/",                    "/",            1,      47)
-STRING(":",                    "\"",           1,      776)
-STRING("8",                    "B",            1,      946)
-STRING("o",                    "o",            1,      176)
-STRING("D-",                   "D",            1,      208)
-STRING("d-",                   "o",            1,      240)
-STRING("Th",                   "b",            1,      222)
-STRING("th",                   "b",            1,      254)
+STRING("--",                   "--",           8212)
+STRING("PI",                   "pi",           960)
+STRING("L\"",                  "``",           8220)
+STRING("R\"",                  "\'\'",         8221)
+STRING("C+",                   "C++",          0)
+STRING("C`",                   "`",            8216)
+STRING("C\'",                  "\'",           8217)
+STRING("Aq",                   "\'",           39)
+STRING("^",                    "^",            94)
+STRING(",",                    ",",            44)
+STRING("~",                    "~",            126)
+STRING("/",                    "/",            47)
+STRING(":",                    "\"",           776)
+STRING("8",                    "B",            946)
+STRING("o",                    "o",            176)
+STRING("D-",                   "D",            208)
+STRING("d-",                   "o",            240)
+STRING("Th",                   "b",            222)
+STRING("th",                   "b",            254)
 
 /* Old style. */
-STRING("Am",                   "&",            1,      38)
-STRING("Ba",                   "|",            1,      124)
-STRING("Ge",                   ">=",           2,      8805)
-STRING("Gt",                   ">",            1,      62)
-STRING("If",                   "infinity",     8,      0)
-STRING("Le",                   "<=",           2,      8804)
-STRING("Lq",                   "``",           2,      8220)
-STRING("Lt",                   "<",            1,      60)
-STRING("Na",                   "NaN",          3,      0)
-STRING("Ne",                   "!=",           2,      8800)
-STRING("Pi",                   "pi",           2,      960)
-STRING("Pm",                   "+-",           2,      177)
-STRING("R",                    "(R)",          3,      174)
-STRING("Rq",                   "\'\'",         2,      8221)
-STRING("Tm",                   "tm",           2,      8482)
-STRING("left-bracket",         "[",            1,      91)
-STRING("left-parenthesis",     "(",            1,      40)
-STRING("left-singlequote",     "`",            1,      8216)
-STRING("lp",                   "(",            1,      40)
-STRING("q",                    "\"",           1,      34)
-STRING("quote-left",           "`",            1,      8216)
-STRING("quote-right",          "\'",           1,      8217)
-STRING("right-bracket",                "]",            1,      93)
-STRING("right-parenthesis",    ")",            1,      41)
-STRING("right-singlequote",    "\'",           1,      8217)
-STRING("rp",                   ")",            1,      41)
+STRING("Am",                   "&",            38)
+STRING("Ba",                   "|",            124)
+STRING("Ge",                   ">=",           8805)
+STRING("Gt",                   ">",            62)
+STRING("If",                   "infinity",     0)
+STRING("Le",                   "<=",           8804)
+STRING("Lq",                   "``",           8220)
+STRING("Lt",                   "<",            60)
+STRING("Na",                   "NaN",          0)
+STRING("Ne",                   "!=",           8800)
+STRING("Pi",                   "pi",           960)
+STRING("Pm",                   "+-",           177)
+STRING("R",                    "(R)",          174)
+STRING("Rq",                   "\'\'",         8221)
+STRING("Tm",                   "tm",           8482)
+STRING("left-bracket",         "[",            91)
+STRING("left-parenthesis",     "(",            40)
+STRING("left-singlequote",     "`",            8216)
+STRING("lp",                   "(",            40)
+STRING("q",                    "\"",           34)
+STRING("quote-left",           "`",            8216)
+STRING("quote-right",          "\'",           8217)
+STRING("right-bracket",                "]",            93)
+STRING("right-parenthesis",    ")",            41)
+STRING("right-singlequote",    "\'",           8217)
+STRING("rp",                   ")",            41)
 
 /* Lines. */
-CHAR("ba",                     "|",            1,      124)
-CHAR("br",                     "|",            1,      9474)
-CHAR("ul",                     "_",            1,      95)
-CHAR("rl",                     "-",            1,      8254)
-CHAR("bb",                     "|",            1,      166)
-CHAR("sl",                     "/",            1,      47)
-CHAR("rs",                     "\\",           1,      92)
+CHAR("ba",                     "|",            124)
+CHAR("br",                     "|",            9474)
+CHAR("ul",                     "_",            95)
+CHAR("rl",                     "-",            8254)
+CHAR("bb",                     "|",            166)
+CHAR("sl",                     "/",            47)
+CHAR("rs",                     "\\",           92)
 
 /* Text markers. */
-CHAR("ci",                     "o",            1,      9675)
-CHAR("bu",                     "o",            1,      8226)
-CHAR("dd",                     "=",            1,      8225)
-CHAR("dg",                     "-",            1,      8224)
-CHAR("lz",                     "<>",           2,      9674)
-CHAR("sq",                     "[]",           2,      9633)
-CHAR("ps",                     "9|",           2,      182)
-CHAR("sc",                     "S",            1,      167)
-CHAR("lh",                     "<=",           2,      9756)
-CHAR("rh",                     "=>",           2,      9758)
-CHAR("at",                     "@",            1,      64)
-CHAR("sh",                     "#",            1,      35)
-CHAR("CR",                     "_|",           2,      8629)
-CHAR("OK",                     "\\/",          2,      10003)
+CHAR("ci",                     "o",            9675)
+CHAR("bu",                     "o",            8226)
+CHAR("dd",                     "=",            8225)
+CHAR("dg",                     "-",            8224)
+CHAR("lz",                     "<>",           9674)
+CHAR("sq",                     "[]",           9633)
+CHAR("ps",                     "9|",           182)
+CHAR("sc",                     "S",            167)
+CHAR("lh",                     "<=",           9756)
+CHAR("rh",                     "=>",           9758)
+CHAR("at",                     "@",            64)
+CHAR("sh",                     "#",            35)
+CHAR("CR",                     "_|",           8629)
+CHAR("OK",                     "\\/",          10003)
 
 /* Legal symbols. */
-CHAR("co",                     "(C)",          3,      169)
-CHAR("rg",                     "(R)",          3,      174)
-CHAR("tm",                     "tm",           2,      8482)
+CHAR("co",                     "(C)",          169)
+CHAR("rg",                     "(R)",          174)
+CHAR("tm",                     "tm",           8482)
 
 /* Punctuation. */
-CHAR(".",                      ".",            1,      46)
-CHAR("r!",                     "i",            1,      161)
-CHAR("r?",                     "c",            1,      191)
-CHAR("em",                     "--",           2,      8212)
-CHAR("en",                     "-",            1,      8211)
-CHAR("hy",                     "-",            1,      8208)
-CHAR("e",                      "\\",           1,      92)
+CHAR(".",                      ".",            46)
+CHAR("r!",                     "i",            161)
+CHAR("r?",                     "c",            191)
+CHAR("em",                     "--",           8212)
+CHAR("en",                     "-",            8211)
+CHAR("hy",                     "-",            8208)
+CHAR("e",                      "\\",           92)
 
 /* Units. */
-CHAR("de",                     "o",            1,      176)
-CHAR("%0",                     "%o",           2,      8240)
-CHAR("fm",                     "\'",           1,      8242)
-CHAR("sd",                     "\"",           1,      8243)
-CHAR("mc",                     "mu",           2,      181)
+CHAR("de",                     "o",            176)
+CHAR("%0",                     "%o",           8240)
+CHAR("fm",                     "\'",           8242)
+CHAR("sd",                     "\"",           8243)
+CHAR("mc",                     "mu",           181)
 
 CHAR_TBL_END
index eb9ebda..647b472 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: html.c,v 1.13 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: html.c,v 1.14 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -415,6 +415,8 @@ print_otag(struct html *h, enum htmltag tag,
 
        if ( ! (h->flags & HTML_NONOSPACE))
                h->flags &= ~HTML_NOSPACE;
+       else
+               h->flags |= HTML_NOSPACE;
 
        /* Print out the tag name and attributes. */
 
index d6abb75..eca8df2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_action.c,v 1.43 2010/07/13 01:09:13 schwarze Exp $ */
+/*     $Id: mdoc_action.c,v 1.44 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -656,6 +656,13 @@ post_bl_tagwidth(POST_ARGS)
                assert(MDOC_BLOCK == nn->type);
                nn = nn->head->child;
 
+               if (nn == NULL) {
+                       /* No -width for .Bl and first .It is emtpy */
+                       if ( ! mdoc_nmsg(m, n, MANDOCERR_NOWIDTHARG))
+                               return(0);
+                       break;
+               }
+
                if (MDOC_TEXT == nn->type) {
                        sz = strlen(nn->string) + 1;
                        break;
@@ -900,6 +907,11 @@ post_dd(POST_ARGS)
 {
        char            buf[DATESIZ];
 
+       if (NULL == n->child) {
+               m->meta.date = time(NULL);
+               return(post_prol(m, n));
+       }
+
        if ( ! concat(m, buf, n->child, DATESIZ))
                return(0);
 
index 73c7aa5..832f74f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_html.c,v 1.26 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: mdoc_html.c,v 1.27 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -1453,14 +1453,11 @@ mdoc_bd_pre(MDOC_ARGS)
        print_otag(h, TAG_DIV, 2, tag);
 
        for (nn = n->child; nn; nn = nn->next) {
-               h->flags |= HTML_NOSPACE;
-               print_mdoc_node(m, nn, h);
-               if (NULL == nn->next)
-                       continue;
-               if (nn->prev && nn->prev->line < nn->line)
-                       print_text(h, "\n");
-               else if (NULL == nn->prev)
+               if (nn->prev && nn->prev->line < nn->line) {
                        print_text(h, "\n");
+                       h->flags |= HTML_NOSPACE;
+               }
+               print_mdoc_node(m, nn, h);
        }
 
        return(0);
index 0dce300..b7a7b23 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_term.c,v 1.98 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: mdoc_term.c,v 1.99 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -147,7 +147,7 @@ static      const struct termact termacts[MDOC_MAX] = {
        { termp_bl_pre, termp_bl_post }, /* Bl */
        { NULL, NULL }, /* El */
        { termp_it_pre, termp_it_post }, /* It */
-       { NULL, NULL }, /* Ad */ 
+       { termp_under_pre, NULL }, /* Ad */ 
        { termp_an_pre, termp_an_post }, /* An */
        { termp_under_pre, NULL }, /* Ar */
        { termp_cd_pre, NULL }, /* Cd */
@@ -1617,8 +1617,7 @@ termp_fa_pre(DECL_ARGS)
 static int
 termp_bd_pre(DECL_ARGS)
 {
-       size_t                   tabwidth;
-       size_t                   rm, rmax;
+       size_t                   tabwidth, rm, rmax;
        const struct mdoc_node  *nn;
 
        if (MDOC_BLOCK == n->type) {
index 9cffeaa..7fed23d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_validate.c,v 1.66 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: mdoc_validate.c,v 1.67 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -141,7 +141,7 @@ static      v_pre    pres_ss[] = { pre_ss, NULL };
 
 const  struct valids mdoc_valids[MDOC_MAX] = {
        { NULL, NULL },                         /* Ap */
-       { pres_dd, posts_text },                /* Dd */
+       { pres_dd, posts_wtext },               /* Dd */
        { pres_dt, posts_dt },                  /* Dt */
        { pres_os, NULL },                      /* Os */
        { pres_sh, posts_sh },                  /* Sh */ 
index d7bff4d..fd5ecb1 100644 (file)
@@ -1,4 +1,4 @@
-.\"    $Id: roff.7,v 1.7 2010/07/13 01:09:13 schwarze Exp $
+.\"    $Id: roff.7,v 1.8 2010/07/31 21:43:07 schwarze Exp $
 .\"
 .\" Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
 .\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: July 13 2010 $
+.Dd $Mdocdate: July 31 2010 $
 .Dt ROFF 7
 .Os
 .Sh NAME
@@ -106,6 +106,15 @@ The
 .Cm key
 values may be invoked in subsequent text by using \e*(NN for two-letter
 pairs, \e*N for one-letter, and \e*[NNN] for arbitrary-length values.
+.Pp
+If
+.Cm val
+is begun with a double-quote mark, the mark is passed over.
+.Cm val
+consists of
+.Em all
+text following this point, including whitespace and trailing
+double-quotes.
 .Ss \&de1
 The syntax of this macro is the same as that of
 .Sx \&ig ,
index 0d9fd8c..5710500 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: roff.c,v 1.9 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: roff.c,v 1.10 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -943,30 +943,40 @@ roff_cond(ROFF_ARGS)
 static enum rofferr
 roff_ds(ROFF_ARGS)
 {
-       char *name, *string, *end;
+       char            *name, *string;
+
+       /*
+        * A symbol is named by the first word following the macro
+        * invocation up to a space.  Its value is anything after the
+        * name's trailing whitespace and optional double-quote.  Thus,
+        *
+        *  [.ds foo "bar  "     ]
+        *
+        * will have `bar  "     ' as its value.
+        */
 
        name = *bufp + pos;
        if ('\0' == *name)
                return(ROFF_IGN);
 
        string = name;
+       /* Read until end of name. */
        while (*string && ' ' != *string)
                string++;
+
+       /* Nil-terminate name. */
        if (*string)
-               *(string++) = NULL;
-       if (*string && '"' == *string)
-               string++;
+               *(string++) = '\0';
+       
+       /* Read past spaces. */
        while (*string && ' ' == *string)
                string++;
-       end = string;
-       while (*end)
-               end++;
-       if (string < end) {
-               end--;
-               if (*end == '"')
-                       *end = '\0';
-       }
 
+       /* Read passed initial double-quote. */
+       if (*string && '"' == *string)
+               string++;
+
+       /* The rest is the value. */
        roff_setstr(r, name, string);
        return(ROFF_IGN);
 }
@@ -1040,7 +1050,7 @@ roff_getstrn(const struct roff *r, const char *name, size_t len)
        const struct roffstr *n;
 
        n = r->first_string;
-       while (n && (strncmp(name, n->name, len) || '\0' != n->name[len]))
+       while (n && (strncmp(name, n->name, len) || '\0' != n->name[(int)len]))
                n = n->next;
 
        return(n ? n->string : NULL);
index 231616c..562a525 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: term.c,v 1.45 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: term.c,v 1.46 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -33,7 +33,6 @@
 static void              spec(struct termp *, enum roffdeco,
                                const char *, size_t);
 static void              res(struct termp *, const char *, size_t);
-static void              buffera(struct termp *, const char *, size_t);
 static void              bufferc(struct termp *, char);
 static void              adjbuf(struct termp *p, size_t);
 static void              encode(struct termp *, const char *, size_t);
@@ -238,10 +237,10 @@ term_flushln(struct termp *p)
                        if ('\t' == p->buf[i])
                                break;
                        if (' ' == p->buf[i]) {
-                               while (' ' == p->buf[i]) {
-                                       vbl += (*p->width)(p, p->buf[i]);
+                               j = i;
+                               while (' ' == p->buf[i])
                                        i++;
-                               }
+                               vbl += (i - j) * (*p->width)(p, ' ');
                                break;
                        }
                        if (ASCII_NBRSP == p->buf[i]) {
@@ -499,6 +498,8 @@ term_word(struct termp *p, const char *word)
 
        if ( ! (p->flags & TERMP_NONOSPACE))
                p->flags &= ~TERMP_NOSPACE;
+       else
+               p->flags |= TERMP_NOSPACE;
 
        p->flags &= ~TERMP_SENTENCE;
 
@@ -577,18 +578,6 @@ adjbuf(struct termp *p, size_t sz)
 }
 
 
-static void
-buffera(struct termp *p, const char *word, size_t sz)
-{
-
-       if (p->col + sz >= p->maxcols) 
-               adjbuf(p, p->col + sz);
-
-       memcpy(&p->buf[(int)p->col], word, sz);
-       p->col += sz;
-}
-
-
 static void
 bufferc(struct termp *p, char c)
 {
@@ -613,23 +602,31 @@ encode(struct termp *p, const char *word, size_t sz)
         */
 
        if (TERMFONT_NONE == (f = term_fonttop(p))) {
-               buffera(p, word, sz);
+               if (p->col + sz >= p->maxcols) 
+                       adjbuf(p, p->col + sz);
+               memcpy(&p->buf[(int)p->col], word, sz);
+               p->col += sz;
                return;
        }
 
+       /* Pre-buffer, assuming worst-case. */
+
+       if (p->col + 1 + (sz * 3) >= p->maxcols)
+               adjbuf(p, p->col + 1 + (sz * 3));
+
        for (i = 0; i < (int)sz; i++) {
                if ( ! isgraph((u_char)word[i])) {
-                       bufferc(p, word[i]);
+                       p->buf[(int)p->col++] = word[i];
                        continue;
                }
 
                if (TERMFONT_UNDER == f)
-                       bufferc(p, '_');
+                       p->buf[(int)p->col++] = '_';
                else
-                       bufferc(p, word[i]);
+                       p->buf[(int)p->col++] = word[i];
 
-               bufferc(p, 8);
-               bufferc(p, word[i]);
+               p->buf[(int)p->col++] = 8;
+               p->buf[(int)p->col++] = word[i];
        }
 }
 
index fd67cd9..102cb18 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: term.h,v 1.26 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: term.h,v 1.27 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -64,9 +64,11 @@ struct       termp_ps {
        size_t            left;         /* body left (AFM units) */
        size_t            header;       /* header pos (AFM units) */
        size_t            footer;       /* footer pos (AFM units) */
-       size_t            pdfbytes;
-       size_t            pdflastpg;
-       size_t            pdfbody;
+       size_t            pdfbytes;     /* current output byte */
+       size_t            pdflastpg;    /* byte of last page mark */
+       size_t            pdfbody;      /* start of body object */
+       size_t           *pdfobjs;      /* table of object offsets */
+       size_t            pdfobjsz;     /* size of pdfobjs */
 };
 
 struct termp {
index 5d570c6..5f42db5 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: term_ps.c,v 1.7 2010/07/25 18:05:54 schwarze Exp $ */
+/*     $Id: term_ps.c,v 1.8 2010/07/31 21:43:07 schwarze Exp $ */
 /*
  * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -384,6 +384,7 @@ static      void              ps_printf(struct termp *, const char *, ...);
 static void              ps_putchar(struct termp *, char);
 static void              ps_setfont(struct termp *, enum termfont);
 static struct termp     *pspdf_alloc(char *);
+static void              pdf_obj(struct termp *, size_t);
 
 
 void *
@@ -391,10 +392,9 @@ pdf_alloc(char *outopts)
 {
        struct termp    *p;
 
-       if (NULL == (p = pspdf_alloc(outopts)))
-               return(p);
+       if (NULL != (p = pspdf_alloc(outopts)))
+               p->type = TERMTYPE_PDF;
 
-       p->type = TERMTYPE_PDF;
        return(p);
 }
 
@@ -404,10 +404,9 @@ ps_alloc(char *outopts)
 {
        struct termp    *p;
 
-       if (NULL == (p = pspdf_alloc(outopts)))
-               return(p);
+       if (NULL != (p = pspdf_alloc(outopts)))
+               p->type = TERMTYPE_PS;
 
-       p->type = TERMTYPE_PS;
        return(p);
 }
 
@@ -522,6 +521,8 @@ pspdf_free(void *arg)
 
        if (p->engine.ps.psmarg)
                free(p->engine.ps.psmarg);
+       if (p->engine.ps.pdfobjs)
+               free(p->engine.ps.pdfobjs);
 
        term_free(p);
 }
@@ -563,8 +564,6 @@ ps_printf(struct termp *p, const char *fmt, ...)
        va_end(ap);
 
        p->engine.ps.psmargcur = strlen(p->engine.ps.psmarg);
-       p->engine.ps.pdfbytes += /* LINTED */
-               len < 0 ? 0 : (size_t)len;
 }
 
 
@@ -589,52 +588,74 @@ ps_putchar(struct termp *p, char c)
 }
 
 
+static void
+pdf_obj(struct termp *p, size_t obj)
+{
+
+       assert(obj > 0);
+
+       if ((obj - 1) >= p->engine.ps.pdfobjsz) {
+               p->engine.ps.pdfobjsz = obj + 128;
+               p->engine.ps.pdfobjs = realloc
+                       (p->engine.ps.pdfobjs, 
+                        p->engine.ps.pdfobjsz * sizeof(size_t));
+               if (NULL == p->engine.ps.pdfobjs) {
+                       perror(NULL);
+                       exit(EXIT_FAILURE);
+               }
+       }
+
+       p->engine.ps.pdfobjs[(int)obj - 1] = p->engine.ps.pdfbytes;
+       ps_printf(p, "%zu 0 obj\n", obj);
+}
+
+
 static void
 ps_closepage(struct termp *p)
 {
        int              i;
-       size_t           len;
+       size_t           len, base;
+
+       /*
+        * Close out a page that we've already flushed to output.  In
+        * PostScript, we simply note that the page must be showed.  In
+        * PDF, we must now create the Length, Resource, and Page node
+        * for the page contents.
+        */
 
        assert(p->engine.ps.psmarg && p->engine.ps.psmarg[0]);
        ps_printf(p, "%s", p->engine.ps.psmarg);
 
-       if (TERMTYPE_PS == p->type) {
-               ps_printf(p, "showpage\n");
-       } else {
+       if (TERMTYPE_PS != p->type) {
                ps_printf(p, "ET\n");
+
                len = p->engine.ps.pdfbytes - p->engine.ps.pdflastpg;
-               ps_printf(p, "endstream\n");
-               ps_printf(p, "endobj\n");
-               ps_printf(p, "%zu 0 obj\n", 
-                               p->engine.ps.pdfbody +
-                               (p->engine.ps.pages + 1) * 4 + 1);
-               ps_printf(p, "%zu\n", len);
-               ps_printf(p, "endobj\n");
-               ps_printf(p, "%zu 0 obj\n", 
-                               p->engine.ps.pdfbody +
-                               (p->engine.ps.pages + 1) * 4 + 2);
-               ps_printf(p, "<<\n");
-               ps_printf(p, "/ProcSet [/PDF /Text]\n");
+               base = p->engine.ps.pages * 4 + p->engine.ps.pdfbody;
+
+               ps_printf(p, "endstream\nendobj\n");
+
+               /* Length of content. */
+               pdf_obj(p, base + 1);
+               ps_printf(p, "%zu\nendobj\n", len);
+
+               /* Resource for content. */
+               pdf_obj(p, base + 2);
+               ps_printf(p, "<<\n/ProcSet [/PDF /Text]\n");
                ps_printf(p, "/Font <<\n");
                for (i = 0; i < (int)TERMFONT__MAX; i++) 
                        ps_printf(p, "/F%d %d 0 R\n", i, 3 + i);
-               ps_printf(p, ">>\n");
-               ps_printf(p, ">>\n");
-               ps_printf(p, "%zu 0 obj\n", 
-                               p->engine.ps.pdfbody +
-                               (p->engine.ps.pages + 1) * 4 + 3);
+               ps_printf(p, ">>\n>>\n");
+
+               /* Page node. */
+               pdf_obj(p, base + 3);
                ps_printf(p, "<<\n");
                ps_printf(p, "/Type /Page\n");
                ps_printf(p, "/Parent 2 0 R\n");
-               ps_printf(p, "/Resources %zu 0 R\n",
-                               p->engine.ps.pdfbody +
-                               (p->engine.ps.pages + 1) * 4 + 2);
-               ps_printf(p, "/Contents %zu 0 R\n",
-                               p->engine.ps.pdfbody +
-                               (p->engine.ps.pages + 1) * 4);
-               ps_printf(p, ">>\n");
-               ps_printf(p, "endobj\n");
-       }
+               ps_printf(p, "/Resources %zu 0 R\n", base + 2);
+               ps_printf(p, "/Contents %zu 0 R\n", base);
+               ps_printf(p, ">>\nendobj\n");
+       } else
+               ps_printf(p, "showpage\n");
 
        p->engine.ps.pages++;
        p->engine.ps.psrow = p->engine.ps.top;
@@ -647,7 +668,7 @@ ps_closepage(struct termp *p)
 static void
 ps_end(struct termp *p)
 {
-       size_t           i, xref;
+       size_t           i, xref, base;
 
        /*
         * At the end of the file, do one last showpage.  This is the
@@ -668,9 +689,8 @@ ps_end(struct termp *p)
                return;
        } 
 
-       ps_printf(p, "2 0 obj\n");
-       ps_printf(p, "<<\n");
-       ps_printf(p, "/Type /Pages\n");
+       pdf_obj(p, 2);
+       ps_printf(p, "<<\n/Type /Pages\n");
        ps_printf(p, "/MediaBox [0 0 %zu %zu]\n",
                        (size_t)AFM2PNT(p, p->engine.ps.width),
                        (size_t)AFM2PNT(p, p->engine.ps.height));
@@ -679,33 +699,31 @@ ps_end(struct termp *p)
        ps_printf(p, "/Kids [");
 
        for (i = 0; i < p->engine.ps.pages; i++)
-               ps_printf(p, " %zu 0 R", 
-                               p->engine.ps.pdfbody +
-                               (i + 1) * 4 + 3);
-       ps_printf(p, "]\n");
-       ps_printf(p, ">>\n");
-       ps_printf(p, "endobj\n");
-       ps_printf(p, "%zu 0 obj\n",
-                       p->engine.ps.pdfbody +
-                       (p->engine.ps.pages * 4) + 4);
+               ps_printf(p, " %zu 0 R", i * 4 +
+                               p->engine.ps.pdfbody + 3);
+
+       base = (p->engine.ps.pages - 1) * 4 + 
+               p->engine.ps.pdfbody + 4;
+
+       ps_printf(p, "]\n>>\nendobj\n");
+       pdf_obj(p, base);
        ps_printf(p, "<<\n");
        ps_printf(p, "/Type /Catalog\n");
        ps_printf(p, "/Pages 2 0 R\n");
        ps_printf(p, ">>\n");
        xref = p->engine.ps.pdfbytes;
        ps_printf(p, "xref\n");
-       ps_printf(p, "0 %zu\n",
-                       p->engine.ps.pdfbody +
-                       (p->engine.ps.pages * 4) + 5);
-       ps_printf(p, "0000000000 65535 f\n");
+       ps_printf(p, "0 %zu\n", base + 1);
+       ps_printf(p, "0000000000 65535 f \n");
+
+       for (i = 0; i < base; i++)
+               ps_printf(p, "%.10zu 00000 n \n", 
+                               p->engine.ps.pdfobjs[(int)i]);
+
        ps_printf(p, "trailer\n");
        ps_printf(p, "<<\n");
-       ps_printf(p, "/Size %zu\n", 
-                       p->engine.ps.pdfbody +
-                       (p->engine.ps.pages * 4) + 5);
-       ps_printf(p, "/Root %zu 0 R\n", 
-                       p->engine.ps.pdfbody +
-                       (p->engine.ps.pages * 4) + 4);
+       ps_printf(p, "/Size %zu\n", base + 1);
+       ps_printf(p, "/Root %zu 0 R\n", base);
        ps_printf(p, "/Info 1 0 R\n");
        ps_printf(p, ">>\n");
        ps_printf(p, "startxref\n");
@@ -730,7 +748,7 @@ ps_begin(struct termp *p)
                p->engine.ps.psmarg[0] = '\0';
        }
 
-       p->engine.ps.pdfbytes = 0;
+       /*p->engine.ps.pdfbytes = 0;*/
        p->engine.ps.psmargcur = 0;
        p->engine.ps.flags = PS_MARGINS;
        p->engine.ps.pscol = p->engine.ps.left;
@@ -780,14 +798,14 @@ ps_begin(struct termp *p)
                ps_printf(p, "\n%%%%EndComments\n");
        } else {
                ps_printf(p, "%%PDF-1.1\n");
-               ps_printf(p, "1 0 obj\n");
+               pdf_obj(p, 1);
                ps_printf(p, "<<\n");
                ps_printf(p, "/Creator mandoc-%s\n", VERSION);
                ps_printf(p, ">>\n");
                ps_printf(p, "endobj\n");
 
                for (i = 0; i < (int)TERMFONT__MAX; i++) {
-                       ps_printf(p, "%d 0 obj\n", i + 3);
+                       pdf_obj(p, (size_t)i + 3);
                        ps_printf(p, "<<\n");
                        ps_printf(p, "/Type /Font\n");
                        ps_printf(p, "/Subtype /Type1\n");
@@ -824,13 +842,12 @@ ps_pletter(struct termp *p, int c)
                                        fonts[(int)p->engine.ps.lastf].name, 
                                        p->engine.ps.scale);
                } else {
-                       ps_printf(p, "%zu 0 obj\n", 
-                                       p->engine.ps.pdfbody +
-                                       (p->engine.ps.pages + 1) * 4);
+                       pdf_obj(p, p->engine.ps.pdfbody + 
+                                       p->engine.ps.pages * 4);
                        ps_printf(p, "<<\n");
                        ps_printf(p, "/Length %zu 0 R\n", 
-                                       p->engine.ps.pdfbody +
-                                       (p->engine.ps.pages + 1) * 4 + 1);
+                                       p->engine.ps.pdfbody + 1 +
+                                       p->engine.ps.pages * 4);
                        ps_printf(p, ">>\nstream\n");
                }
                p->engine.ps.pdflastpg = p->engine.ps.pdfbytes;