MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / wildcmp

Function wildcmp

tests/framework/src/doctest.cpp:1023–1057  ·  view source on GitHub ↗

matching of a string against a wildcard mask (case sensitivity configurable) taken from https://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing

Source from the content-addressed store, hash-verified

1021 // matching of a string against a wildcard mask (case sensitivity configurable) taken from
1022 // https://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing
1023 int wildcmp(const char* str, const char* wild, bool caseSensitive) {
1024 const char* cp = str;
1025 const char* mp = wild;
1026
1027 while((*str) && (*wild != '*')) {
1028 if((caseSensitive ? (*wild != *str) : (tolower(*wild) != tolower(*str))) &&
1029 (*wild != '?')) {
1030 return 0;
1031 }
1032 wild++;
1033 str++;
1034 }
1035
1036 while(*str) {
1037 if(*wild == '*') {
1038 if(!*++wild) {
1039 return 1;
1040 }
1041 mp = wild;
1042 cp = str + 1;
1043 } else if((caseSensitive ? (*wild == *str) : (tolower(*wild) == tolower(*str))) ||
1044 (*wild == '?')) {
1045 wild++;
1046 str++;
1047 } else {
1048 wild = mp; //!OCLINT parameter reassignment
1049 str = cp++; //!OCLINT parameter reassignment
1050 }
1051 }
1052
1053 while(*wild == '*') {
1054 wild++;
1055 }
1056 return !*wild;
1057 }
1058
1059 // checks if the name matches any of the filters (and can be configured what to do when empty)
1060 bool matchesAny(const char* name, const std::vector<String>& filters, bool matchEmpty,

Callers 1

matchesAnyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected