? config.h ? config.log ? foo.1 ? mandoc ? patch.txt ? regress/output Index: mdoc_action.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_action.c,v retrieving revision 1.61 diff -u -r1.61 mdoc_action.c --- mdoc_action.c 24 May 2010 11:59:37 -0000 1.61 +++ mdoc_action.c 26 May 2010 00:48:56 -0000 @@ -57,6 +57,7 @@ static int post_display(POST_ARGS); static int post_dt(POST_ARGS); static int post_lb(POST_ARGS); +static int post_li(POST_ARGS); static int post_nm(POST_ARGS); static int post_os(POST_ARGS); static int post_pa(POST_ARGS); @@ -102,7 +103,7 @@ { NULL, NULL }, /* Ft */ { NULL, NULL }, /* Ic */ { NULL, NULL }, /* In */ - { NULL, NULL }, /* Li */ + { NULL, post_li }, /* Li */ { NULL, NULL }, /* Nd */ { NULL, post_nm }, /* Nm */ { NULL, NULL }, /* Op */ @@ -309,6 +310,28 @@ m->next = MDOC_NEXT_CHILD; if ( ! mdoc_word_alloc(m, n->line, n->pos, m->meta.name)) + return(0); + m->last = nn; + return(1); +} + + +/* + * The `Li' macro gets a mysterious space when invoked without any + * arguments. Happens, e.g., `Ar expr Li : expr2'. + */ +static int +post_li(POST_ARGS) +{ + struct mdoc_node *nn; + + if (n->child) + return(1); + + nn = n; + m->next = MDOC_NEXT_CHILD; + + if ( ! mdoc_word_alloc(m, n->line, n->pos, "")) return(0); m->last = nn; return(1); Index: mdoc_macro.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_macro.c,v retrieving revision 1.68 diff -u -r1.68 mdoc_macro.c --- mdoc_macro.c 17 May 2010 22:11:42 -0000 1.68 +++ mdoc_macro.c 26 May 2010 00:48:56 -0000 @@ -754,7 +754,7 @@ static int in_line(MACRO_PROT_ARGS) { - int la, lastpunct, cnt, nc, nl; + int la, scope, cnt, nc, nl; enum margverr av; enum mdoct ntok; enum margserr ac; @@ -805,7 +805,7 @@ return(0); } - for (cnt = 0, lastpunct = 1;; ) { + for (cnt = scope = 0;; ) { la = *pos; ac = mdoc_args(m, line, pos, buf, tok, &p); @@ -826,7 +826,7 @@ */ if (MDOC_MAX != ntok) { - if (0 == lastpunct && ! rew_elem(m, tok)) + if (scope && ! rew_elem(m, tok)) return(0); if (nc && 0 == cnt) { if ( ! mdoc_elem_alloc(m, line, ppos, tok, arg)) @@ -853,14 +853,33 @@ d = ARGS_QWORD == ac ? DELIM_NONE : mdoc_isdelim(p); - if (ARGS_QWORD != ac && DELIM_NONE != d) { - if (0 == lastpunct && ! rew_elem(m, tok)) + if (DELIM_NONE != d) { + /* + * If we encounter closing punctuation, no word + * has been omitted, no scope is open, and we're + * allowed to have an empty element, then start + * a new scope. `Ar' and `Li', mysteriously, + * only do this once per invocation. + */ + if (0 == cnt && (nc || MDOC_Li == tok) && + DELIM_CLOSE == d && ! scope) { + if ( ! mdoc_elem_alloc(m, line, ppos, tok, arg)) + return(0); + if (MDOC_Ar == tok || MDOC_Li == tok) + cnt++; + scope = 1; + } + /* + * Close out our scope, if one is open, before + * any punctuation. + */ + if (scope && ! rew_elem(m, tok)) return(0); - lastpunct = 1; - } else if (lastpunct) { + scope = 0; + } else if ( ! scope) { if ( ! mdoc_elem_alloc(m, line, ppos, tok, arg)) return(0); - lastpunct = 0; + scope = 1; } if (DELIM_NONE == d) @@ -873,14 +892,14 @@ * word so that the `-' can be added to each one without * having to parse out spaces. */ - if (0 == lastpunct && MDOC_Fl == tok) { + if (scope && MDOC_Fl == tok) { if ( ! rew_elem(m, tok)) return(0); - lastpunct = 1; + scope = 0; } } - if (0 == lastpunct && ! rew_elem(m, tok)) + if (scope && ! rew_elem(m, tok)) return(0); /*