diff options
-rw-r--r-- | action.c | 3 | ||||
-rw-r--r-- | argv.c | 3 | ||||
-rw-r--r-- | hash.c | 63 | ||||
-rw-r--r-- | macro.c | 11 | ||||
-rw-r--r-- | mdoc.c | 3 | ||||
-rw-r--r-- | mdoc.h | 5 | ||||
-rw-r--r-- | mdocterm.1 | 4 | ||||
-rw-r--r-- | mdocterm.c | 4 | ||||
-rw-r--r-- | term.c | 36 | ||||
-rw-r--r-- | term.h | 4 | ||||
-rw-r--r-- | validate.c | 3 |
11 files changed, 119 insertions, 20 deletions
@@ -174,6 +174,9 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL }, /* Lp */ { NULL }, /* Lk */ { NULL }, /* Mt */ + { NULL }, /* Brq */ + { NULL }, /* Bro */ + { NULL }, /* Brc */ }; @@ -213,6 +213,9 @@ static int mdoc_argflags[MDOC_MAX] = { ARGS_DELIM, /* Lp */ ARGS_DELIM | ARGS_QUOTED, /* Lk */ ARGS_DELIM | ARGS_QUOTED, /* Mt */ + ARGS_DELIM, /* Brq */ + 0, /* Bro */ + ARGS_DELIM, /* Brc */ }; @@ -45,7 +45,7 @@ mdoc_tokhash_alloc(void) int i, major, minor, ind; const void **htab; - htab = calloc(27 * 26, sizeof(struct mdoc_macro *)); + htab = calloc(27 * 26 * 3, sizeof(struct mdoc_macro *)); if (NULL == htab) err(1, "calloc"); @@ -74,9 +74,19 @@ mdoc_tokhash_alloc(void) assert(major >= 0 && major < 27); assert(minor >= 0 && minor < 26); - ind = (major * 27) + minor; + ind = (major * 27 * 3) + (minor * 3); - assert(NULL == htab[ind]); + if (NULL == htab[ind]) { + htab[ind] = &mdoc_macros[i]; + continue; + } + + if (NULL == htab[++ind]) { + htab[ind] = &mdoc_macros[i]; + continue; + } + + assert(NULL == htab[++ind]); htab[ind] = &mdoc_macros[i]; } @@ -118,25 +128,48 @@ mdoc_tokhash_find(const void *arg, const char *tmp) else minor = tmp[1] - 97; - ind = (major * 27) + minor; - if (ind < 0 || ind >= (27 * 26)) + ind = (major * 27 * 3) + (minor * 3); + if (ind < 0 || ind >= (27 * 26 * 3)) return(MDOC_MAX); - if (NULL == htab[ind]) - return(MDOC_MAX); + if (htab[ind]) { + slot = htab[ind] - /* LINTED */ + (void *)mdoc_macros; + assert(0 == (size_t)slot % sizeof(struct mdoc_macro)); + slot /= sizeof(struct mdoc_macro); + if (mdoc_macronames[slot][0] == tmp[0] && + mdoc_macronames[slot][1] == tmp[1] && + (0 == tmp[2] || + mdoc_macronames[slot][2] == tmp[2])) + return(slot); + ind++; + } + + if (htab[ind]) { + slot = htab[ind] - /* LINTED */ + (void *)mdoc_macros; + assert(0 == (size_t)slot % sizeof(struct mdoc_macro)); + slot /= sizeof(struct mdoc_macro); + if (mdoc_macronames[slot][0] == tmp[0] && + mdoc_macronames[slot][1] == tmp[1] && + (0 == tmp[2] || + mdoc_macronames[slot][2] == tmp[2])) + return(slot); + ind++; + } + if (NULL == htab[ind]) + return(MDOC_MAX); slot = htab[ind] - /* LINTED */ (void *)mdoc_macros; assert(0 == (size_t)slot % sizeof(struct mdoc_macro)); slot /= sizeof(struct mdoc_macro); + if (mdoc_macronames[slot][0] == tmp[0] && + mdoc_macronames[slot][1] == tmp[1] && + (0 == tmp[2] || + mdoc_macronames[slot][2] == tmp[2])) + return(slot); - if (mdoc_macronames[slot][0] != tmp[0]) - return(MDOC_MAX); - if (mdoc_macronames[slot][1] != tmp[1]) - return(MDOC_MAX); - if (tmp[2] && mdoc_macronames[slot][2] != tmp[2]) - return(MDOC_MAX); - - return(slot); + return(MDOC_MAX); } @@ -184,6 +184,9 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { macro_text, 0 }, /* Lp */ { macro_text, MDOC_PARSED }, /* Lk */ { macro_text, MDOC_PARSED }, /* Mt */ + { macro_scoped_line, MDOC_CALLABLE | MDOC_PARSED }, /* Brq */ + { macro_constant_scoped, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Bro */ + { macro_scoped_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Brc */ }; const struct mdoc_macro * const mdoc_macros = __mdoc_macros; @@ -326,6 +329,8 @@ rewind_alt(int tok) return(MDOC_Ao); case (MDOC_Bc): return(MDOC_Bo); + case (MDOC_Brc): + return(MDOC_Bro); case (MDOC_Dc): return(MDOC_Do); case (MDOC_Ec): @@ -375,6 +380,8 @@ rewind_dohalt(int tok, enum mdoc_type type, const struct mdoc_node *p) /* FALLTHROUGH */ case (MDOC_Bq): /* FALLTHROUGH */ + case (MDOC_Brq): + /* FALLTHROUGH */ case (MDOC_D1): /* FALLTHROUGH */ case (MDOC_Dl): @@ -429,6 +436,8 @@ rewind_dohalt(int tok, enum mdoc_type type, const struct mdoc_node *p) /* FALLTHROUGH */ case (MDOC_Bo): /* FALLTHROUGH */ + case (MDOC_Bro): + /* FALLTHROUGH */ case (MDOC_Do): /* FALLTHROUGH */ case (MDOC_Eo): @@ -455,6 +464,8 @@ rewind_dohalt(int tok, enum mdoc_type type, const struct mdoc_node *p) /* FALLTHROUGH */ case (MDOC_Bc): /* FALLTHROUGH */ + case (MDOC_Brc): + /* FALLTHROUGH */ case (MDOC_Dc): /* FALLTHROUGH */ case (MDOC_Ec): @@ -72,7 +72,8 @@ const char *const __mdoc_macronames[MDOC_MAX] = { "Fo", "Fc", "Oo", "Oc", "Bk", "Ek", "Bt", "Hf", "Fr", "Ud", "Lb", "Ap", - "Lp", "Lk", "Mt" + "Lp", "Lk", "Mt", "Brq", + "Bro", "Brc" }; const char *const __mdoc_argnames[MDOC_ARG_MAX] = { @@ -144,7 +144,10 @@ #define MDOC_Lp 108 #define MDOC_Lk 109 #define MDOC_Mt 110 -#define MDOC_MAX 111 +#define MDOC_Brq 111 +#define MDOC_Bro 112 +#define MDOC_Brc 113 +#define MDOC_MAX 114 /* What follows is a list of ALL possible macro arguments. */ @@ -171,6 +171,10 @@ Enclosures: .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It Em Output .Em Input (Name) +.It \(rC +\\(rC (right brace) +.It \(lC +\\(lC (left brace) .It \(ra \\(ra (right angle) .It \(la @@ -74,6 +74,8 @@ static struct termenc termenc1[] = { }; static struct termenc termenc2[] = { + { "rC", TERMSYM_RBRACE }, + { "lC", TERMSYM_LBRACE }, { "rB", TERMSYM_RBRACK }, { "lB", TERMSYM_LBRACK }, { "ra", TERMSYM_RANGLE }, @@ -163,6 +165,8 @@ static struct termsym termsym_ansi[] = { { "", 0 }, /* TERMSYM_BREAK */ { "<", 1 }, /* TERMSYM_LANGLE */ { ">", 1 }, /* TERMSYM_RANGLE */ + { "{", 1 }, /* TERMSYM_LBRACE */ + { "}", 1 }, /* TERMSYM_RBRACE */ }; static const char ansi_clear[] = { 27, '[', '0', 'm' }; @@ -118,6 +118,7 @@ DECL_PREPOST(termp__t); DECL_PREPOST(termp_aq); DECL_PREPOST(termp_bd); DECL_PREPOST(termp_bq); +DECL_PREPOST(termp_brq); DECL_PREPOST(termp_d1); DECL_PREPOST(termp_dq); DECL_PREPOST(termp_fd); @@ -287,6 +288,9 @@ const struct termact __termacts[MDOC_MAX] = { { termp_pp_pre, NULL }, /* Pp */ { termp_lk_pre, NULL }, /* Lk */ { termp_mt_pre, NULL }, /* Mt */ + { termp_brq_pre, termp_brq_post }, /* Brq */ + { termp_brq_pre, termp_brq_post }, /* Bro */ + { NULL, NULL }, /* Brc */ }; const struct termact *termacts = __termacts; @@ -1524,12 +1528,37 @@ termp_at_pre(DECL_ARGS) /* ARGSUSED */ static int +termp_brq_pre(DECL_ARGS) +{ + + if (MDOC_BODY != node->type) + return(1); + word(p, "\\(lC"); + p->flags |= TERMP_NOSPACE; + return(1); +} + + +/* ARGSUSED */ +static void +termp_brq_post(DECL_ARGS) +{ + + if (MDOC_BODY != node->type) + return; + p->flags |= TERMP_NOSPACE; + word(p, "\\(rC"); +} + + +/* ARGSUSED */ +static int termp_bq_pre(DECL_ARGS) { if (MDOC_BODY != node->type) return(1); - word(p, "["); + word(p, "\\(lB"); p->flags |= TERMP_NOSPACE; return(1); } @@ -1542,7 +1571,8 @@ termp_bq_post(DECL_ARGS) if (MDOC_BODY != node->type) return; - word(p, "]"); + p->flags |= TERMP_NOSPACE; + word(p, "\\(rB"); } @@ -1604,7 +1634,9 @@ termp_fo_post(DECL_ARGS) if (MDOC_BODY != node->type) return; + p->flags |= TERMP_NOSPACE; word(p, ")"); + p->flags |= TERMP_NOSPACE; word(p, ";"); newln(p); } @@ -64,7 +64,9 @@ enum tsym { TERMSYM_PERIOD = 35, TERMSYM_BREAK = 36, TERMSYM_LANGLE = 37, - TERMSYM_RANGLE = 38 + TERMSYM_RANGLE = 38, + TERMSYM_LBRACE = 39, + TERMSYM_RBRACE = 40 }; @@ -307,6 +307,9 @@ const struct valids mdoc_valids[MDOC_MAX] = { { NULL, posts_pp }, /* Pp */ { NULL, posts_lk }, /* Lk */ { NULL, posts_mt }, /* Mt */ + { NULL, posts_wline }, /* Brq */ + { NULL, NULL }, /* Bro */ + { NULL, NULL }, /* Brc */ }; |