MCPcopy Index your code
hub / github.com/NetHack/NetHack / badman

Function badman

src/objnam.c:3193–3239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3191}
3192
3193staticfn boolean
3194badman(
3195 const char *basestr,
3196 boolean to_plural) /* True: makeplural, False: makesingular */
3197{
3198 /* these are all the prefixes for *man that don't have a *men plural */
3199 static const char *const no_men[] = {
3200 "albu", "antihu", "anti", "ata", "auto", "bildungsro", "cai", "cay",
3201 "ceru", "corner", "decu", "des", "dura", "fir", "hanu", "het",
3202 "infrahu", "inhu", "nonhu", "otto", "out", "prehu", "protohu",
3203 "subhu", "superhu", "talis", "unhu", "sha",
3204 "hu", "un", "le", "re", "so", "to", "at", "a",
3205 };
3206 /* these are all the prefixes for *men that don't have a *man singular */
3207 static const char *const no_man[] = {
3208 "abdo", "acu", "agno", "ceru", "cogno", "cycla", "fleh", "grava",
3209 "hegu", "preno", "sonar", "speci", "dai", "exa", "fla", "sta", "teg",
3210 "tegu", "vela", "da", "hy", "lu", "no", "nu", "ra", "ru", "se", "vi",
3211 "ya", "o", "a",
3212 };
3213 int i, al;
3214 const char *endstr, *spot;
3215
3216 if (!basestr || strlen(basestr) < 4)
3217 return FALSE;
3218
3219 endstr = eos((char *) basestr);
3220
3221 if (to_plural) {
3222 for (i = 0; i < SIZE(no_men); i++) {
3223 al = (int) strlen(no_men[i]);
3224 spot = endstr - (al + 3);
3225 if (!BSTRNCMPI(basestr, spot, no_men[i], al)
3226 && (spot == basestr || *(spot - 1) == ' '))
3227 return TRUE;
3228 }
3229 } else {
3230 for (i = 0; i < SIZE(no_man); i++) {
3231 al = (int) strlen(no_man[i]);
3232 spot = endstr - (al + 3);
3233 if (!BSTRNCMPI(basestr, spot, no_man[i], al)
3234 && (spot == basestr || *(spot - 1) == ' '))
3235 return TRUE;
3236 }
3237 }
3238 return FALSE;
3239}
3240
3241/* compare user string against object name string using fuzzy matching */
3242staticfn boolean

Callers 3

singplur_lookupFunction · 0.85
makepluralFunction · 0.85
makesingularFunction · 0.85

Calls 1

eosFunction · 0.85

Tested by

no test coverage detected