summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-11 00:39:58 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-11 00:39:58 +0000
commitb245e76978c72e7237d90485531acee7d3caa4fc (patch)
treefdf44540f6b1904b7f26b0b008bceccff7ab2be5
parent3a26b8088d5978b9e623c51df0dcaf7206eae3e4 (diff)
downloadmandoc-b245e76978c72e7237d90485531acee7d3caa4fc.tar.gz
Expanded perfect htab to use 27 * 26 * 3 space.
Added Brq, Bro and Brc macros. Added lbrace and rbrace to special characters. Fixed spacing in braces.
-rw-r--r--action.c3
-rw-r--r--argv.c3
-rw-r--r--hash.c63
-rw-r--r--macro.c11
-rw-r--r--mdoc.c3
-rw-r--r--mdoc.h5
-rw-r--r--mdocterm.14
-rw-r--r--mdocterm.c4
-rw-r--r--term.c36
-rw-r--r--term.h4
-rw-r--r--validate.c3
11 files changed, 119 insertions, 20 deletions
diff --git a/action.c b/action.c
index 06ff1e34..6fb82841 100644
--- a/action.c
+++ b/action.c
@@ -174,6 +174,9 @@ const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL }, /* Lp */
{ NULL }, /* Lk */
{ NULL }, /* Mt */
+ { NULL }, /* Brq */
+ { NULL }, /* Bro */
+ { NULL }, /* Brc */
};
diff --git a/argv.c b/argv.c
index fd2a99e5..b30cf028 100644
--- a/argv.c
+++ b/argv.c
@@ -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 */
};
diff --git a/hash.c b/hash.c
index ce0abe91..2e5e9fc6 100644
--- a/hash.c
+++ b/hash.c
@@ -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);
}
diff --git a/macro.c b/macro.c
index 378dcef8..4e296c3c 100644
--- a/macro.c
+++ b/macro.c
@@ -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):
diff --git a/mdoc.c b/mdoc.c
index 67ac71cf..364f0bf4 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -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] = {
diff --git a/mdoc.h b/mdoc.h
index b23eeed3..42a55e07 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -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. */
diff --git a/mdocterm.1 b/mdocterm.1
index e591fa60..95cd3bf7 100644
--- a/mdocterm.1
+++ b/mdocterm.1
@@ -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
diff --git a/mdocterm.c b/mdocterm.c
index 9acb566e..fb4b31de 100644
--- a/mdocterm.c
+++ b/mdocterm.c
@@ -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' };
diff --git a/term.c b/term.c
index a3122948..47f8f924 100644
--- a/term.c
+++ b/term.c
@@ -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);
}
diff --git a/term.h b/term.h
index 64291b76..05b57a7d 100644
--- a/term.h
+++ b/term.h
@@ -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
};
diff --git a/validate.c b/validate.c
index ae6b86ea..595b1edd 100644
--- a/validate.c
+++ b/validate.c
@@ -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 */
};