///////////////////////////////////////////////////////////////// // wildcards.cpp - find strings that match, using wild cards // // ver 1.1 // // // // Language: Visual C++, ver 6.0 // // Platform: Micron Dual Pentium 200, Windows NT 4.0 // // Application: CSE687 Project #1, S98 // // Author: Jim Fawcett, CST 2-187, (315) 443-3948 // // fawcett@ecs.syr.edu // ///////////////////////////////////////////////////////////////// #include #include #include "wildcards.h" using namespace std; //----< does name match pattern >------------------------------ // // assumes that pat may have wildcards but s does not // bool wildcards::matches(const string &s) { int i=0, j=0; while(i-------------------------------------------- #ifdef TEST_WILDCARDS void main() { cout << "\n Testing Wildcard Matching " << "\n ===========================\n"; string s[5] = { "*.bar", "foo.*", "f*.bar", "f?o.bar", "foo.bar" }; string t[3] = { "foo.bar", "fee.bar", "foo.bor" }; int i, j; for(i=0; i<5; i++) { cout << '\n'; wildcards wc(s[i]); for(j=0; j<3; j++) if(wc.matches(t[j])) cout << " \"" << s[i] << "\" matches \"" << t[j] << "\"" << endl; else cout << " \"" << s[i] << "\" does not match \"" << t[j] << "\"" << endl; } cout << "\n\n"; } #endif