From a78f7ea60ac3b0e2c941afc20e674fe437317174 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Fri, 17 Jul 2009 12:40:48 +0000 Subject: `sp' documented: validates & produces correct output. --- mdoc.7 | 56 +++++++++++++++++++++++++++++++------------------------- mdoc_term.c | 26 ++++++++++++++++++++++++-- mdoc_validate.c | 6 ++++-- 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/mdoc.7 b/mdoc.7 index 8f5e8551..a22d5bdc 100644 --- a/mdoc.7 +++ b/mdoc.7 @@ -1,4 +1,4 @@ -.\" $Id: mdoc.7,v 1.44 2009/07/17 12:08:08 kristaps Exp $ +.\" $Id: mdoc.7,v 1.45 2009/07/17 12:40:48 kristaps Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons .\" @@ -414,6 +414,7 @@ then the macro accepts an arbitrary number of arguments. .It \&Vt Ta Yes Ta Yes Ta >0 .It \&Xr Ta Yes Ta Yes Ta >0, <3 .It \&br Ta \&No Ta \&No Ta 0 +.It \&sp Ta \&No Ta \&No Ta 1 .El .\" SECTION--------------------------------------------- .Sh COMPATIBILITY @@ -431,6 +432,11 @@ file re-write .Bl -dash -compact .\" LIST-ITEM .It +The +.Sq \&sp +macro does not accept negative numbers. +.\" LIST-ITEM +.It Some character sequences in groff are not handled depending on escape style, e.g., .Sq \e(ba @@ -457,25 +463,25 @@ made historic groff but is a proper delimiter in this implementation. .\" LIST-ITEM .It -.Sq \&.It \-nested +.Sq \&It \-nested is assumed for all lists (it wasn't in historic groff): any list may be nested and .Sq \-enum lists will restart the sequence only for the sub-list. .\" LIST-ITEM .It -.Sq \&.It \-column +.Sq \&It \-column syntax where column widths may be preceded by other arguments (instead of proceeded) is not supported. .\" LIST-ITEM .It The -.Sq \&.At +.Sq \&At macro only accepts a single parameter. .\" LIST-ITEM .It Some manuals use -.Sq \&.Li +.Sq \&Li incorrectly by following it with a reserved character and expecting the delimiter to render. This is not supported. .\" LIST-ITEM @@ -487,7 +493,7 @@ versions of groff seem to dither on this. .\" LIST-ITEM .It In groff, the -.Sq \&.Fo +.Sq \&Fo macro only produces the first parameter. This is no longer the case. .El .\" SECTION--------------------------------------------- @@ -508,69 +514,69 @@ There are many ambiguous parts of mdoc. .Bl -dash -compact .\" LIST-ITEM .It -.Sq \&.Fa +.Sq \&Fa should be -.Sq \&.Va +.Sq \&Va as function arguments are variables. .\" LIST-ITEM .It -.Sq \&.Ft +.Sq \&Ft should be -.Sq \&.Vt +.Sq \&Vt as function return types are still types. Furthermore, the -.Sq \&.Ft +.Sq \&Ft should be removed and -.Sq \&.Fo , +.Sq \&Fo , which ostensibly follows it, should follow the same convention as -.Sq \&.Va . +.Sq \&Va . .\" LIST-ITEM .It -.Sq \&.Va +.Sq \&Va should formalise that only one or two arguments are acceptable: a variable name and optional, preceding type. .\" LIST-ITEM .It -.Sq \&.Fd +.Sq \&Fd is ambiguous. It's commonly used to indicate an include file in the synopsis section. -.Sq \&.In +.Sq \&In should be used, instead. .\" LIST-ITEM .It Only the .Sq \-literal argument to -.Sq \&.Bd +.Sq \&Bd makes sense. The remaining ones should be removed. .\" LIST-ITEM .It The -.Sq \&.Xo +.Sq \&Xo and -.Sq \&.Xc +.Sq \&Xc macros should be deprecated. .\" LIST-ITEM .It The -.Sq \&.Dt +.Sq \&Dt macro lacks clarity. It should be absolutely clear which title will render when formatting the manual page. .\" LIST-ITEM .It A -.Sq \&.Lx +.Sq \&Lx should be provided for Linux (\(`a la -.Sq \&.Ox , -.Sq \&.Nx +.Sq \&Ox , +.Sq \&Nx etc.). .\" LIST-ITEM .It There's no way to refer to references in -.Sq \&.Rs/.Re +.Sq \&Rs/Re blocks. .\" LIST-ITEM .It The \-split and \-nosplit arguments to -.Sq \&.An +.Sq \&An are inane. .El diff --git a/mdoc_term.c b/mdoc_term.c index 41338aa5..f290a91d 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.44 2009/07/17 10:56:57 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.45 2009/07/17 12:40:48 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -164,6 +164,7 @@ static int termp_rs_pre(DECL_ARGS); static int termp_rv_pre(DECL_ARGS); static int termp_sh_pre(DECL_ARGS); static int termp_sm_pre(DECL_ARGS); +static int termp_sp_pre(DECL_ARGS); static int termp_sq_pre(DECL_ARGS); static int termp_ss_pre(DECL_ARGS); static int termp_sx_pre(DECL_ARGS); @@ -294,7 +295,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_xx_pre, NULL }, /* Dx */ { NULL, NULL }, /* %Q */ { termp_br_pre, NULL }, /* br */ - { NULL, NULL }, /* sp */ + { termp_sp_pre, NULL }, /* sp */ }; #ifdef __linux__ @@ -1831,6 +1832,27 @@ termp_in_post(DECL_ARGS) } +/* ARGSUSED */ +static int +termp_sp_pre(DECL_ARGS) +{ + int i, len; + + if (NULL == node->child) { + term_vspace(p); + return(0); + } + + len = atoi(node->child->string); + if (0 == len) + term_newln(p); + for (i = 0; i < len; i++) + term_vspace(p); + + return(0); +} + + /* ARGSUSED */ static int termp_br_pre(DECL_ARGS) diff --git a/mdoc_validate.c b/mdoc_validate.c index 433ba11a..5d2be450 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.35 2009/07/17 12:27:49 kristaps Exp $ */ +/* $Id: mdoc_validate.c,v 1.36 2009/07/17 12:40:48 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -1138,6 +1138,8 @@ post_sp(POST_ARGS) if (NULL == mdoc->last->child) return(1); + else if ( ! eerr_eq1(mdoc)) + return(0); assert(MDOC_TEXT == mdoc->last->child->type); buf = mdoc->last->child->string; @@ -1150,7 +1152,7 @@ post_sp(POST_ARGS) return(mdoc_nerr(mdoc, mdoc->last->child, ENUMFMT)); if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || - (lval > INT_MAX || lval < INT_MIN)) + (lval > INT_MAX || lval < 0)) return(mdoc_nerr(mdoc, mdoc->last->child, ENUMFMT)); return(1); -- cgit v1.2.3-56-ge451