-/* $Id: chars.c,v 1.44 2011/05/17 11:50:20 kristaps Exp $ */
+/* $Id: chars.c,v 1.46 2011/05/24 21:31:23 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
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 };
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)
{
const struct ln *ln;
- ln = find(arg, p, sz, CHARS_CHAR);
- if (NULL == ln)
- return(-1);
- return(ln->unicode);
-}
-
-
-/*
- * Reserved word to Unicode codepoint.
- */
-int
-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);
{
const struct ln *ln;
- ln = find(arg, p, sz, CHARS_CHAR);
- if (NULL == ln)
- return(NULL);
-
- *rsz = strlen(ln->ascii);
- return(ln->ascii);
-}
-
-/*
- * Reserved word to string array.
- */
-const char *
-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);
}
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;
return(NULL);
for (prev = NULL; pp; pp = pp->next) {
- if ( ! match(pp, p, sz, type)) {
+ if ( ! match(pp, p, sz)) {
prev = pp;
continue;
}
}
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]);