From 2f1fb732d4be844fb68829bdc1c8c103f8b2df60 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 5 Sep 2009 10:25:42 -0700 Subject: [PATCH] Improve error handling and get rid of a lingering fprintf(). --- token.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/token.c b/token.c index b3621b93..838f8c97 100644 --- a/token.c +++ b/token.c @@ -45,12 +45,12 @@ static void add_suffix(struct suffix_tree **prior, char ltr, const char *str) if (ltr == '[') { const char *after = strchr(str, ']'); - /* Just skip bogus character classes. */ - if (!after++) + /* Treat "[foo" and "[]" as having a literal '['. */ + if (after && after++ != str+1) { + while ((ltr = *str++) != ']') + add_suffix(prior, ltr, after); return; - while ((ltr = *str++) != ']') - add_suffix(prior, ltr, after); - return; + } } for (node = *prior; node; prior = &node->sibling, node = node->sibling) { @@ -100,7 +100,6 @@ static void add_nocompress_suffixes(const char *str) } while (*++f != '/' && *f); *t++ = '\0'; - fprintf(stderr, "adding `%s'\n", buf); add_suffix(&suftree, *buf, buf+1); } -- 2.34.1