MCPcopy Create free account
hub / github.com/NetHack/NetHack / match_str2conditionbitmask

Function match_str2conditionbitmask

src/botl.c:3170–3206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3168}
3169
3170staticfn unsigned long
3171match_str2conditionbitmask(const char *str)
3172{
3173 int i, nmatches = 0;
3174 unsigned long mask = 0UL;
3175
3176 if (str && *str) {
3177 /* check matches to canonical names */
3178 for (i = 0; i < SIZE(conditions); i++)
3179 if (fuzzymatch(conditions[i].text[0], str, " -_", TRUE)) {
3180 mask |= conditions[i].mask;
3181 nmatches++;
3182 }
3183
3184 if (!nmatches) {
3185 /* check aliases */
3186 for (i = 0; i < SIZE(condition_aliases); i++)
3187 if (fuzzymatch(condition_aliases[i].id, str, " -_", TRUE)) {
3188 mask |= condition_aliases[i].bitmask;
3189 nmatches++;
3190 }
3191 }
3192
3193 if (!nmatches) {
3194 /* check partial matches to aliases */
3195 int len = (int) strlen(str);
3196
3197 for (i = 0; i < SIZE(condition_aliases); i++)
3198 if (!strncmpi(str, condition_aliases[i].id, len)) {
3199 mask |= condition_aliases[i].bitmask;
3200 nmatches++;
3201 }
3202 }
3203 }
3204
3205 return mask;
3206}
3207
3208staticfn unsigned long
3209str2conditionbitmask(char *str)

Callers 1

str2conditionbitmaskFunction · 0.85

Calls 2

fuzzymatchFunction · 0.85
strncmpiFunction · 0.70

Tested by

no test coverage detected