summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chars.c33
-rw-r--r--chars.in63
2 files changed, 26 insertions, 70 deletions
diff --git a/chars.c b/chars.c
index 2b5f035b..66bfc5ec 100644
--- a/chars.c
+++ b/chars.c
@@ -36,20 +36,12 @@ struct ln {
const char *code;
const char *ascii;
int unicode;
- int type;
-#define CHARS_CHAR (1 << 0)
-#define CHARS_STRING (1 << 1)
-#define CHARS_BOTH (CHARS_CHAR | CHARS_STRING)
};
-#define LINES_MAX 353
+#define LINES_MAX 325
#define CHAR(in, ch, code) \
- { NULL, (in), (ch), (code), CHARS_CHAR },
-#define STRING(in, ch, code) \
- { NULL, (in), (ch), (code), CHARS_STRING },
-#define BOTH(in, ch, code) \
- { NULL, (in), (ch), (code), CHARS_BOTH },
+ { NULL, (in), (ch), (code) },
#define CHAR_TBL_START static struct ln lines[LINES_MAX] = {
#define CHAR_TBL_END };
@@ -60,9 +52,8 @@ struct mchars {
struct ln **htab;
};
-static inline int match(const struct ln *,
- const char *, size_t, int);
-static const struct ln *find(struct mchars *, const char *, size_t, int);
+static inline int match(const struct ln *, const char *, size_t);
+static const struct ln *find(struct mchars *, const char *, size_t);
void
mchars_free(struct mchars *arg)
@@ -116,7 +107,7 @@ mchars_spec2cp(struct mchars *arg, const char *p, size_t sz)
{
const struct ln *ln;
- ln = find(arg, p, sz, CHARS_CHAR);
+ ln = find(arg, p, sz);
if (NULL == ln)
return(-1);
return(ln->unicode);
@@ -131,7 +122,7 @@ mchars_res2cp(struct mchars *arg, const char *p, size_t sz)
{
const struct ln *ln;
- ln = find(arg, p, sz, CHARS_STRING);
+ ln = find(arg, p, sz);
if (NULL == ln)
return(-1);
return(ln->unicode);
@@ -177,7 +168,7 @@ mchars_spec2str(struct mchars *arg, const char *p, size_t sz, size_t *rsz)
{
const struct ln *ln;
- ln = find(arg, p, sz, CHARS_CHAR);
+ ln = find(arg, p, sz);
if (NULL == ln)
return(NULL);
@@ -193,7 +184,7 @@ mchars_res2str(struct mchars *arg, const char *p, size_t sz, size_t *rsz)
{
const struct ln *ln;
- ln = find(arg, p, sz, CHARS_STRING);
+ ln = find(arg, p, sz);
if (NULL == ln)
return(NULL);
@@ -202,7 +193,7 @@ mchars_res2str(struct mchars *arg, const char *p, size_t sz, size_t *rsz)
}
static const struct ln *
-find(struct mchars *tab, const char *p, size_t sz, int type)
+find(struct mchars *tab, const char *p, size_t sz)
{
struct ln *pp, *prev;
struct ln **htab;
@@ -228,7 +219,7 @@ find(struct mchars *tab, const char *p, size_t sz, int type)
return(NULL);
for (prev = NULL; pp; pp = pp->next) {
- if ( ! match(pp, p, sz, type)) {
+ if ( ! match(pp, p, sz)) {
prev = pp;
continue;
}
@@ -246,11 +237,9 @@ find(struct mchars *tab, const char *p, size_t sz, int type)
}
static inline int
-match(const struct ln *ln, const char *p, size_t sz, int type)
+match(const struct ln *ln, const char *p, size_t sz)
{
- if ( ! (ln->type & type))
- return(0);
if (strncmp(ln->code, p, sz))
return(0);
return('\0' == ln->code[(int)sz]);
diff --git a/chars.in b/chars.in
index 33ff760b..b59d3b07 100644
--- a/chars.in
+++ b/chars.in
@@ -16,15 +16,12 @@
*/
/*
- * The ASCII translation tables. STRING corresponds to predefined
- * strings (cf. mdoc_samples.7 and tmac/mdoc/doc-nroff). CHAR
- * corresponds to special characters (cf. groff_char.7). BOTH contains
- * sequences that are equivalent in both STRING and CHAR.
+ * The ASCII translation tables.
*
- * Either way, the left-hand side corresponds to the input sequence (\x,
- * \(xx, \*(xx and so on) whose length is listed second element. The
- * right-hand side is what's produced by the front-end, with the fourth
- * element being its length.
+ * The left-hand side corresponds to the input sequence (\x, \(xx, \*(xx
+ * and so on) whose length is listed second element. The right-hand
+ * side is what's produced by the front-end, with the fourth element
+ * being its length.
*
* XXX - C-escape strings!
* XXX - update LINES_MAX if adding more!
@@ -51,10 +48,10 @@ CHAR("a\"", "\"", 779)
CHAR("a-", "-", 175)
CHAR("a.", ".", 729)
CHAR("a^", "^", 770)
-BOTH("\'", "\'", 769)
-BOTH("aa", "\'", 769)
-BOTH("ga", "`", 768)
-BOTH("`", "`", 768)
+CHAR("\'", "\'", 769)
+CHAR("aa", "\'", 769)
+CHAR("ga", "`", 768)
+CHAR("`", "`", 768)
CHAR("ab", "`", 774)
CHAR("ac", ",", 807)
CHAR("ad", "\"", 776)
@@ -68,8 +65,8 @@ CHAR("ti", "~", 126)
/* Quotes. */
CHAR("Bq", ",,", 8222)
CHAR("bq", ",", 8218)
-BOTH("lq", "``", 8220)
-BOTH("rq", "\'\'", 8221)
+CHAR("lq", "``", 8220)
+CHAR("rq", "\'\'", 8221)
CHAR("oq", "`", 8216)
CHAR("cq", "\'", 8217)
CHAR("aq", "\'", 39)
@@ -232,8 +229,8 @@ CHAR("<-", "<-", 8592)
CHAR("->", "->", 8594)
CHAR("<>", "<>", 8596)
CHAR("da", "v", 8595)
-BOTH("ua", "^", 8593)
-BOTH("va", "^v", 8597)
+CHAR("ua", "^", 8593)
+CHAR("va", "^v", 8597)
CHAR("lA", "<=", 8656)
CHAR("rA", "=>", 8658)
CHAR("hA", "<=>", 8660)
@@ -270,8 +267,8 @@ CHAR("di", "-:-", 247)
CHAR("tdi", "-:-", 247)
CHAR("f/", "/", 8260)
CHAR("**", "*", 8727)
-BOTH("<=", "<=", 8804)
-BOTH(">=", ">=", 8805)
+CHAR("<=", "<=", 8804)
+CHAR(">=", ">=", 8805)
CHAR("<<", "<<", 8810)
CHAR(">>", ">>", 8811)
CHAR("eq", "=", 61)
@@ -348,36 +345,6 @@ CHAR("Po", "L", 163)
CHAR("Cs", "x", 164)
CHAR("Fn", "f", 402)
-/* Old style. */
-STRING("Am", "&", 38)
-STRING("Ba", "|", 124)
-STRING("Ge", ">=", 8805)
-STRING("Gt", ">", 62)
-STRING("If", "infinity", 0)
-STRING("Le", "<=", 8804)
-STRING("Lq", "``", 8220)
-STRING("Lt", "<", 60)
-STRING("Na", "NaN", 0)
-STRING("Ne", "!=", 8800)
-STRING("Pi", "pi", 960)
-STRING("Pm", "+-", 177)
-STRING("Rq", "\'\'", 8221)
-STRING("left-bracket", "[", 91)
-STRING("left-parenthesis", "(", 40)
-STRING("left-singlequote", "`", 8216)
-STRING("lp", "(", 40)
-STRING("q", "\"", 34)
-STRING("quote-left", "`", 8216)
-STRING("quote-right", "\'", 8217)
-STRING("R", "(R)", 174)
-STRING("right-bracket", "]", 93)
-STRING("right-parenthesis", ")", 41)
-STRING("right-singlequote", "\'", 8217)
-STRING("rp", ")", 41)
-STRING("Tm", "(Tm)", 8482)
-STRING("Px", "POSIX", 0)
-STRING("Ai", "ANSI", 0)
-
/* Lines. */
CHAR("ba", "|", 124)
CHAR("br", "|", 9474)