| 77 | |
| 78 | |
| 79 | bool match(const wchar *pattern,const wchar *string,bool ForceCase) |
| 80 | { |
| 81 | for (;; ++string) |
| 82 | { |
| 83 | wchar stringc=touppercw(*string,ForceCase); |
| 84 | wchar patternc=touppercw(*pattern++,ForceCase); |
| 85 | switch (patternc) |
| 86 | { |
| 87 | case 0: |
| 88 | return(stringc==0); |
| 89 | case '?': |
| 90 | if (stringc == 0) |
| 91 | return(false); |
| 92 | break; |
| 93 | case '*': |
| 94 | if (*pattern==0) |
| 95 | return(true); |
| 96 | if (*pattern=='.') |
| 97 | { |
| 98 | if (pattern[1]=='*' && pattern[2]==0) |
| 99 | return(true); |
| 100 | const wchar *dot=wcschr(string,'.'); |
| 101 | if (pattern[1]==0) |
| 102 | return (dot==NULL || dot[1]==0); |
| 103 | if (dot!=NULL) |
| 104 | { |
| 105 | string=dot; |
| 106 | if (wcspbrk(pattern,L"*?")==NULL && wcschr(string+1,'.')==NULL) |
| 107 | return(mwcsicompc(pattern+1,string+1,ForceCase)==0); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | while (*string) |
| 112 | if (match(pattern,string++,ForceCase)) |
| 113 | return(true); |
| 114 | return(false); |
| 115 | default: |
| 116 | if (patternc != stringc) |
| 117 | { |
| 118 | // Allow "name." mask match "name" and "name.\" match "name\". |
| 119 | if (patternc=='.' && (stringc==0 || stringc=='\\' || stringc=='.')) |
| 120 | return(match(pattern,string,ForceCase)); |
| 121 | else |
| 122 | return(false); |
| 123 | } |
| 124 | break; |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | |
| 130 | int mwcsicompc(const wchar *Str1,const wchar *Str2,bool ForceCase) |
no test coverage detected