diff options
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/html.c | 7 | ||||
-rw-r--r-- | usr.bin/mandoc/html.h | 25 | ||||
-rw-r--r-- | usr.bin/mandoc/libmdoc.h | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/man.7 | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/man_validate.c | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.c | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.7 | 206 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 64 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_action.c | 29 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 86 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 29 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 24 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 50 | ||||
-rw-r--r-- | usr.bin/mandoc/out.c | 149 | ||||
-rw-r--r-- | usr.bin/mandoc/out.h | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/term.c | 14 |
17 files changed, 379 insertions, 342 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile index e578cfd97be..d6e9e290f28 100644 --- a/usr.bin/mandoc/Makefile +++ b/usr.bin/mandoc/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.32 2010/04/02 12:39:47 schwarze Exp $ +# $OpenBSD: Makefile,v 1.33 2010/04/07 23:15:05 schwarze Exp $ .include <bsd.own.mk> -VERSION=1.9.22 +VERSION=1.9.23 CFLAGS+=-DVERSION=\"${VERSION}\" CFLAGS+=-W -Wall -Wstrict-prototypes .if ${USE_GCC3:L} != "no" diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c index c9429eb93fe..8b747ffd0ab 100644 --- a/usr.bin/mandoc/html.c +++ b/usr.bin/mandoc/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.6 2010/02/18 02:11:25 schwarze Exp $ */ +/* $Id: html.c,v 1.7 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -85,7 +85,6 @@ static const char *const htmlattrs[ATTR_MAX] = { "summary", }; - 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); @@ -504,8 +503,6 @@ print_text(struct html *h, const char *p) case(')'): /* FALLTHROUGH */ case(']'): - /* FALLTHROUGH */ - case('}'): if ( ! (HTML_IGNDELIM & h->flags)) h->flags |= HTML_NOSPACE; break; @@ -525,8 +522,6 @@ print_text(struct html *h, const char *p) case('('): /* FALLTHROUGH */ case('['): - /* FALLTHROUGH */ - case('{'): h->flags |= HTML_NOSPACE; break; default: diff --git a/usr.bin/mandoc/html.h b/usr.bin/mandoc/html.h index 2ac9402ef75..7bb789c98d0 100644 --- a/usr.bin/mandoc/html.h +++ b/usr.bin/mandoc/html.h @@ -1,4 +1,4 @@ -/* $Id: html.h,v 1.5 2010/02/18 02:11:26 schwarze Exp $ */ +/* $Id: html.h,v 1.6 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -90,18 +90,17 @@ struct htmlpair { const char *val; }; -#define PAIR_CLASS_INIT(p, v) \ - do { (p)->key = ATTR_CLASS; \ - (p)->val = (v); } while (/* CONSTCOND */ 0) -#define PAIR_HREF_INIT(p, v) \ - do { (p)->key = ATTR_HREF; \ - (p)->val = (v); } while (/* CONSTCOND */ 0) -#define PAIR_STYLE_INIT(p, h) \ - do { (p)->key = ATTR_STYLE; \ - (p)->val = (h)->buf; } while (/* CONSTCOND */ 0) -#define PAIR_SUMMARY_INIT(p, v) \ - do { (p)->key = ATTR_SUMMARY; \ - (p)->val = (v); } while (/* CONSTCOND */ 0) +#define PAIR_INIT(p, t, v) \ + do { \ + (p)->key = (t); \ + (p)->val = (v); \ + } while (/* CONSTCOND */ 0) + +#define PAIR_ID_INIT(p, v) PAIR_INIT(p, ATTR_ID, v) +#define PAIR_CLASS_INIT(p, v) PAIR_INIT(p, ATTR_CLASS, v) +#define PAIR_HREF_INIT(p, v) PAIR_INIT(p, ATTR_HREF, v) +#define PAIR_STYLE_INIT(p, h) PAIR_INIT(p, ATTR_STYLE, (h)->buf) +#define PAIR_SUMMARY_INIT(p, v) PAIR_INIT(p, ATTR_SUMMARY, v) enum htmltype { HTML_HTML_4_01_STRICT, diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h index b76f2ed8f04..acbeb51f8c2 100644 --- a/usr.bin/mandoc/libmdoc.h +++ b/usr.bin/mandoc/libmdoc.h @@ -1,4 +1,4 @@ -/* $Id: libmdoc.h,v 1.26 2010/04/03 16:30:42 schwarze Exp $ */ +/* $Id: libmdoc.h,v 1.27 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -137,8 +137,7 @@ int mdoc_block_alloc(struct mdoc *, int, int, int mdoc_head_alloc(struct mdoc *, int, int, enum mdoct); int mdoc_tail_alloc(struct mdoc *, int, int, enum mdoct); int mdoc_body_alloc(struct mdoc *, int, int, enum mdoct); -void mdoc_node_free(struct mdoc_node *); -void mdoc_node_freelist(struct mdoc_node *); +void mdoc_node_delete(struct mdoc *, struct mdoc_node *); void mdoc_hash_init(void); enum mdoct mdoc_hash_find(const char *); int mdoc_iscdelim(char); diff --git a/usr.bin/mandoc/man.7 b/usr.bin/mandoc/man.7 index 93c98c2f8ad..4174cb04361 100644 --- a/usr.bin/mandoc/man.7 +++ b/usr.bin/mandoc/man.7 @@ -1,4 +1,4 @@ -.\" $Id: man.7,v 1.19 2010/03/29 22:56:52 schwarze Exp $ +.\" $Id: man.7,v 1.20 2010/04/07 23:15:05 schwarze Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se> .\" @@ -14,7 +14,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: March 29 2010 $ +.Dd $Mdocdate: April 7 2010 $ .Dt MAN 7 .Os . @@ -440,7 +440,6 @@ If a next-line macro is followed by a non-next-line macro, an error is raised (unless in the case of .Sx \&br , .Sx \&sp , -.Sx \&Sp , or .Sx \&na ) . .Pp diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index 7347769d4f1..954849f650c 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.17 2010/04/03 16:33:01 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.18 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -166,7 +166,15 @@ check_root(CHKARGS) if (NULL == m->meta.title) { if ( ! man_nwarn(m, n, WNOTITLE)) return(0); + /* + * If a title hasn't been set, do so now (by + * implication, date and section also aren't set). + * + * FIXME: this should be in man_action.c. + */ m->meta.title = mandoc_strdup("unknown"); + m->meta.date = time(NULL); + m->meta.msec = 1; } return(1); diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c index 85c16657383..d03f7bf482d 100644 --- a/usr.bin/mandoc/mandoc.c +++ b/usr.bin/mandoc/mandoc.c @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.7 2010/02/18 02:11:26 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.8 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -69,10 +69,6 @@ mandoc_special(const char *p) return(2); case ('e'): return(2); - case ('f'): - if ('\0' == *++p || ! isgraph((u_char)*p)) - return(0); - return(3); case ('s'): if ('\0' == *++p) return(2); @@ -148,6 +144,10 @@ mandoc_special(const char *p) } return(c); + case ('f'): + /* FALLTHROUGH */ + case ('F'): + /* FALLTHROUGH */ case ('*'): if (0 == *++p || ! isgraph((u_char)*p)) return(0); diff --git a/usr.bin/mandoc/mdoc.7 b/usr.bin/mandoc/mdoc.7 index b90529353f0..329aa572db4 100644 --- a/usr.bin/mandoc/mdoc.7 +++ b/usr.bin/mandoc/mdoc.7 @@ -1,4 +1,4 @@ -.\" $Id: mdoc.7,v 1.24 2010/04/02 12:39:47 schwarze Exp $ +.\" $Id: mdoc.7,v 1.25 2010/04/07 23:15:05 schwarze Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se> .\" @@ -14,7 +14,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: April 2 2010 $ +.Dd $Mdocdate: April 7 2010 $ .Dt MDOC 7 .Os . @@ -860,7 +860,7 @@ then the macro accepts an arbitrary number of arguments. .It Sx \&Ot Ta \&No Ta \&No Ta n .It Sx \&Ox Ta Yes Ta Yes Ta n .It Sx \&Pa Ta Yes Ta Yes Ta n -.It Sx \&Pf Ta \&No Ta Yes Ta 1 +.It Sx \&Pf Ta Yes Ta Yes Ta 1 .It Sx \&Pp Ta \&No Ta \&No Ta 0 .It Sx \&Rv Ta \&No Ta \&No Ta n .It Sx \&Sm Ta \&No Ta \&No Ta 1 @@ -974,10 +974,8 @@ Address construct: usually in the context of an computational address in memory, not a physical (post) address. .Pp Examples: -.Bd -literal -offset indent -\&.Ad [0,$] -\&.Ad 0x00000000 -.Ed +.D1 \&.Ad [0,$] +.D1 \&.Ad 0x00000000 . .Ss \&An Author name. This macro may alternatively accepts the following @@ -998,11 +996,8 @@ will cause the first listing also to be split. If not in the AUTHORS section, the default is not to split. .Pp Examples: -.Bd -literal -offset indent -\&.An -nosplit -\&.An J. E. Hopcraft , -\&.An J. D. Ullman . -.Ed +.D1 \&.An -nosplit +.D1 \&.An J. D. Ullman . .Pp .Em Remarks : the effects of @@ -1019,9 +1014,7 @@ Begins a block enclosed by angled brackets. Does not have any head arguments. .Pp Examples: -.Bd -literal -offset indent -\&.Fl -key= Ns Ao Ar val Ac -.Ed +.D1 \&.Fl -key= \&Ns \&Ao \&Ar val \&Ac .Pp See also .Sx \&Aq . @@ -1038,9 +1031,7 @@ a function: Encloses its arguments in angled brackets. .Pp Examples: -.Bd -literal -offset indent -\&.Fl -key= Ns Aq Ar val -.Ed +.D1 \&.Fl -key= \&Ns \&Aq \&Ar val .Pp .Em Remarks : this macro is often abused for rendering URIs, which should instead use @@ -1061,11 +1052,9 @@ Command arguments. If an argument is not provided, the string is used as a default. .Pp Examples: -.Bd -literal -offset indent -\&.Fl o Ns Ar file1 -\&.Ar -\&.Ar arg1 , arg2 . -.Ed +.D1 \&.Fl o \&Ns \&Ar file1 +.D1 \&.Ar +.D1 \&.Ar arg1 , arg2 . . .Ss \&At Formats an AT&T version. Accepts at most one parameter: @@ -1081,10 +1070,8 @@ A system version of Note that these parameters do not begin with a hyphen. .Pp Examples: -.Bd -literal -offset indent -\&.At -\&.At V.1 -.Ed +.D1 \&.At +.D1 \&.At V.1 .Pp See also .Sx \&Bsx , @@ -1244,7 +1231,7 @@ arguments. Examples: .Bd -literal -offset indent \&.Bo 1 , -\&.Dv BUFSIZ Bc +\&.Dv BUFSIZ \&Bc .Ed .Pp See also @@ -1254,9 +1241,7 @@ See also Encloses its arguments in square brackets. .Pp Examples: -.Bd -literal -offset indent -\&.Bq 1 , Dv BUFSIZ -.Ed +.D1 \&.Bq 1 , \&Dv BUFSIZ .Pp .Em Remarks : this macro is sometimes abused to emulate optional arguments for @@ -1281,7 +1266,7 @@ arguments. Examples: .Bd -literal -offset indent \&.Bro 1 , ... , -\&.Va n Brc +\&.Va n \&Brc .Ed .Pp See also @@ -1291,9 +1276,7 @@ See also Encloses its arguments in curly braces. .Pp Examples: -.Bd -literal -offset indent -\&.Brq 1 , ... , Va n -.Ed +.D1 \&.Brq 1 , ... , \&Va n .Pp See also .Sx \&Bro . @@ -1303,10 +1286,8 @@ Format the BSD/OS version provided as an argument, or a default value if no argument is provided. .Pp Examples: -.Bd -literal -offset indent -\&.Bsx 1.0 -\&.Bsx -.Ed +.D1 \&.Bsx 1.0 +.D1 \&.Bsx .Pp See also .Sx \&At , @@ -1327,10 +1308,8 @@ Format the BSD version provided as an argument, or a default value if no argument is provided. .Pp Examples: -.Bd -literal -offset indent -\&.Bx 4.4 -\&.Bx -.Ed +.D1 \&.Bx 4.4 +.D1 \&.Bx .Pp See also .Sx \&At , @@ -1348,9 +1327,7 @@ manuals). This denotes strings accepted by .Xr config 8 . .Pp Examples: -.Bd -literal -offset indent -\&.Cd device le0 at scode? -.Ed +.D1 \&.Cd device le0 at scode? .Pp .Em Remarks : this macro is commonly abused by using quoted literals to retain @@ -1363,10 +1340,8 @@ Command modifiers. Useful when specifying configuration options or keys. .Pp Examples: -.Bd -literal -offset indent -\&.Cm ControlPath -\&.Cm ControlMaster -.Ed +.D1 \&.Cm ControlPath +.D1 \&.Cm ControlMaster .Pp See also .Sx \&Fl . @@ -1376,9 +1351,7 @@ One-line indented display. This is formatted by the default rules and is useful for simple indented statements. It is followed by a newline. .Pp Examples: -.Bd -literal -offset indent -\&.D1 Fl abcdefgh -.Ed +.D1 \&.D1 \&Fl abcdefgh .Pp See also .Sx \&Bd @@ -1409,11 +1382,9 @@ or instead a valid canonical date as specified by If a date does not conform, the current date is used instead. .Pp Examples: -.Bd -literal -offset indent -\&.Dd $\&Mdocdate$ -\&.Dd $\&Mdocdate: July 21 2007$ -\&.Dd July 21, 2007 -.Ed +.D1 \&.Dd $\&Mdocdate$ +.D1 \&.Dd $\&Mdocdate: July 21 2007$ +.D1 \&.Dd July 21, 2007 .Pp See also .Sx \&Dt @@ -1425,9 +1396,7 @@ One-line intended display. This is formatted as literal text and is useful for commands and invocations. It is followed by a newline. .Pp Examples: -.Bd -literal -offset indent -\&.Dl % mandoc mdoc.7 | less -.Ed +.D1 \&.Dl % mandoc mdoc.7 | less .Pp See also .Sx \&Bd @@ -1439,9 +1408,7 @@ Begins a block enclosed by double quotes. Does not have any head arguments. .Pp Examples: -.Bd -literal -offset indent -\&.D1 Do April is the cruellest month Dc \e(em T.S. Eliot -.Ed +.D1 \&.D1 \&Do April is the cruellest month \&Dc \e(em T.S. Eliot .Pp See also .Sx \&Dq . @@ -1450,7 +1417,7 @@ See also Encloses its arguments in double quotes. .Pp Examples: -.Bd -literal -offset indent +.Bd -literal -offset indent -compact \&.Dq April is the cruellest month \e(em T.S. Eliot .Ed @@ -1572,12 +1539,10 @@ or .El .Pp Examples: -.Bd -literal -offset indent -\&.Dt FOO 1 -\&.Dt FOO 4 KM -\&.Dt FOO 9 i386 -\&.Dt FOO 9 KM i386 -.Ed +.D1 \&.Dt FOO 1 +.D1 \&.Dt FOO 4 KM +.D1 \&.Dt FOO 9 i386 +.D1 \&.Dt FOO 9 KM i386 .Pp See also .Sx \&Dd @@ -1588,10 +1553,8 @@ and Defined variables such as preprocessor constants. .Pp Examples: -.Bd -literal -offset indent -\&.Dv BUFSIZ -\&.Dv STDOUT_FILENO -.Ed +.D1 \&.Dv BUFSIZ +.D1 \&.Dv STDOUT_FILENO .Pp See also .Sx \&Er . @@ -1601,10 +1564,8 @@ Format the DragonFly BSD version provided as an argument, or a default value if no argument is provided. .Pp Examples: -.Bd -literal -offset indent -\&.Dx 2.4.1 -\&.Dx -.Ed +.D1 \&.Dx 2.4.1 +.D1 \&.Dx .Pp See also .Sx \&At , @@ -1621,27 +1582,24 @@ and .Ss \&Ef .Ss \&Ek .Ss \&El +. .Ss \&Em Denotes text that should be emphasised. Note that this is a presentation term and should not be used for stylistically decorating technical terms. .Pp Examples: -.Bd -literal -offset indent -\&.Ed Warnings! -\&.Ed Remarks : -.Ed +.D1 \&.Em Warnings! +.D1 \&.Em Remarks : . .Ss \&En .Ss \&Eo .Ss \&Er -Error constants (suggested for use only in section two manuals). +Display error constants. .Pp Examples: -.Bd -literal -offset indent -\&.Er EPERM -\&.Er ENOENT -.Ed +.D1 \&.Er EPERM +.D1 \&.Er ENOENT .Pp See also .Sx \&Dv . @@ -1653,10 +1611,8 @@ Environmental variables such as those specified in .Xr environ 7 . .Pp Examples: -.Bd -literal -offset indent -\&.Ev DISPLAY -\&.Ev PATH -.Ed +.D1 \&.Ev DISPLAY +.D1 \&.Ev PATH . .Ss \&Ex Inserts text regarding a utility's exit values. This macro must have @@ -1676,15 +1632,15 @@ is provided. Command-line flag. Used when listing arguments to command-line utilities. Prints a fixed-width hyphen .Sq \- -before each delimited argument. If no arguments are provided, a hyphen -is still printed. +directly followed by each argument. If no arguments are provided, a hyphen is +printed followed by a space. If the argument is a macro, a hyphen is +prefixed to the subsequent macro output. .Pp Examples: -.Bd -literal -offset indent -\&.Fl a b c -\&.Fl -\&.Op Fl o Ns Ar file -.Ed +.D1 \&.Fl a b c +.D1 \&.Fl \&Pf a b +.D1 \&.Fl +.D1 \&.Op \&Fl o \&Ns \&Ar file .Pp See also .Sx \&Cm . @@ -1698,10 +1654,8 @@ Format the FreeBSD version provided as an argument, or a default value if no argument is provided. .Pp Examples: -.Bd -literal -offset indent -\&.Fx 7.1 -\&.Fx -.Ed +.D1 \&.Fx 7.1 +.D1 \&.Fx .Pp See also .Sx \&At , @@ -1725,10 +1679,8 @@ Format a hyperlink. The calling syntax is as follows: .D1 \. Ns Sx \&Lk Cm uri Op Cm name .Pp Examples: -.Bd -literal -offset indent -\&.Lk http://bsd.lv "The BSD.lv Project" -\&.Lk http://bsd.lv -.Ed +.D1 \&.Lk http://bsd.lv "The BSD.lv Project" +.D1 \&.Lk http://bsd.lv .Pp See also .Sx \&Mt . @@ -1745,10 +1697,8 @@ Format the NetBSD version provided as an argument, or a default value if no argument is provided. .Pp Examples: -.Bd -literal -offset indent -\&.Nx 5.01 -\&.Nx -.Ed +.D1 \&.Nx 5.01 +.D1 \&.Nx .Pp See also .Sx \&At , @@ -1778,11 +1728,9 @@ unspecified, it defaults to the local operating system version. This is the suggested form. .Pp Examples: -.Bd -literal -offset indent -\&.Os -\&.Os KTH/CSC/TCS -\&.Os BSD 4.3 -.Ed +.D1 \&.Os +.D1 \&.Os KTH/CSC/TCS +.D1 \&.Os BSD 4.3 .Pp See also .Sx \&Dd @@ -1800,10 +1748,8 @@ Format the OpenBSD version provided as an argument, or a default value if no argument is provided. .Pp Examples: -.Bd -literal -offset indent -\&.Ox 4.5 -\&.Ox -.Ed +.D1 \&.Ox 4.5 +.D1 \&.Ox .Pp See also .Sx \&At , @@ -1853,7 +1799,7 @@ and child macros (at least one must be specified). .Pp Examples: -.Bd -literal -offset indent +.Bd -literal -offset indent -compact \&.Rs \&.%A J. E. Hopcroft \&.%A J. D. Ullman @@ -1886,9 +1832,7 @@ line. Format the UNIX name. Accepts no argument. .Pp Examples: -.Bd -literal -offset indent -\&.Ux -.Ed +.D1 \&.Ux .Pp See also .Sx \&At , @@ -1916,10 +1860,8 @@ Note that this should not be confused with which is used for function return types. .Pp Examples: -.Bd -literal -offset indent -\&.Vt unsigned char -\&.Vt extern const char * const sys_signame[] ; -.Ed +.D1 \&.Vt unsigned char +.D1 \&.Vt extern const char * const sys_signame[] ; .Pp See also .Sx \&Ft @@ -1955,11 +1897,9 @@ with .Xr groff 1 . .Pp Examples: -.Bd -literal -offset indent -\&.Xr mandoc 1 -\&.Xr mandoc 1 ; -\&.Xr mandoc 1 s behaviour -.Ed +.D1 \&.Xr mandoc 1 +.D1 \&.Xr mandoc 1 ; +.D1 \&.Xr mandoc 1 \&Ns s behaviour . .Ss \&br .Ss \&sp diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index 92f99390328..dac9a3512ad 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.39 2010/04/04 20:14:35 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.40 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -137,6 +137,9 @@ const char *const __mdoc_argnames[MDOC_ARG_MAX] = { const char * const *mdoc_macronames = __mdoc_macronames; const char * const *mdoc_argnames = __mdoc_argnames; +static void mdoc_node_free(struct mdoc_node *); +static void mdoc_node_unlink(struct mdoc *, + struct mdoc_node *); static void mdoc_free1(struct mdoc *); static void mdoc_alloc1(struct mdoc *); static struct mdoc_node *node_alloc(struct mdoc *, int, int, @@ -173,7 +176,7 @@ mdoc_free1(struct mdoc *mdoc) { if (mdoc->first) - mdoc_node_freelist(mdoc->first); + mdoc_node_delete(mdoc, mdoc->first); if (mdoc->meta.title) free(mdoc->meta.title); if (mdoc->meta.os) @@ -558,8 +561,6 @@ void mdoc_node_free(struct mdoc_node *p) { - if (p->parent) - p->parent->nchild--; if (p->string) free(p->string); if (p->args) @@ -568,16 +569,53 @@ mdoc_node_free(struct mdoc_node *p) } -void -mdoc_node_freelist(struct mdoc_node *p) +static void +mdoc_node_unlink(struct mdoc *m, struct mdoc_node *n) { - if (p->child) - mdoc_node_freelist(p->child); - if (p->next) - mdoc_node_freelist(p->next); + /* Adjust siblings. */ + + if (n->prev) + n->prev->next = n->next; + if (n->next) + n->next->prev = n->prev; + + /* Adjust parent. */ + + if (n->parent) { + n->parent->nchild--; + if (n->parent->child == n) + n->parent->child = n->prev ? n->prev : n->next; + } + + /* Adjust parse point, if applicable. */ + + if (m && m->last == n) { + if (n->prev) { + m->last = n->prev; + m->next = MDOC_NEXT_SIBLING; + } else { + m->last = n->parent; + m->next = MDOC_NEXT_CHILD; + } + } + + if (m && m->first == n) + m->first = NULL; +} + +void +mdoc_node_delete(struct mdoc *m, struct mdoc_node *p) +{ + + while (p->child) { + assert(p->nchild); + mdoc_node_delete(m, p->child); + } assert(0 == p->nchild); + + mdoc_node_unlink(m, p); mdoc_node_free(p); } @@ -611,6 +649,12 @@ parsetext(struct mdoc *m, int line, char *buf) if ('\0' == buf[i]) { if ( ! mdoc_pwarn(m, line, 0, ENOBLANK)) return(0); + /* + * Assume that a `Pp' should be inserted in the case of + * a blank line. Technically, blank lines aren't + * allowed, but enough manuals assume this behaviour + * that we want to work around it. + */ if ( ! mdoc_elem_alloc(m, line, 0, MDOC_Pp, NULL)) return(0); } diff --git a/usr.bin/mandoc/mdoc_action.c b/usr.bin/mandoc/mdoc_action.c index cff9330ed98..9c00b2ac66d 100644 --- a/usr.bin/mandoc/mdoc_action.c +++ b/usr.bin/mandoc/mdoc_action.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_action.c,v 1.29 2010/04/04 17:36:57 schwarze Exp $ */ +/* $Id: mdoc_action.c,v 1.30 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -417,6 +417,10 @@ post_sh(POST_ARGS) if ( ! concat(m, buf, n->child, BUFSIZ)) return(0); sec = mdoc_atosec(buf); + /* + * The first section should always make us move into a non-new + * state. + */ if (SEC_NONE == m->lastnamed || SEC_CUSTOM != sec) m->lastnamed = sec; @@ -722,7 +726,7 @@ post_bl_head(POST_ARGS) nn->string = NULL; nnp = nn; nn = nn->next; - mdoc_node_free(nnp); + mdoc_node_delete(NULL, nnp); } n->nchild = 0; @@ -847,29 +851,10 @@ post_dd(POST_ARGS) static int post_prol(POST_ARGS) { - struct mdoc_node *np; - - if (n->parent->child == n) - n->parent->child = n->prev; - if (n->prev) - n->prev->next = NULL; - - np = n; - assert(NULL == n->next); - - if (n->prev) { - m->last = n->prev; - m->next = MDOC_NEXT_SIBLING; - } else { - m->last = n->parent; - m->next = MDOC_NEXT_CHILD; - } - - mdoc_node_freelist(np); + mdoc_node_delete(m, n); if (m->meta.title && m->meta.date && m->meta.os) m->flags |= MDOC_PBODY; - return(1); } diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index f41d6acf420..8414e69ced0 100644 --- a/usr.bin/mandoc/mdoc_html.c +++ b/usr.bin/mandoc/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.10 2010/04/04 00:00:12 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.11 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -196,7 +196,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {NULL, NULL}, /* Dc */ {mdoc_dq_pre, mdoc_dq_post}, /* Do */ {mdoc_dq_pre, mdoc_dq_post}, /* Dq */ - {NULL, NULL}, /* Ec */ + {NULL, NULL}, /* Ec */ /* FIXME: no space */ {NULL, NULL}, /* Ef */ {mdoc_em_pre, NULL}, /* Em */ {NULL, NULL}, /* Eo */ @@ -586,14 +586,9 @@ mdoc_sh_pre(MDOC_ARGS) html_idcat(buf, " ", BUFSIZ); } - /* - * TODO: make sure there are no duplicates, as HTML does not - * allow for multiple `id' tags of the same name. - */ - PAIR_CLASS_INIT(&tag[0], "sec-head"); - tag[1].key = ATTR_ID; - tag[1].val = buf; + PAIR_ID_INIT(&tag[1], buf); + print_otag(h, TAG_DIV, 2, tag); return(1); } @@ -645,8 +640,8 @@ mdoc_ss_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag[0], "ssec-head"); PAIR_STYLE_INIT(&tag[1], h); - tag[2].key = ATTR_ID; - tag[2].val = buf; + PAIR_ID_INIT(&tag[2], buf); + print_otag(h, TAG_DIV, 3, tag); return(1); } @@ -668,10 +663,10 @@ mdoc_fl_pre(MDOC_ARGS) print_text(h, "\\-"); - /* A blank `Fl' should incur a subsequent space. */ - if (n->child) h->flags |= HTML_NOSPACE; + else if (n->next && n->next->line == n->line) + h->flags |= HTML_NOSPACE; return(1); } @@ -762,8 +757,7 @@ mdoc_xr_pre(MDOC_ARGS) buffmt_man(h, n->child->string, n->child->next ? n->child->next->string : NULL); - tag[1].key = ATTR_HREF; - tag[1].val = h->buf; + PAIR_HREF_INIT(&tag[1], h->buf); print_otag(h, TAG_A, 2, tag); } else print_otag(h, TAG_A, 1, tag); @@ -1119,6 +1113,8 @@ mdoc_bl_pre(MDOC_ARGS) { struct ord *ord; + if (MDOC_HEAD == n->type) + return(0); if (MDOC_BLOCK != n->type) return(1); if (MDOC_Enum != a2list(n)) @@ -1306,8 +1302,6 @@ mdoc_sx_pre(MDOC_ARGS) const struct mdoc_node *nn; char buf[BUFSIZ]; - /* FIXME: duplicates? */ - strlcpy(buf, "#", BUFSIZ); for (nn = n->child; nn; nn = nn->next) { html_idcat(buf, nn->string, BUFSIZ); @@ -1316,8 +1310,7 @@ mdoc_sx_pre(MDOC_ARGS) } PAIR_CLASS_INIT(&tag[0], "link-sec"); - tag[1].key = ATTR_HREF; - tag[1].val = buf; + PAIR_HREF_INIT(&tag[1], buf); print_otag(h, TAG_A, 2, tag); return(1); @@ -1392,6 +1385,7 @@ mdoc_bd_pre(MDOC_ARGS) } /* FIXME: -centered, etc. formatting. */ + /* FIXME: does not respect -offset ??? */ if (MDOC_BLOCK == n->type) { bufcat_su(h, "margin-left", &su); @@ -1583,15 +1577,15 @@ mdoc_vt_pre(MDOC_ARGS) struct htmlpair tag; struct roffsu su; - if (MDOC_BLOCK == n->type) { - if (n->prev && MDOC_Vt != n->prev->tok) { + if (SEC_SYNOPSIS == n->sec && MDOC_BLOCK == n->type) { + if (n->next && MDOC_Vt != n->next->tok) { SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-top", &su); + bufcat_su(h, "margin-bottom", &su); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_DIV, 1, &tag); } else print_otag(h, TAG_DIV, 0, NULL); - + return(1); } else if (MDOC_HEAD == n->type) return(0); @@ -1607,17 +1601,9 @@ static int mdoc_ft_pre(MDOC_ARGS) { struct htmlpair tag; - struct roffsu su; - if (SEC_SYNOPSIS == n->sec) { - if (n->prev && MDOC_Fo == n->prev->tok) { - SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-top", &su); - PAIR_STYLE_INIT(&tag, h); - print_otag(h, TAG_DIV, 1, &tag); - } else - print_otag(h, TAG_DIV, 0, NULL); - } + if (SEC_SYNOPSIS == n->sec) + print_otag(h, TAG_DIV, 0, NULL); PAIR_CLASS_INIT(&tag, "ftype"); print_otag(h, TAG_SPAN, 1, &tag); @@ -1671,10 +1657,27 @@ mdoc_fn_pre(MDOC_ARGS) } PAIR_CLASS_INIT(&tag[0], "fname"); + + /* + * FIXME: only refer to IDs that we know exist. + */ + +#if 0 + if (SEC_SYNOPSIS == n->sec) { + nbuf[0] = '\0'; + html_idcat(nbuf, sp, BUFSIZ); + PAIR_ID_INIT(&tag[1], nbuf); + } else { + strlcpy(nbuf, "#", BUFSIZ); + html_idcat(nbuf, sp, BUFSIZ); + PAIR_HREF_INIT(&tag[1], nbuf); + } +#endif + t = print_otag(h, TAG_SPAN, 1, tag); if (sp) { - (void)strlcpy(nbuf, sp, BUFSIZ); + strlcpy(nbuf, sp, BUFSIZ); print_text(h, nbuf); } @@ -1775,8 +1778,7 @@ mdoc_lk_pre(MDOC_ARGS) nn = n->child; PAIR_CLASS_INIT(&tag[0], "link-ext"); - tag[1].key = ATTR_HREF; - tag[1].val = nn->string; + PAIR_HREF_INIT(&tag[1], nn->string); print_otag(h, TAG_A, 2, tag); if (NULL == nn->next) @@ -1818,14 +1820,20 @@ static int mdoc_fo_pre(MDOC_ARGS) { struct htmlpair tag; + struct roffsu su; if (MDOC_BODY == n->type) { h->flags |= HTML_NOSPACE; print_text(h, "("); h->flags |= HTML_NOSPACE; return(1); - } else if (MDOC_BLOCK == n->type) + } else if (MDOC_BLOCK == n->type && n->next) { + SCALE_VS_INIT(&su, 1); + bufcat_su(h, "margin-bottom", &su); + PAIR_STYLE_INIT(&tag, h); + print_otag(h, TAG_DIV, 1, &tag); return(1); + } PAIR_CLASS_INIT(&tag, "fname"); print_otag(h, TAG_SPAN, 1, &tag); @@ -1885,8 +1893,8 @@ mdoc_in_pre(MDOC_ARGS) bufinit(h); if (h->base_includes) { buffmt_includes(h, nn->string); - tag[i].key = ATTR_HREF; - tag[i++].val = h->buf; + PAIR_HREF_INIT(&tag[i], h->buf); + i++; } t = print_otag(h, TAG_A, i, tag); print_mdoc_node(m, nn, h); diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 703aeaeb5ef..2cef1cc635c 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.34 2010/04/02 12:39:47 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.35 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -23,9 +23,11 @@ #include "libmdoc.h" -#define REWIND_REWIND (1 << 0) -#define REWIND_NOHALT (1 << 1) -#define REWIND_HALT (1 << 2) +enum rew { + REWIND_REWIND, + REWIND_NOHALT, + REWIND_HALT +}; static int ctx_synopsis(MACRO_PROT_ARGS); static int obsolete(MACRO_PROT_ARGS); @@ -38,7 +40,7 @@ static int blk_exp_close(MACRO_PROT_ARGS); static int blk_part_imp(MACRO_PROT_ARGS); static int phrase(struct mdoc *, int, int, char *); -static int rew_dohalt(enum mdoct, enum mdoc_type, +static enum rew rew_dohalt(enum mdoct, enum mdoc_type, const struct mdoc_node *); static enum mdoct rew_alt(enum mdoct); static int rew_dobreak(enum mdoct, const struct mdoc_node *); @@ -133,7 +135,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Nx */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ox */ { blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Pc */ - { in_line_argn, MDOC_PARSED | MDOC_IGNDELIM }, /* Pf */ + { in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_IGNDELIM }, /* Pf */ { blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Po */ { blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Pq */ { blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Qc */ @@ -365,7 +367,7 @@ rew_alt(enum mdoct tok) * close our current scope (REWIND_REWIND), or continue (REWIND_NOHALT). * The scope-closing and so on occurs in the various rew_* routines. */ -static int +static enum rew rew_dohalt(enum mdoct tok, enum mdoc_type type, const struct mdoc_node *p) { @@ -571,7 +573,7 @@ rew_sub(enum mdoc_type t, struct mdoc *m, enum mdoct tok, int line, int ppos) { struct mdoc_node *n; - int c; + enum rew c; /* LINTED */ for (n = m->last; n; n = n->parent) { @@ -812,7 +814,7 @@ in_line(MACRO_PROT_ARGS) * the word. */ - d = mdoc_isdelim(p); + d = ARGS_QWORD == w ? 0 : mdoc_isdelim(p); if (ARGS_QWORD != w && d) { if (0 == lastpunct && ! rew_elem(m, tok)) @@ -951,6 +953,7 @@ blk_full(MACRO_PROT_ARGS) /* Don't emit leading punct. for phrases. */ if (NULL == head && ARGS_PHRASE != c && + ARGS_QWORD != c && 1 == mdoc_isdelim(p)) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); @@ -1077,7 +1080,8 @@ blk_part_imp(MACRO_PROT_ARGS) * We must investigate the fallout before enabling this. */ #if 0 - if (NULL == body && 1 == mdoc_isdelim(p)) { + if (NULL == body && ARGS_QWORD != c && + 1 == mdoc_isdelim(p)) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); continue; @@ -1175,7 +1179,8 @@ blk_part_exp(MACRO_PROT_ARGS) #if 0 /* Flush out leading punctuation. */ - if (NULL == head && 1 == mdoc_isdelim(p)) { + if (NULL == head && ARGS_QWORD != c && + 1 == mdoc_isdelim(p)) { assert(NULL == body); if ( ! mdoc_word_alloc(m, line, la, p)) return(0); @@ -1317,6 +1322,7 @@ in_line_argn(MACRO_PROT_ARGS) */ #if 0 if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && + ARGS_QWORD != c && 0 == j && 1 == mdoc_isdelim(p)) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); @@ -1344,6 +1350,7 @@ in_line_argn(MACRO_PROT_ARGS) } if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && + ARGS_QWORD != c && ! flushed && mdoc_isdelim(p)) { if ( ! rew_elem(m, tok)) return(0); diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index d4d3de5a407..7753102eb35 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.72 2010/04/03 17:06:19 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.73 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -95,6 +95,7 @@ static int termp_ap_pre(DECL_ARGS); static int termp_aq_pre(DECL_ARGS); static int termp_bd_pre(DECL_ARGS); static int termp_bf_pre(DECL_ARGS); +static int termp_bl_pre(DECL_ARGS); static int termp_bold_pre(DECL_ARGS); static int termp_bq_pre(DECL_ARGS); static int termp_brq_pre(DECL_ARGS); @@ -145,7 +146,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_d1_pre, termp_d1_post }, /* Dl */ { termp_bd_pre, termp_bd_post }, /* Bd */ { NULL, NULL }, /* Ed */ - { NULL, termp_bl_post }, /* Bl */ + { termp_bl_pre, termp_bl_post }, /* Bl */ { NULL, NULL }, /* El */ { termp_it_pre, termp_it_post }, /* It */ { NULL, NULL }, /* Ad */ @@ -200,7 +201,7 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, NULL }, /* Dc */ { termp_dq_pre, termp_dq_post }, /* Do */ { termp_dq_pre, termp_dq_post }, /* Dq */ - { NULL, NULL }, /* Ec */ + { NULL, NULL }, /* Ec */ /* FIXME: no space */ { NULL, NULL }, /* Ef */ { termp_under_pre, NULL }, /* Em */ { NULL, NULL }, /* Eo */ @@ -1068,10 +1069,10 @@ termp_fl_pre(DECL_ARGS) term_fontpush(p, TERMFONT_BOLD); term_word(p, "\\-"); - /* A blank `Fl' should incur a subsequent space. */ - if (n->child) p->flags |= TERMP_NOSPACE; + else if (n->next && n->next->line == n->line) + p->flags |= TERMP_NOSPACE; return(1); } @@ -1248,6 +1249,15 @@ termp_nd_pre(DECL_ARGS) /* ARGSUSED */ +static int +termp_bl_pre(DECL_ARGS) +{ + + return(MDOC_HEAD != n->type); +} + + +/* ARGSUSED */ static void termp_bl_post(DECL_ARGS) { @@ -1592,8 +1602,8 @@ termp_bd_pre(DECL_ARGS) if (MDOC_BLOCK == n->type) { print_bvspace(p, n, n); return(1); - } else if (MDOC_BODY != n->type) - return(1); + } else if (MDOC_HEAD == n->type) + return(0); nn = n->parent; diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 7bb7b0b2fe8..1d6a9934a04 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.47 2010/04/03 17:06:19 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.48 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -73,6 +73,7 @@ static int ewarn_ge1(POST_ARGS); static int herr_eq0(POST_ARGS); static int herr_ge1(POST_ARGS); static int hwarn_eq1(POST_ARGS); +static int hwarn_eq0(POST_ARGS); static int hwarn_le1(POST_ARGS); static int post_an(POST_ARGS); @@ -97,7 +98,6 @@ static int pre_cd(PRE_ARGS); static int pre_dd(PRE_ARGS); static int pre_display(PRE_ARGS); static int pre_dt(PRE_ARGS); -static int pre_er(PRE_ARGS); static int pre_ex(PRE_ARGS); static int pre_fd(PRE_ARGS); static int pre_it(PRE_ARGS); @@ -109,7 +109,7 @@ static int pre_ss(PRE_ARGS); static v_post posts_an[] = { post_an, NULL }; static v_post posts_at[] = { post_at, NULL }; -static v_post posts_bd[] = { herr_eq0, bwarn_ge1, NULL }; +static v_post posts_bd[] = { hwarn_eq0, bwarn_ge1, NULL }; static v_post posts_bf[] = { hwarn_le1, post_bf, NULL }; static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL }; static v_post posts_bool[] = { eerr_eq1, ebool, NULL }; @@ -137,7 +137,7 @@ static v_pre pres_cd[] = { pre_cd, NULL }; static v_pre pres_d1[] = { pre_display, NULL }; static v_pre pres_dd[] = { pre_dd, NULL }; static v_pre pres_dt[] = { pre_dt, NULL }; -static v_pre pres_er[] = { pre_er, NULL }; +static v_pre pres_er[] = { NULL, NULL }; static v_pre pres_ex[] = { pre_ex, NULL }; static v_pre pres_fd[] = { pre_fd, NULL }; static v_pre pres_it[] = { pre_it, NULL }; @@ -411,6 +411,7 @@ CHECK_HEAD_DEFN(eq0, err, err_child_eq, 0) /* herr_eq0() */ CHECK_HEAD_DEFN(le1, warn, warn_child_lt, 2) /* hwarn_le1() */ CHECK_HEAD_DEFN(ge1, err, err_child_gt, 0) /* herr_ge1() */ CHECK_HEAD_DEFN(eq1, warn, warn_child_eq, 1) /* hwarn_eq1() */ +CHECK_HEAD_DEFN(eq0, warn, warn_child_eq, 0) /* hwarn_eq0() */ static int @@ -618,6 +619,15 @@ pre_bl(PRE_ARGS) case (MDOC_Inset): /* FALLTHROUGH */ case (MDOC_Column): + /* + * Note that if a duplicate is detected, we + * remove the duplicate instead of passing it + * over. If we don't do this, mdoc_action will + * become confused when it scans over multiple + * types whilst setting its bitmasks. + * + * FIXME: this should occur in mdoc_action.c. + */ if (type >= 0) { if ( ! mdoc_nwarn(mdoc, n, EMULTILIST)) return(0); @@ -790,14 +800,6 @@ pre_ex(PRE_ARGS) static int -pre_er(PRE_ARGS) -{ - - return(check_msec(mdoc, n, 2, 3, 9, 0)); -} - - -static int pre_cd(PRE_ARGS) { @@ -1084,21 +1086,23 @@ post_bl_head(POST_ARGS) { int i; const struct mdoc_node *n; + const struct mdoc_argv *a; n = mdoc->last->parent; assert(n->args); - for (i = 0; i < (int)n->args->argc; i++) - if (n->args->argv[i].arg == MDOC_Column) - break; + for (i = 0; i < (int)n->args->argc; i++) { + a = &n->args->argv[i]; + if (a->arg == MDOC_Column) { + if (a->sz && mdoc->last->nchild) + return(mdoc_nerr(mdoc, n, ECOLMIS)); + return(1); + } + } - if (i == (int)n->args->argc) + if (0 == (i = mdoc->last->nchild)) return(1); - - if (n->args->argv[i].sz && mdoc->last->child) - return(mdoc_nerr(mdoc, n, ECOLMIS)); - - return(1); + return(warn_count(mdoc, "==", 0, "line arguments", i)); } @@ -1310,8 +1314,8 @@ post_sh_head(POST_ARGS) * non-CUSTOM has a conventional order to be followed. */ - if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed && - ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME)) + if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed && + ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME)) return(0); if (SEC_CUSTOM == sec) return(1); diff --git a/usr.bin/mandoc/out.c b/usr.bin/mandoc/out.c index 4156738d78a..b0899288e25 100644 --- a/usr.bin/mandoc/out.c +++ b/usr.bin/mandoc/out.c @@ -1,4 +1,4 @@ -/* $Id: out.c,v 1.3 2009/12/24 02:08:14 schwarze Exp $ */ +/* $Id: out.c,v 1.4 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -193,14 +193,14 @@ int a2roffdeco(enum roffdeco *d, const char **word, size_t *sz) { - int j, type, term, lim; + int j, term, lim; + char set; const char *wp, *sp; *d = DECO_NONE; wp = *word; - type = 1; - switch (*wp) { + switch ((set = *wp)) { case ('\0'): return(0); @@ -215,6 +215,67 @@ a2roffdeco(enum roffdeco *d, *word = wp; return(3); + case ('F'): + /* FALLTHROUGH */ + case ('f'): + /* + * FIXME: this needs work and consolidation (it should + * follow the sequence that special characters do, for + * one), but isn't a priority at the moment. Note, for + * one, that in reality \fB != \FB, although here we let + * these slip by. + */ + switch (*(++wp)) { + case ('\0'): + return(1); + case ('3'): + /* FALLTHROUGH */ + case ('B'): + *d = DECO_BOLD; + return(2); + case ('2'): + /* FALLTHROUGH */ + case ('I'): + *d = DECO_ITALIC; + return(2); + case ('P'): + *d = DECO_PREVIOUS; + return(2); + case ('1'): + /* FALLTHROUGH */ + case ('R'): + *d = DECO_ROMAN; + return(2); + case ('('): + if ('\0' == *(++wp)) + return(2); + if ('\0' == *(wp + 1)) + return(3); + + *d = 'F' == set ? DECO_FFONT : DECO_FONT; + *sz = 2; + *word = wp; + return(4); + case ('['): + *word = ++wp; + for (j = 0; *wp && ']' != *wp; wp++, j++) + /* Loop... */ ; + + if ('\0' == *wp) + return(j + 2); + + *d = 'F' == set ? DECO_FFONT : DECO_FONT; + *sz = (size_t)j; + return(j + 3); + default: + break; + } + + *d = 'F' == set ? DECO_FFONT : DECO_FONT; + *sz = 1; + *word = wp; + return(2); + case ('*'): switch (*(++wp)) { case ('\0'): @@ -232,16 +293,25 @@ a2roffdeco(enum roffdeco *d, return(4); case ('['): - type = 0; - break; + *word = ++wp; + for (j = 0; *wp && ']' != *wp; wp++, j++) + /* Loop... */ ; + + if ('\0' == *wp) + return(j + 2); - default: *d = DECO_RESERVED; - *sz = 1; - *word = wp; - return(2); + *sz = (size_t)j; + return(j + 3); + + default: + break; } - break; + + *d = DECO_RESERVED; + *sz = 1; + *word = wp; + return(2); case ('s'): sp = wp; @@ -296,36 +366,18 @@ a2roffdeco(enum roffdeco *d, *d = DECO_SIZE; return((int)(wp - sp)); - case ('f'): - switch (*(++wp)) { - case ('\0'): - return(1); - case ('3'): - /* FALLTHROUGH */ - case ('B'): - *d = DECO_BOLD; - break; - case ('2'): - /* FALLTHROUGH */ - case ('I'): - *d = DECO_ITALIC; - break; - case ('P'): - *d = DECO_PREVIOUS; - break; - case ('1'): - /* FALLTHROUGH */ - case ('R'): - *d = DECO_ROMAN; - break; - default: - break; - } + case ('['): + *word = ++wp; - return(2); + for (j = 0; *wp && ']' != *wp; wp++, j++) + /* Loop... */ ; - case ('['): - break; + if ('\0' == *wp) + return(j + 1); + + *d = DECO_SPECIAL; + *sz = (size_t)j; + return(j + 2); case ('c'): *d = DECO_NOSPACE; @@ -333,20 +385,11 @@ a2roffdeco(enum roffdeco *d, return(1); default: - *d = DECO_SPECIAL; - *word = wp; - *sz = 1; - return(1); + break; } - *word = ++wp; - for (j = 0; *wp && ']' != *wp; wp++, j++) - /* Loop... */ ; - - if ('\0' == *wp) - return(j + 1); - - *d = type ? DECO_SPECIAL : DECO_RESERVED; - *sz = (size_t)j; - return (j + 2); + *d = DECO_SPECIAL; + *word = wp; + *sz = 1; + return(1); } diff --git a/usr.bin/mandoc/out.h b/usr.bin/mandoc/out.h index 330fdb31588..dee3d3c8017 100644 --- a/usr.bin/mandoc/out.h +++ b/usr.bin/mandoc/out.h @@ -1,4 +1,4 @@ -/* $Id: out.h,v 1.3 2009/12/24 02:08:14 schwarze Exp $ */ +/* $Id: out.h,v 1.4 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -45,6 +45,8 @@ enum roffdeco { DECO_PREVIOUS, DECO_SIZE, DECO_NOSPACE, + DECO_FONT, /* font */ + DECO_FFONT, /* font family */ DECO_MAX }; diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c index 06d9efab18d..9ab9b693bd6 100644 --- a/usr.bin/mandoc/term.c +++ b/usr.bin/mandoc/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.26 2010/03/26 01:22:07 schwarze Exp $ */ +/* $Id: term.c,v 1.27 2010/04/07 23:15:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -88,12 +88,10 @@ term_alloc(enum termenc enc) * Flush a line of text. A "line" is loosely defined as being something * that should be followed by a newline, regardless of whether it's * broken apart by newlines getting there. A line can also be a - * fragment of a columnar list. + * fragment of a columnar list (`Bl -tag' or `Bl -column'), which does + * not have a trailing newline. * - * Specifically, a line is whatever's in p->buf of length p->col, which - * is zeroed after this function returns. - * - * The usage of termp:flags is as follows: + * The following flags may be specified: * * - TERMP_NOLPAD: when beginning to write the line, don't left-pad the * offset value. This is useful when doing columnar lists where the @@ -453,8 +451,6 @@ term_word(struct termp *p, const char *word) case(')'): /* FALLTHROUGH */ case(']'): - /* FALLTHROUGH */ - case('}'): if ( ! (TERMP_IGNDELIM & p->flags)) p->flags |= TERMP_NOSPACE; break; @@ -513,8 +509,6 @@ term_word(struct termp *p, const char *word) case('('): /* FALLTHROUGH */ case('['): - /* FALLTHROUGH */ - case('{'): p->flags |= TERMP_NOSPACE; break; default: |