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

Function str2align

src/role.c:942–967  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940}
941
942int
943str2align(const char *str)
944{
945 int i, len;
946
947 /* Is str valid? */
948 if (!str || !str[0])
949 return ROLE_NONE;
950
951 /* Match as much of str as is provided */
952 len = Strlen(str);
953 for (i = 0; i < ROLE_ALIGNS; i++) {
954 /* Does it match the adjective? */
955 if (!strncmpi(str, aligns[i].adj, len))
956 return i;
957 /* Or the filecode? */
958 if (!strcmpi(str, aligns[i].filecode))
959 return i;
960 }
961 if ((len == 1 && (*str == '*' || *str == '@'))
962 || !strncmpi(str, randomstr, len))
963 return ROLE_RANDOM;
964
965 /* Couldn't find anything appropriate */
966 return ROLE_NONE;
967}
968
969/* is rolenum compatible with any racenum/gendnum/alignnum constraints? */
970boolean

Callers 5

early_optionsFunction · 0.85
process_optionsFunction · 0.85
optfn_alignmentFunction · 0.85
setrolefilterFunction · 0.85
plnamesuffixFunction · 0.85

Calls 1

strncmpiFunction · 0.70

Tested by

no test coverage detected