summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmdoc.h4
-rw-r--r--mdoc_argv.c6
-rw-r--r--mdoc_macro.c36
3 files changed, 19 insertions, 27 deletions
diff --git a/libmdoc.h b/libmdoc.h
index bf44541f..cff9a62b 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -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 c9e2170b..95c92e3e 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -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 caf7637c..8886a6b6 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -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))