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

Function match_multi

plugins/plugin_utils/plugin_files.cpp:110–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109#define _DirDelim '/'
110static int match_multi(const char** mask, const char** string) {
111 const char* msk;
112 const char* str;
113 const char* msktop;
114 const char* strtop;
115
116 msk = *mask;
117 str = *string;
118
119 while ((*msk != '\0') && (*msk == '*')) {
120 msk++; /* get rid of multiple '*'s */
121 }
122
123 if (*msk == '\0') { /* '*' was last, auto-match */
124 return +1;
125 }
126
127 msktop = msk;
128 strtop = str;
129
130 while (*msk != '\0') {
131 if (*msk == '*') {
132 *mask = msk;
133 *string = str;
134 return 0; /* matched this segment */
135 }
136 else if (*str == '\0') {
137 return -1; /* can't match */
138 }
139 else {
140 if ((*msk == '?') || (*msk == *str)) {
141 msk++;
142 str++;
143 if ((*msk == '\0') && (*str != '\0')) { /* advanced check */
144 str++;
145 strtop++;
146 str = strtop;
147 msk = msktop;
148 }
149 }
150 else {
151 str++;
152 strtop++;
153 str = strtop;
154 msk = msktop;
155 }
156 }
157 }
158
159 *mask = msk;
160 *string = str;
161 return +1; /* full match */
162}
163
164static int match_mask(const char* mask, const char* string) {
165 if (mask == NULL) {

Callers 1

match_maskFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected