| 908 | |
| 909 | |
| 910 | bool WildCompareString( const wxString& pattern, const wxString& string_to_tst, |
| 911 | bool case_sensitive ) |
| 912 | { |
| 913 | const wxChar* cp = nullptr; |
| 914 | const wxChar* mp = nullptr; |
| 915 | const wxChar* wild = nullptr; |
| 916 | const wxChar* str = nullptr; |
| 917 | wxString _pattern, _string_to_tst; |
| 918 | |
| 919 | if( case_sensitive ) |
| 920 | { |
| 921 | wild = pattern.GetData(); |
| 922 | str = string_to_tst.GetData(); |
| 923 | } |
| 924 | else |
| 925 | { |
| 926 | _pattern = pattern; |
| 927 | _pattern.MakeUpper(); |
| 928 | _string_to_tst = string_to_tst; |
| 929 | _string_to_tst.MakeUpper(); |
| 930 | wild = _pattern.GetData(); |
| 931 | str = _string_to_tst.GetData(); |
| 932 | } |
| 933 | |
| 934 | while( ( *str ) && ( *wild != '*' ) ) |
| 935 | { |
| 936 | if( ( *wild != *str ) && ( *wild != '?' ) ) |
| 937 | return false; |
| 938 | |
| 939 | wild++; |
| 940 | str++; |
| 941 | } |
| 942 | |
| 943 | while( *str ) |
| 944 | { |
| 945 | if( *wild == '*' ) |
| 946 | { |
| 947 | if( !*++wild ) |
| 948 | return true; |
| 949 | |
| 950 | mp = wild; |
| 951 | cp = str + 1; |
| 952 | } |
| 953 | else if( ( *wild == *str ) || ( *wild == '?' ) ) |
| 954 | { |
| 955 | wild++; |
| 956 | str++; |
| 957 | } |
| 958 | else |
| 959 | { |
| 960 | wild = mp; |
| 961 | str = cp++; |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | while( *wild == '*' ) |
| 966 | { |
| 967 | wild++; |
no test coverage detected