version 1.104, 2011/03/20 16:02:05 |
version 1.107, 2011/04/19 16:38:48 |
|
|
#include <string.h> |
#include <string.h> |
#include <time.h> |
#include <time.h> |
|
|
|
#include "mdoc.h" |
#include "mandoc.h" |
#include "mandoc.h" |
#include "libmdoc.h" |
#include "libmdoc.h" |
#include "libmandoc.h" |
#include "libmandoc.h" |
Line 50 static int in_line(MACRO_PROT_ARGS); |
|
Line 51 static int in_line(MACRO_PROT_ARGS); |
|
static int obsolete(MACRO_PROT_ARGS); |
static int obsolete(MACRO_PROT_ARGS); |
static int phrase_ta(MACRO_PROT_ARGS); |
static int phrase_ta(MACRO_PROT_ARGS); |
|
|
|
static int dword(struct mdoc *, int, int, |
|
const char *, enum mdelim); |
static int append_delims(struct mdoc *, |
static int append_delims(struct mdoc *, |
int, int *, char *); |
int, int *, char *); |
static enum mdoct lookup(enum mdoct, const char *); |
static enum mdoct lookup(enum mdoct, const char *); |
Line 580 rew_sub(enum mdoc_type t, struct mdoc *m, |
|
Line 583 rew_sub(enum mdoc_type t, struct mdoc *m, |
|
return(1); |
return(1); |
} |
} |
|
|
|
/* |
|
* Allocate a word and check whether it's punctuation or not. |
|
* Punctuation consists of those tokens found in mdoc_isdelim(). |
|
*/ |
|
static int |
|
dword(struct mdoc *m, int line, |
|
int col, const char *p, enum mdelim d) |
|
{ |
|
|
|
if (DELIM_MAX == d) |
|
d = mdoc_isdelim(p); |
|
|
|
if ( ! mdoc_word_alloc(m, line, col, p)) |
|
return(0); |
|
|
|
if (DELIM_OPEN == d) |
|
m->last->flags |= MDOC_DELIMO; |
|
else if (DELIM_CLOSE == d) |
|
m->last->flags |= MDOC_DELIMC; |
|
|
|
return(1); |
|
} |
|
|
static int |
static int |
append_delims(struct mdoc *m, int line, int *pos, char *buf) |
append_delims(struct mdoc *m, int line, int *pos, char *buf) |
{ |
{ |
Line 593 append_delims(struct mdoc *m, int line, int *pos, char |
|
Line 618 append_delims(struct mdoc *m, int line, int *pos, char |
|
|
|
for (;;) { |
for (;;) { |
la = *pos; |
la = *pos; |
ac = mdoc_zargs(m, line, pos, buf, ARGS_NOWARN, &p); |
ac = mdoc_zargs(m, line, pos, buf, &p); |
|
|
if (ARGS_ERROR == ac) |
if (ARGS_ERROR == ac) |
return(0); |
return(0); |
else if (ARGS_EOLN == ac) |
else if (ARGS_EOLN == ac) |
break; |
break; |
|
|
assert(DELIM_NONE != mandoc_isdelim(p)); |
dword(m, line, la, p, DELIM_MAX); |
if ( ! mdoc_word_alloc(m, line, la, p)) |
|
return(0); |
|
|
|
/* |
/* |
* If we encounter end-of-sentence symbols, then trigger |
* If we encounter end-of-sentence symbols, then trigger |
Line 746 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 769 blk_exp_close(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! mdoc_word_alloc(m, line, lastarg, p)) |
if ( ! dword(m, line, lastarg, p, DELIM_MAX)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 870 in_line(MACRO_PROT_ARGS) |
|
Line 893 in_line(MACRO_PROT_ARGS) |
|
* the word. |
* the word. |
*/ |
*/ |
|
|
d = ARGS_QWORD == ac ? DELIM_NONE : mandoc_isdelim(p); |
d = ARGS_QWORD == ac ? DELIM_NONE : mdoc_isdelim(p); |
|
|
if (DELIM_NONE != d) { |
if (DELIM_NONE != d) { |
/* |
/* |
Line 905 in_line(MACRO_PROT_ARGS) |
|
Line 928 in_line(MACRO_PROT_ARGS) |
|
|
|
if (DELIM_NONE == d) |
if (DELIM_NONE == d) |
cnt++; |
cnt++; |
if ( ! mdoc_word_alloc(m, line, la, p)) |
|
|
if ( ! dword(m, line, la, p, d)) |
return(0); |
return(0); |
|
|
/* |
/* |
Line 1060 blk_full(MACRO_PROT_ARGS) |
|
Line 1084 blk_full(MACRO_PROT_ARGS) |
|
ARGS_PHRASE != ac && |
ARGS_PHRASE != ac && |
ARGS_PPHRASE != ac && |
ARGS_PPHRASE != ac && |
ARGS_QWORD != ac && |
ARGS_QWORD != ac && |
DELIM_OPEN == mandoc_isdelim(p)) { |
DELIM_OPEN == mdoc_isdelim(p)) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_OPEN)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1113 blk_full(MACRO_PROT_ARGS) |
|
Line 1137 blk_full(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_MAX)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1223 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1247 blk_part_imp(MACRO_PROT_ARGS) |
|
break; |
break; |
|
|
if (NULL == body && ARGS_QWORD != ac && |
if (NULL == body && ARGS_QWORD != ac && |
DELIM_OPEN == mandoc_isdelim(p)) { |
DELIM_OPEN == mdoc_isdelim(p)) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_OPEN)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1238 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1262 blk_part_imp(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_MAX)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1354 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1378 blk_part_exp(MACRO_PROT_ARGS) |
|
/* Flush out leading punctuation. */ |
/* Flush out leading punctuation. */ |
|
|
if (NULL == head && ARGS_QWORD != ac && |
if (NULL == head && ARGS_QWORD != ac && |
DELIM_OPEN == mandoc_isdelim(p)) { |
DELIM_OPEN == mdoc_isdelim(p)) { |
assert(NULL == body); |
assert(NULL == body); |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_OPEN)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1377 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1401 blk_part_exp(MACRO_PROT_ARGS) |
|
assert(head); |
assert(head); |
/* No check whether it's a macro! */ |
/* No check whether it's a macro! */ |
if (MDOC_Eo == tok) |
if (MDOC_Eo == tok) |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_MAX)) |
return(0); |
return(0); |
|
|
if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) |
if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) |
Line 1395 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1419 blk_part_exp(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_MAX)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1500 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1524 in_line_argn(MACRO_PROT_ARGS) |
|
break; |
break; |
|
|
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && |
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && |
ARGS_QWORD != ac && |
ARGS_QWORD != ac && 0 == j && |
0 == j && DELIM_OPEN == mandoc_isdelim(p)) { |
DELIM_OPEN == mdoc_isdelim(p)) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_OPEN)) |
return(0); |
return(0); |
continue; |
continue; |
} else if (0 == j) |
} else if (0 == j) |
Line 1530 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1554 in_line_argn(MACRO_PROT_ARGS) |
|
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && |
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && |
ARGS_QWORD != ac && |
ARGS_QWORD != ac && |
! flushed && |
! flushed && |
DELIM_NONE != mandoc_isdelim(p)) { |
DELIM_NONE != mdoc_isdelim(p)) { |
if ( ! rew_elem(m, tok)) |
if ( ! rew_elem(m, tok)) |
return(0); |
return(0); |
flushed = 1; |
flushed = 1; |
Line 1552 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1576 in_line_argn(MACRO_PROT_ARGS) |
|
} |
} |
#endif |
#endif |
|
|
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_MAX)) |
return(0); |
return(0); |
j++; |
j++; |
} |
} |
Line 1623 in_line_eoln(MACRO_PROT_ARGS) |
|
Line 1647 in_line_eoln(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_MAX)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1693 phrase(struct mdoc *m, int line, int ppos, char *buf) |
|
Line 1717 phrase(struct mdoc *m, int line, int ppos, char *buf) |
|
for (pos = ppos; ; ) { |
for (pos = ppos; ; ) { |
la = pos; |
la = pos; |
|
|
ac = mdoc_zargs(m, line, &pos, buf, 0, &p); |
ac = mdoc_zargs(m, line, &pos, buf, &p); |
|
|
if (ARGS_ERROR == ac) |
if (ARGS_ERROR == ac) |
return(0); |
return(0); |
Line 1703 phrase(struct mdoc *m, int line, int ppos, char *buf) |
|
Line 1727 phrase(struct mdoc *m, int line, int ppos, char *buf) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_MAX)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1738 phrase_ta(MACRO_PROT_ARGS) |
|
Line 1762 phrase_ta(MACRO_PROT_ARGS) |
|
|
|
for (;;) { |
for (;;) { |
la = *pos; |
la = *pos; |
ac = mdoc_zargs(m, line, pos, buf, 0, &p); |
ac = mdoc_zargs(m, line, pos, buf, &p); |
|
|
if (ARGS_ERROR == ac) |
if (ARGS_ERROR == ac) |
return(0); |
return(0); |
Line 1748 phrase_ta(MACRO_PROT_ARGS) |
|
Line 1772 phrase_ta(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! mdoc_word_alloc(m, line, la, p)) |
if ( ! dword(m, line, la, p, DELIM_MAX)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |