From: Kristaps Dzonsons <kristaps@bsd.lv>
To: "discuss@mdocml.bsd.lv" <discuss@mdocml.bsd.lv>
Subject: Re: .Li hiccup (and \*(Pu issue)
Date: Wed, 26 May 2010 02:49:44 +0200 [thread overview]
Message-ID: <4BFC7028.10007@bsd.lv> (raw)
In-Reply-To: <20100525232818.GA29800@iris.usta.de>
[-- Attachment #1: Type: text/plain, Size: 346 bytes --]
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
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3739 bytes --]
? 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);
/*
next prev parent reply other threads:[~2010-05-26 0:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20100525065543.GB8074@bramka.kerhand.co.uk>
[not found] ` <4BFBCEBB.4070205@bsd.lv>
[not found] ` <20100525141839.GG8074@bramka.kerhand.co.uk>
2010-05-25 20:42 ` Kristaps Dzonsons
2010-05-25 22:38 ` Jason McIntyre
2010-05-25 23:28 ` Ingo Schwarze
2010-05-26 0:49 ` Kristaps Dzonsons [this message]
2010-05-26 6:56 ` Jason McIntyre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BFC7028.10007@bsd.lv \
--to=kristaps@bsd.lv \
--cc=discuss@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).