aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/chars.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-17 09:21:39 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-17 09:21:39 +0000
commita5c49f24b16e6351ce3bc6e801ec3c0fed98839a (patch)
tree84072be36468fd3cdd67b3600cbf41e34c288087 /chars.c
parent3e23d66c0abbb35f937f3969d2a6a54cb8827037 (diff)
downloadmandoc-a5c49f24b16e6351ce3bc6e801ec3c0fed98839a.tar.gz
mandoc-a5c49f24b16e6351ce3bc6e801ec3c0fed98839a.tar.zst
mandoc-a5c49f24b16e6351ce3bc6e801ec3c0fed98839a.zip
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.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/chars.c b/chars.c
index 72754ca9..b0fcc165 100644
--- a/chars.c
+++ b/chars.c
@@ -1,4 +1,4 @@
-/* $Id: chars.c,v 1.21 2010/07/16 22:33:30 kristaps Exp $ */
+/* $Id: chars.c,v 1.22 2010/07/17 09:21:39 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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]);
}