3 This file is part of libmspstrings
4 Copyright © 2007 Mikko Rasa
5 Distributed under the LGPL
14 bool cmp(char c, char h);
17 bool cmp<true>(char c, char h)
18 { return tolower(c)==tolower(h); }
21 bool cmp<false>(char c, char h)
25 bool globmatch(string::const_iterator pat_i, const string::const_iterator &pat_e, string::const_iterator str_i, const string::const_iterator &str_e)
27 while(pat_i!=pat_e && str_i!=str_e)
29 if(*pat_i=='?' || cmp<icase>(*str_i, *pat_i))
40 for(; str_i!=str_e; ++str_i)
41 if(cmp<icase>(*str_i, *pat_i) && globmatch<icase>(pat_i, pat_e, str_i, str_e))
50 return pat_i==pat_e && str_i==str_e;
57 bool globmatch(const string &pat, const string &str)
59 return ::globmatch<false>(pat.begin(), pat.end(), str.begin(), str.end());
62 bool globcasematch(const string &pat, const string &str)
64 return ::globmatch<true>(pat.begin(), pat.end(), str.begin(), str.end());