MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / match_multi

Function match_multi

src/common/OSFile.cpp:592–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590// we don't need these for windows as it can do it right in findNextFile
591#ifndef _WIN32
592static int match_multi(const char** mask, const char** string) {
593 const char* msk;
594 const char* str;
595 const char* msktop;
596 const char* strtop;
597
598 msk = *mask;
599 str = *string;
600
601 while ((*msk != '\0') && (*msk == '*')) {
602 msk++; /* get rid of multiple '*'s */
603 }
604
605 if (*msk == '\0') { /* '*' was last, auto-match */
606 return +1;
607 }
608
609 msktop = msk;
610 strtop = str;
611
612 while (*msk != '\0') {
613 if (*msk == '*') {
614 *mask = msk;
615 *string = str;
616 return 0; /* matched this segment */
617 }
618 else if (*str == '\0') {
619 return -1; /* can't match */
620 }
621 else {
622 if ((*msk == '?') || (*msk == *str)) {
623 msk++;
624 str++;
625 if ((*msk == '\0') && (*str != '\0')) { /* advanced check */
626 str++;
627 strtop++;
628 str = strtop;
629 msk = msktop;
630 }
631 }
632 else {
633 str++;
634 strtop++;
635 str = strtop;
636 msk = msktop;
637 }
638 }
639 }
640
641 *mask = msk;
642 *string = str;
643 return +1; /* full match */
644}
645
646static int match_mask(const char* mask, const char* string) {
647 if (mask == NULL) {

Callers 1

match_maskFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected