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

Function fuzzymatch

src/hacklib.c:784–808  ·  view source on GitHub ↗

compare two strings for equality, ignoring the presence of specified characters (typically whitespace) and possibly ignoring case */

Source from the content-addressed store, hash-verified

782/* compare two strings for equality, ignoring the presence of specified
783 characters (typically whitespace) and possibly ignoring case */
784boolean
785fuzzymatch(
786 const char *s1, const char *s2,
787 const char *ignore_chars,
788 boolean caseblind)
789{
790 char c1, c2;
791
792 do {
793 while ((c1 = *s1++) != '\0' && strchr(ignore_chars, c1) != 0)
794 continue;
795 while ((c2 = *s2++) != '\0' && strchr(ignore_chars, c2) != 0)
796 continue;
797 if (!c1 || !c2)
798 break; /* stop when end of either string is reached */
799
800 if (caseblind) {
801 c1 = lowc(c1);
802 c2 = lowc(c2);
803 }
804 } while (c1 == c2);
805
806 /* match occurs only when the end of both strings has been reached */
807 return (boolean) (!c1 && !c2);
808}
809
810/*
811 * Time routines

Callers 12

optfn_autounlockFunction · 0.85
match_str2clrFunction · 0.85
match_str2attrFunction · 0.85
check_enhanced_colorsFunction · 0.85
alreadynamedFunction · 0.85
wishymatchFunction · 0.85
artifact_nameFunction · 0.85
read_sym_fileFunction · 0.85
fldname_to_bl_indxFunction · 0.85
noneoftheaboveFunction · 0.85
get_hiliteFunction · 0.85

Calls 1

lowcFunction · 0.70

Tested by

no test coverage detected