aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/chars.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-05-24 21:24:16 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-05-24 21:24:16 +0000
commitc96b6e579c812eed08e99af59d7134e91eb8bfbf (patch)
tree9b3ddbe424a34533388c43d0c1864f4476fadb9a /chars.c
parentb73dbb2f124e747e7c3c066cf61fef62a2ac0913 (diff)
downloadmandoc-c96b6e579c812eed08e99af59d7134e91eb8bfbf.tar.gz
mandoc-c96b6e579c812eed08e99af59d7134e91eb8bfbf.tar.zst
mandoc-c96b6e579c812eed08e99af59d7134e91eb8bfbf.zip
Remove predefined strings from the chars.in file, as they're now local
to predefs.in. This also makes "BOTH" entries directly into CHAR. The res2str and spec2str are now effectively the same function.
Diffstat (limited to 'chars.c')
-rw-r--r--chars.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/chars.c b/chars.c
index 808d70d7..b32c5bba 100644
--- a/chars.c
+++ b/chars.c
@@ -1,4 +1,4 @@
-/* $Id: chars.c,v 1.44 2011/05/17 11:50:20 kristaps Exp $ */
+/* $Id: chars.c,v 1.45 2011/05/24 21:24:16 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -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]);