summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-05-15 04:47:38 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-05-15 04:47:38 +0000
commit1db04df566a46d5f7b51e6496c47de3a488b01b5 (patch)
tree0d3e43748c7b0ee838fd811341e895a49aef3e1c
parente04a4aa3c39c11d12b11bb874246146990cd663a (diff)
downloadmandoc-1db04df566a46d5f7b51e6496c47de3a488b01b5.tar.gz
mandoc-1db04df566a46d5f7b51e6496c47de3a488b01b5.tar.zst
mandoc-1db04df566a46d5f7b51e6496c47de3a488b01b5.zip
More `Bl -column' dancing: It children also inherit in-phrase flags (noted by Ingo Schwarze).
-rw-r--r--libmdoc.h6
-rw-r--r--mdoc_argv.c8
-rw-r--r--mdoc_macro.c38
3 files changed, 22 insertions, 30 deletions
diff --git a/libmdoc.h b/libmdoc.h
index f632a4e5..ee77dd68 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.44 2010/05/14 17:31:25 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.45 2010/05/15 04:47:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -32,7 +32,8 @@ struct mdoc {
#define MDOC_LITERAL (1 << 1) /* in a literal scope */
#define MDOC_PBODY (1 << 2) /* in the document body */
#define MDOC_NEWLINE (1 << 3) /* first macro/text in a line */
-#define MDOC_PHRASELIT (1 << 4) /* in a literal within a phrase */
+#define MDOC_PHRASELIT (1 << 4) /* literal within a partila phrase */
+#define MDOC_PPHRASE (1 << 5) /* within a partial phrase */
int pflags;
enum mdoc_next next;
struct mdoc_node *last;
@@ -189,7 +190,6 @@ enum margserr mdoc_zargs(struct mdoc *, int,
#define ARGS_DELIM (1 << 1)
#define ARGS_TABSEP (1 << 2)
#define ARGS_NOWARN (1 << 3)
-#define ARGS_PPHRASED (1 << 4)
int mdoc_macroend(struct mdoc *);
diff --git a/mdoc_argv.c b/mdoc_argv.c
index 44b72071..cacc3a80 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.46 2010/05/14 12:55:22 kristaps Exp $ */
+/* $Id: mdoc_argv.c,v 1.47 2010/05/15 04:47:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -399,7 +399,7 @@ args(struct mdoc *m, int line, int *pos,
assert(' ' != buf[*pos]);
if ('\0' == buf[*pos]) {
- if (ARGS_PPHRASED & fl)
+ if (MDOC_PPHRASE & m->flags)
return(ARGS_EOLN);
/*
* If we're not in a partial phrase and the flag for
@@ -525,7 +525,7 @@ args(struct mdoc *m, int line, int *pos,
if ( ! (MDOC_PHRASELIT & m->flags))
*v = &buf[++(*pos)];
- if (ARGS_PPHRASED & fl)
+ if (MDOC_PPHRASE & m->flags)
m->flags |= MDOC_PHRASELIT;
for ( ; buf[*pos]; (*pos)++) {
@@ -537,7 +537,7 @@ args(struct mdoc *m, int line, int *pos,
}
if ('\0' == buf[*pos]) {
- if (ARGS_NOWARN & fl || ARGS_PPHRASED & fl)
+ if (ARGS_NOWARN & fl || MDOC_PPHRASE & m->flags)
return(ARGS_QWORD);
if ( ! mdoc_pwarn(m, line, *pos, EQUOTTERM))
return(ARGS_ERROR);
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 0a89e563..079b8aa5 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.64 2010/05/14 14:09:13 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.65 2010/05/15 04:47:38 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -972,12 +972,18 @@ blk_full(MACRO_PROT_ARGS)
if (ARGS_EOLN == ac)
break;
+ if (ARGS_PEND == ac) {
+ if (ARGS_PPHRASE == lac)
+ ac = ARGS_PPHRASE;
+ else
+ ac = ARGS_PHRASE;
+ }
+
/* Don't emit leading punct. for phrases. */
if (NULL == head &&
ARGS_PHRASE != ac &&
ARGS_PPHRASE != ac &&
- ARGS_PEND != ac &&
ARGS_QWORD != ac &&
1 == mdoc_isdelim(p)) {
if ( ! mdoc_word_alloc(m, line, la, p))
@@ -989,29 +995,18 @@ blk_full(MACRO_PROT_ARGS)
if (NULL == head ||
ARGS_PHRASE == ac ||
- ARGS_PEND == ac ||
ARGS_PPHRASE == ac) {
if ( ! mdoc_head_alloc(m, line, ppos, tok))
return(0);
head = m->last;
}
- if (ARGS_PHRASE == ac ||
- ARGS_PEND == ac ||
- ARGS_PPHRASE == ac) {
- /*
- * Special treatment for the last phrase. A
- * prior ARGS_PHRASE gets is handled as a
- * regular ARGS_PHRASE, but a prior ARGS_PPHRASE
- * has special handling.
- */
- if (ARGS_PEND == ac && ARGS_ERROR == lac)
- ac = ARGS_PHRASE;
- else if (ARGS_PEND == ac && ARGS_PHRASE == lac)
- ac = ARGS_PHRASE;
-
+ if (ARGS_PHRASE == ac || ARGS_PPHRASE == ac) {
+ if (ARGS_PPHRASE == ac)
+ m->flags |= MDOC_PPHRASE;
if ( ! phrase(m, line, la, buf, ac))
return(0);
+ m->flags &= ~MDOC_PPHRASE;
if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos))
return(0);
continue;
@@ -1569,22 +1564,19 @@ phrase(struct mdoc *m, int line, int ppos, char *buf, enum margserr ac)
enum mdoct ntok;
char *p;
- assert(ARGS_PHRASE == ac ||
- ARGS_PEND == ac ||
- ARGS_PPHRASE == ac);
+ assert(ARGS_PHRASE == ac || ARGS_PPHRASE == ac);
for (pos = ppos; ; ) {
la = pos;
- aac = mdoc_zargs(m, line, &pos, buf, ARGS_PPHRASED, &p);
+ aac = mdoc_zargs(m, line, &pos, buf, 0, &p);
if (ARGS_ERROR == aac)
return(0);
if (ARGS_EOLN == aac)
break;
- ntok = ARGS_QWORD == aac || ARGS_PEND == ac ?
- MDOC_MAX : lookup_raw(p);
+ ntok = ARGS_QWORD == aac ? MDOC_MAX : lookup_raw(p);
if (MDOC_MAX == ntok) {
if ( ! mdoc_word_alloc(m, line, la, p))