summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/pattern.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2012-06-23 18:45:30 +0200
committerAdam Borowski <kilobyte@angband.pl>2012-06-23 20:57:56 +0200
commite8b8168dad2b5040b77641770177ef77d65bf16d (patch)
treed5f51eecfe0a18c478997ce6705e9ab49b048e79 /crawl-ref/source/pattern.cc
parentceaff5dee3286c9a53c3fa39f3e10e4c00a0f03b (diff)
downloadcrawl-ref-e8b8168dad2b5040b77641770177ef77d65bf16d.tar.gz
crawl-ref-e8b8168dad2b5040b77641770177ef77d65bf16d.zip
Drop unused plain glob support.
Since a long time ago, platforms with no POSIX regexes available will instead build contrib PCRE. Other contribs are always needed as well, so there's no gain here. And I guess we rely on patterns being regular expressions internally, too.
Diffstat (limited to 'crawl-ref/source/pattern.cc')
-rw-r--r--crawl-ref/source/pattern.cc98
1 files changed, 1 insertions, 97 deletions
diff --git a/crawl-ref/source/pattern.cc b/crawl-ref/source/pattern.cc
index 46c92dec7d..af4297da48 100644
--- a/crawl-ref/source/pattern.cc
+++ b/crawl-ref/source/pattern.cc
@@ -2,85 +2,6 @@
#include "pattern.h"
-///////////////////////////////////////////////////////////////////////
-// Pattern matching
-
-inline int pm_lower(int ch, bool icase)
-{
- return icase? tolower(ch) : ch;
-}
-
-// Determines whether the pattern specified by 'pattern' matches the given
-// text. A pattern is a simple glob, with the traditional * and ? wildcards.
-static bool glob_match(const char *pattern, const char *text, bool icase)
-{
- char p, t;
- bool special;
-
- while (true)
- {
- p = pm_lower(*pattern++, icase);
- t = pm_lower(*text++, icase);
- special = true;
-
- if (!p)
- return (t == 0);
-
- if (p == '\\' && *pattern)
- {
- p = pm_lower(*pattern++, icase);
- special = false;
- }
-
- if (p == '*' && special)
- {
- // Try to match exactly at the current text position...
- if (!*pattern || glob_match(pattern, text - 1, icase))
- return (true);
-
- // Or skip one character in the text and try the wildcard match
- // again. If this is the end of the text, the match has failed.
- return (t ? glob_match(pattern - 1, text, icase) : false);
- }
- else if (!t || p != t && (p != '?' || !special))
- return (false);
- }
-}
-
-////////////////////////////////////////////////////////////////////
-// Basic glob (always available)
-
-struct glob_info
-{
- std::string s;
- bool ignore_case;
-};
-
-void *compile_glob_pattern(const char *pattern, bool icase)
-{
- // If we're using simple globs, we need to box the pattern with '*'
- std::string s = std::string("*") + pattern + "*";
- glob_info *gi = new glob_info;
- if (gi)
- {
- gi->s = s;
- gi->ignore_case = icase;
- }
- return gi;
-}
-
-void free_compiled_glob_pattern(void *compiled_pattern)
-{
- delete static_cast<glob_info *>(compiled_pattern);
-}
-
-bool glob_pattern_match(void *compiled_pattern, const char *text, int length)
-{
- glob_info *gi = static_cast<glob_info *>(compiled_pattern);
- return glob_match(gi->s.c_str(), text, gi->ignore_case);
-}
-////////////////////////////////////////////////////////////////////
-
#if defined(REGEX_PCRE)
////////////////////////////////////////////////////////////////////
// Perl Compatible Regular Expressions
@@ -114,7 +35,7 @@ bool pattern_match(void *compiled_pattern, const char *text, int length)
}
////////////////////////////////////////////////////////////////////
-#elif defined(REGEX_POSIX)
+#else
////////////////////////////////////////////////////////////////////
// POSIX regular expressions
@@ -154,21 +75,4 @@ bool pattern_match(void *compiled_pattern, const char *text, int length)
}
////////////////////////////////////////////////////////////////////
-#else
-
-void *compile_pattern(const char *pattern, bool icase)
-{
- return compile_glob_pattern(pattern, icase);
-}
-
-void free_compiled_pattern(void *cp)
-{
- free_compiled_glob_pattern(cp);
-}
-
-bool pattern_match(void *compiled_pattern, const char *text, int length)
-{
- return glob_pattern_match(compiled_pattern, text, length);
-}
-
#endif