diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-07-17 09:21:39 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-07-17 09:21:39 +0000 |
commit | 783d095f30c97a02fda548fcfc9bddc37fda9a36 (patch) | |
tree | 1803b74c6a06371b409ebb7d85e92e54ec8ac40b /chars.c | |
parent | 0b50b90cf4efcd1646b2517a4777605ab2e844df (diff) | |
download | mandoc-783d095f30c97a02fda548fcfc9bddc37fda9a36.tar.gz |
By letting strncmp() do its job and not helping it with a prior length
check, we can remove the hard-coded length of all escape patterns. This
frees up a nice chunk of memory.
Diffstat (limited to 'chars.c')
-rw-r--r-- | chars.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -32,7 +32,6 @@ struct ln { struct ln *next; const char *code; - size_t codesz; const char *ascii; size_t asciisz; int unicode; @@ -44,12 +43,12 @@ struct ln { #define LINES_MAX 370 -#define CHAR(in, insz, ch, chsz, code) \ - { NULL, (in), (insz), (ch), (chsz), (code), CHARS_CHAR }, -#define STRING(in, insz, ch, chsz, code) \ - { NULL, (in), (insz), (ch), (chsz), (code), CHARS_STRING }, -#define BOTH(in, insz, ch, chsz, code) \ - { NULL, (in), (insz), (ch), (chsz), (code), CHARS_BOTH }, +#define CHAR(in, ch, chsz, code) \ + { NULL, (in), (ch), (chsz), (code), CHARS_CHAR }, +#define STRING(in, ch, chsz, code) \ + { NULL, (in), (ch), (chsz), (code), CHARS_STRING }, +#define BOTH(in, ch, chsz, code) \ + { NULL, (in), (ch), (chsz), (code), CHARS_BOTH }, #define CHAR_TBL_START static struct ln lines[LINES_MAX] = { #define CHAR_TBL_END }; @@ -238,7 +237,7 @@ match(const struct ln *ln, const char *p, size_t sz, int type) if ( ! (ln->type & type)) return(0); - if (ln->codesz != sz) + if (strncmp(ln->code, p, sz)) return(0); - return(0 == strncmp(ln->code, p, sz)); + return('\0' == ln->code[(int)sz]); } |