From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-1.sys.kth.se (smtp-1.sys.kth.se [130.237.32.175]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o4Q0nsQS016253 for ; Tue, 25 May 2010 18:49:56 -0600 (MDT) Received: from localhost (localhost [127.0.0.1]) by smtp-1.sys.kth.se (Postfix) with ESMTP id 0D2B5155893 for ; Wed, 26 May 2010 02:49:49 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-1.sys.kth.se ([127.0.0.1]) by localhost (smtp-1.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GuGEg8yc8K46 for ; Wed, 26 May 2010 02:49:46 +0200 (CEST) X-KTH-Auth: kristaps [85.8.61.146] X-KTH-mail-from: kristaps@bsd.lv X-KTH-rcpt-to: discuss@mdocml.bsd.lv Received: from lappy.bsd.lv (h85-8-61-146.dynamic.se.alltele.net [85.8.61.146]) by smtp-1.sys.kth.se (Postfix) with ESMTP id EA342154137 for ; Wed, 26 May 2010 02:49:45 +0200 (CEST) Message-ID: <4BFC7028.10007@bsd.lv> Date: Wed, 26 May 2010 02:49:44 +0200 From: Kristaps Dzonsons User-Agent: Thunderbird 2.0.0.16 (X11/20080812) X-Mailinglist: mdocml-discuss Reply-To: discuss@mdocml.bsd.lv MIME-Version: 1.0 To: "discuss@mdocml.bsd.lv" Subject: Re: .Li hiccup (and \*(Pu issue) References: <20100525065543.GB8074@bramka.kerhand.co.uk> <4BFBCEBB.4070205@bsd.lv> <20100525141839.GG8074@bramka.kerhand.co.uk> <4BFC3639.8030409@bsd.lv> <20100525232818.GA29800@iris.usta.de> In-Reply-To: <20100525232818.GA29800@iris.usta.de> Content-Type: multipart/mixed; boundary="------------030809080308030001080302" This is a multi-part message in MIME format. --------------030809080308030001080302 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit This patch seems to fix these issues. Ingo, let's cross over to tech@ if you have comments (it's lacking regression tests and documentation). Note that `Ar' behaves differently between versions of groff: old groff doesn't print out the "file ..." when invoked as `.Ar [ ( : ( :'. I vaguely remember this being discussed long ago. Kristaps --------------030809080308030001080302 Content-Type: text/plain; name="patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch.txt" ? 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); /* --------------030809080308030001080302-- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv