diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-02-22 19:23:48 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-02-22 19:23:48 +0000 |
commit | c9f801d9804d2a25f795302e5db93880df4f4d87 (patch) | |
tree | 7b147f5444b71e4c9386eeac77ed155e23156314 | |
parent | f25db392c434984141c67fb983517a0dd28c4fe1 (diff) | |
download | mandoc-c9f801d9804d2a25f795302e5db93880df4f4d87.tar.gz |
Fixed `.Pf' handling.
System now supports all mdocml manual pages.
-rw-r--r-- | macro.c | 16 | ||||
-rw-r--r-- | mdoctree.1 | 5 | ||||
-rw-r--r-- | term.c | 7 | ||||
-rw-r--r-- | term.h | 1 | ||||
-rw-r--r-- | termact.c | 79 | ||||
-rw-r--r-- | validate.c | 3 |
6 files changed, 99 insertions, 12 deletions
@@ -1086,7 +1086,8 @@ macro_constant_scoped(MACRO_PROT_ARGS) int macro_constant_delimited(MACRO_PROT_ARGS) { - int lastarg, flushed, j, c, maxargs, argc; + int lastarg, flushed, j, c, maxargs, argc, + igndelim; struct mdoc_arg argv[MDOC_LINEARG_MAX]; char *p; @@ -1098,8 +1099,6 @@ macro_constant_delimited(MACRO_PROT_ARGS) /* FALLTHROUGH */ case (MDOC_Ns): /* FALLTHROUGH */ - case (MDOC_Pf): - /* FALLTHROUGH */ case (MDOC_Ux): /* FALLTHROUGH */ case (MDOC_St): @@ -1110,6 +1109,15 @@ macro_constant_delimited(MACRO_PROT_ARGS) break; } + switch (tok) { + case (MDOC_Pf): + igndelim = 1; + break; + default: + igndelim = 0; + break; + } + for (argc = 0; argc < MDOC_LINEARG_MAX; argc++) { lastarg = *pos; c = mdoc_argv(mdoc, line, tok, &argv[argc], pos, buf); @@ -1167,7 +1175,7 @@ macro_constant_delimited(MACRO_PROT_ARGS) break; } - if ( ! flushed && mdoc_isdelim(p)) { + if ( ! flushed && mdoc_isdelim(p) && ! igndelim) { if ( ! rewind_elem(mdoc, tok)) return(0); flushed = 1; @@ -35,7 +35,10 @@ The .Nm utility parses a BSD .Dq mdoc -manual pages and prints its syntax tree. The arguments are as follows: +manual pages and prints its syntax tree. It's commonly used to see the +syntax tree of a document when building new +.Xr mdoc 3 +utilities. The arguments are as follows: .Bl -tag -width "\-Werr... " .\" ITEM .It Fl v @@ -319,8 +319,11 @@ word(struct termp *p, const char *word) len = strlen(word); assert(len > 0); - if (mdoc_isdelim(word)) - p->flags |= TERMP_NOSPACE; + if (mdoc_isdelim(word)) { + if ( ! (p->flags & TERMP_IGNDELIM)) + p->flags |= TERMP_NOSPACE; + p->flags &= ~TERMP_IGNDELIM; + } /* LINTED */ for (j = i = 0; i < len; i++) { @@ -36,6 +36,7 @@ struct termp { #define TERMP_NOLPAD (1 << 3) /* No leftpad before flush. */ #define TERMP_NOBREAK (1 << 4) /* No break after flush. */ #define TERMP_LITERAL (1 << 5) /* Literal words. */ +#define TERMP_IGNDELIM (1 << 6) /* Delims like regulars. */ char *buf; }; @@ -96,10 +96,14 @@ DECL_PRE(termp_it); DECL_PRE(termp_nd); DECL_PRE(termp_nm); DECL_PRE(termp_ns); +DECL_PRE(termp_nx); DECL_PRE(termp_op); +DECL_PRE(termp_ox); +DECL_PRE(termp_pf); DECL_PRE(termp_pp); DECL_PRE(termp_qq); DECL_PRE(termp_sh); +DECL_PRE(termp_sq); DECL_PRE(termp_sx); DECL_PRE(termp_ud); DECL_PRE(termp_va); @@ -119,8 +123,10 @@ DECL_POST(termp_ft); DECL_POST(termp_it); DECL_POST(termp_nm); DECL_POST(termp_op); +DECL_POST(termp_pf); DECL_POST(termp_qq); DECL_POST(termp_sh); +DECL_POST(termp_sq); DECL_POST(termp_sx); DECL_POST(termp_va); DECL_POST(termp_vt); @@ -200,10 +206,10 @@ const struct termact __termacts[MDOC_MAX] = { { NULL, NULL }, /* Ms */ { NULL, NULL }, /* No */ { termp_ns_pre, NULL }, /* Ns */ - { NULL, NULL }, /* Nx */ - { NULL, NULL }, /* Ox */ + { termp_nx_pre, NULL }, /* Nx */ + { termp_ox_pre, NULL }, /* Ox */ { NULL, NULL }, /* Pc */ - { NULL, NULL }, /* Pf */ + { termp_pf_pre, termp_pf_post }, /* Pf */ { NULL, NULL }, /* Po */ { NULL, NULL }, /* Pq */ { NULL, NULL }, /* Qc */ @@ -214,7 +220,7 @@ const struct termact __termacts[MDOC_MAX] = { { NULL, NULL }, /* Rs */ { NULL, NULL }, /* Sc */ { NULL, NULL }, /* So */ - { NULL, NULL }, /* Sq */ + { termp_sq_pre, termp_sq_post }, /* Sq */ { NULL, NULL }, /* Sm */ { termp_sx_pre, termp_sx_post }, /* Sx */ { NULL, NULL }, /* Sy */ @@ -969,3 +975,68 @@ termp_qq_post(DECL_ARGS) } +/* ARGSUSED */ +static int +termp_ox_pre(DECL_ARGS) +{ + + word(p, "OpenBSD"); + return(1); +} + + +/* ARGSUSED */ +static int +termp_nx_pre(DECL_ARGS) +{ + + word(p, "NetBSD"); + return(1); +} + + +/* ARGSUSED */ +static int +termp_sq_pre(DECL_ARGS) +{ + + if (MDOC_BODY != node->type) + return(1); + word(p, "`"); + p->flags |= TERMP_NOSPACE; + return(1); +} + + +/* ARGSUSED */ +static void +termp_sq_post(DECL_ARGS) +{ + + if (MDOC_BODY != node->type) + return; + p->flags |= TERMP_NOSPACE; + word(p, "\'"); +} + + +/* ARGSUSED */ +static int +termp_pf_pre(DECL_ARGS) +{ + + p->flags |= TERMP_IGNDELIM; + return(1); +} + + +/* ARGSUSED */ +static void +termp_pf_post(DECL_ARGS) +{ + + p->flags &= ~TERMP_IGNDELIM; + p->flags |= TERMP_NOSPACE; +} + + @@ -140,6 +140,7 @@ static v_post posts_bl[] = { herr_eq0, bwarn_ge1, post_bl, NULL }; static v_post posts_it[] = { post_it, NULL }; static v_post posts_in[] = { ewarn_eq1, NULL }; static v_post posts_ss[] = { herr_ge1, NULL }; +static v_post posts_pf[] = { eerr_eq1, NULL }; static v_post posts_pp[] = { ewarn_eq0, NULL }; static v_post posts_ex[] = { eerr_le1, post_ex, NULL }; static v_post posts_an[] = { post_an, NULL }; @@ -231,7 +232,7 @@ const struct valids mdoc_valids[MDOC_MAX] = { { NULL, NULL }, /* Nx */ { NULL, NULL }, /* Ox */ { NULL, NULL }, /* Pc */ - { NULL, NULL }, /* Pf */ + { NULL, posts_pf }, /* Pf */ { NULL, NULL }, /* Po */ { NULL, posts_wline }, /* Pq */ { NULL, NULL }, /* Qc */ |