diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-09 14:19:59 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-09 14:19:59 +0000 |
commit | e5a9cad1c94b10a303a391c74d8b4dd29c494cce (patch) | |
tree | 9af1bcf9f9faedf1b3c6a1f29f3507e47d6f0b27 | |
parent | 028cb9cf2041bbee0ed488b669254a2a8bc9ccb9 (diff) | |
download | mandoc-e5a9cad1c94b10a303a391c74d8b4dd29c494cce.tar.gz |
Added `Mt' and `Lk' macros (NetBSD).
-rw-r--r-- | action.c | 2 | ||||
-rw-r--r-- | argv.c | 4 | ||||
-rw-r--r-- | macro.c | 2 | ||||
-rw-r--r-- | mdoc.c | 2 | ||||
-rw-r--r-- | mdoc.h | 4 | ||||
-rw-r--r-- | term.c | 52 | ||||
-rw-r--r-- | validate.c | 5 |
7 files changed, 66 insertions, 5 deletions
@@ -172,6 +172,8 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL }, /* Lb */ { NULL }, /* Ap */ { NULL }, /* Lp */ + { NULL }, /* Lk */ + { NULL }, /* Mt */ }; @@ -210,7 +210,9 @@ static int mdoc_argflags[MDOC_MAX] = { 0, /* Ud */ 0, /* Lb */ 0, /* Ap */ - 0, /* Lp */ + ARGS_DELIM, /* Lp */ + ARGS_DELIM | ARGS_QUOTED, /* Lk */ + ARGS_DELIM | ARGS_QUOTED, /* Mt */ }; @@ -180,6 +180,8 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { macro_constant, 0 }, /* Lb */ { macro_constant_delimited, MDOC_CALLABLE | MDOC_PARSED }, /* Ap */ { macro_text, 0 }, /* Lp */ + { macro_text, MDOC_PARSED }, /* Lk */ + { macro_text, MDOC_PARSED }, /* Mt */ }; const struct mdoc_macro * const mdoc_macros = __mdoc_macros; @@ -72,7 +72,7 @@ const char *const __mdoc_macronames[MDOC_MAX] = { "Fo", "Fc", "Oo", "Oc", "Bk", "Ek", "Bt", "Hf", "Fr", "Ud", "Lb", "Ap", - "Lp" + "Lp", "Lk", "Mt" }; const char *const __mdoc_argnames[MDOC_ARG_MAX] = { @@ -142,7 +142,9 @@ #define MDOC_Lb 106 #define MDOC_Ap 107 #define MDOC_Lp 108 -#define MDOC_MAX 109 +#define MDOC_Lk 109 +#define MDOC_Mt 110 +#define MDOC_MAX 111 /* What follows is a list of ALL possible macro arguments. */ @@ -53,7 +53,9 @@ #define TTYPE_SYMB 16 #define TTYPE_SYMBOL 17 #define TTYPE_DIAG 18 -#define TTYPE_NMAX 19 +#define TTYPE_LINK_ANCHOR 19 +#define TTYPE_LINK_TEXT 20 +#define TTYPE_NMAX 21 /* * These define "styles" for element types, like command arguments or @@ -82,7 +84,9 @@ const int ttypes[TTYPE_NMAX] = { TERMP_BOLD, /* TTYPE_INCLUDE */ TERMP_BOLD, /* TTYPE_SYMB */ TERMP_BOLD, /* TTYPE_SYMBOL */ - TERMP_BOLD /* TTYPE_DIAG */ + TERMP_BOLD, /* TTYPE_DIAG */ + TERMP_UNDERLINE, /* TTYPE_LINK_ANCHOR */ + TERMP_BOLD /* TTYPE_LINK_TEXT */ }; static int arg_hasattr(int, const struct mdoc_node *); @@ -146,7 +150,9 @@ DECL_PRE(termp_fa); DECL_PRE(termp_fl); DECL_PRE(termp_fx); DECL_PRE(termp_ic); +DECL_PRE(termp_lk); DECL_PRE(termp_ms); +DECL_PRE(termp_mt); DECL_PRE(termp_nd); DECL_PRE(termp_nm); DECL_PRE(termp_ns); @@ -279,6 +285,8 @@ const struct termact __termacts[MDOC_MAX] = { { termp_lb_pre, termp_lb_post }, /* Lb */ { termp_ap_pre, NULL }, /* Lb */ { termp_pp_pre, NULL }, /* Pp */ + { termp_lk_pre, NULL }, /* Lk */ + { termp_mt_pre, NULL }, /* Mt */ }; const struct termact *termacts = __termacts; @@ -1747,3 +1755,43 @@ termp____post(DECL_ARGS) p->flags |= TERMP_NOSPACE; word(p, node->next ? "," : "."); } + + +/* ARGSUSED */ +static int +termp_lk_pre(DECL_ARGS) +{ + const struct mdoc_node *n; + + if (NULL == (n = node->child)) + errx(1, "expected text line argument"); + if (MDOC_TEXT != n->type) + errx(1, "expected text line argument"); + + p->flags |= ttypes[TTYPE_LINK_ANCHOR]; + word(p, n->string); + p->flags &= ~ttypes[TTYPE_LINK_ANCHOR]; + p->flags |= TERMP_NOSPACE; + word(p, ":"); + + p->flags |= ttypes[TTYPE_LINK_TEXT]; + for ( ; n; n = n->next) { + if (MDOC_TEXT != n->type) + errx(1, "expected text line argument"); + word(p, n->string); + } + p->flags &= ~ttypes[TTYPE_LINK_TEXT]; + + return(0); +} + + +/* ARGSUSED */ +static int +termp_mt_pre(DECL_ARGS) +{ + + TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK_ANCHOR]); + return(1); +} + @@ -137,6 +137,7 @@ static int bwarn_ge1(POST_ARGS); static int hwarn_eq1(POST_ARGS); static int ewarn_ge1(POST_ARGS); static int ebool(POST_ARGS); + static int post_an(POST_ARGS); static int post_at(POST_ARGS); static int post_bf(POST_ARGS); @@ -179,12 +180,14 @@ 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_lb[] = { eerr_eq1, NULL }; +static v_post posts_mt[] = { eerr_ge1, NULL }; static v_post posts_st[] = { eerr_eq1, post_st, NULL }; static v_post posts_pp[] = { ewarn_eq0, NULL }; static v_post posts_ex[] = { eerr_eq0, post_ex, NULL }; static v_post posts_an[] = { post_an, NULL }; static v_post posts_at[] = { post_at, NULL }; static v_post posts_xr[] = { eerr_ge1, eerr_le2, NULL }; +static v_post posts_lk[] = { eerr_ge1, NULL }; static v_post posts_nm[] = { post_nm, NULL }; static v_post posts_bf[] = { hwarn_le1, post_bf, NULL }; static v_post posts_rs[] = { herr_eq0, bwarn_ge1, NULL }; @@ -302,6 +305,8 @@ const struct valids mdoc_valids[MDOC_MAX] = { { pres_lb, posts_lb }, /* Lb */ { NULL, NULL }, /* Lb */ { NULL, posts_pp }, /* Pp */ + { NULL, posts_lk }, /* Lk */ + { NULL, posts_mt }, /* Mt */ }; |