From d1bc31f47387eda79db87e7db958ea5ed50eaee4 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 4 Dec 2010 18:35:13 +0000 Subject: Make sure we elide trailing non-characters when matching aliases svn path=/trunk/libparserutils/; revision=10973 --- src/charset/aliases.c | 4 ++++ test/aliases.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/charset/aliases.c b/src/charset/aliases.c index 5c173d0..81962eb 100644 --- a/src/charset/aliases.c +++ b/src/charset/aliases.c @@ -62,6 +62,10 @@ static int parserutils_charset_alias_match(const void *a, const void *b) s_alias++; } + while ((key_left > 0) && IS_PUNCT_OR_SPACE(*s_key)) { + key_left--; s_key++; + } + return key_left - alias_left; } diff --git a/test/aliases.c b/test/aliases.c index 9a9f962..819e4b5 100644 --- a/test/aliases.c +++ b/test/aliases.c @@ -28,6 +28,14 @@ int main (int argc, char **argv) return 1; } + c = parserutils_charset_alias_canonicalise("csinvariant\"", 12); + if (c) { + printf("%s %d\n", c->name, c->mib_enum); + } else { + printf("FAIL - failed finding encoding 'csinvariant'\n"); + return 1; + } + c = parserutils_charset_alias_canonicalise("nats-sefi-add", 13); if (c) { printf("%s %d\n", c->name, c->mib_enum); -- cgit v1.2.3