MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / wildcmp

Method wildcmp

astyle/src/astyle_main.cpp:2356–2412  ·  view source on GitHub ↗

From The Code Project http://www.codeproject.com/string/wildcmp.asp Written by Jack Handy - jakkhandy@hotmail.com Modified to compare case insensitive for Windows

Source from the content-addressed store, hash-verified

2354// Written by Jack Handy - jakkhandy@hotmail.com
2355// Modified to compare case insensitive for Windows
2356int ASConsole::wildcmp(const char* wild, const char* data) const
2357{
2358 const char* cp = NULL, *mp = NULL;
2359 bool cmpval;
2360
2361 while ((*data) && (*wild != '*'))
2362 {
2363 if (!g_isCaseSensitive)
2364 cmpval = (tolower(*wild) != tolower(*data)) && (*wild != '?');
2365 else
2366 cmpval = (*wild != *data) && (*wild != '?');
2367
2368 if (cmpval)
2369 {
2370 return 0;
2371 }
2372 wild++;
2373 data++;
2374 }
2375
2376 while (*data)
2377 {
2378 if (*wild == '*')
2379 {
2380 if (!*++wild)
2381 {
2382 return 1;
2383 }
2384 mp = wild;
2385 cp = data + 1;
2386 }
2387 else
2388 {
2389 if (!g_isCaseSensitive)
2390 cmpval = (tolower(*wild) == tolower(*data) || (*wild == '?'));
2391 else
2392 cmpval = (*wild == *data) || (*wild == '?');
2393
2394 if (cmpval)
2395 {
2396 wild++;
2397 data++;
2398 }
2399 else
2400 {
2401 wild = mp;
2402 data = cp++;
2403 }
2404 }
2405 }
2406
2407 while (*wild == '*')
2408 {
2409 wild++;
2410 }
2411 return !*wild;
2412}
2413

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected