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

Function findword

src/hacklib.c:600–621  ·  view source on GitHub ↗

search for a word in a space-separated list; returns non-Null if found */

Source from the content-addressed store, hash-verified

598
599/* search for a word in a space-separated list; returns non-Null if found */
600const char *
601findword(
602 const char *list, /* string of space-separated words */
603 const char *word, /* word to try to find */
604 int wordlen, /* so that it isn't required to be \0 terminated */
605 boolean ignorecase) /* T: case-blind, F: case-sensitive */
606{
607 const char *p = list;
608
609 while (p) {
610 while (*p == ' ')
611 ++p;
612 if (!*p)
613 break;
614 if ((ignorecase ? !strncmpi(p, word, wordlen)
615 : !strncmp(p, word, wordlen))
616 && (p[wordlen] == '\0' || p[wordlen] == ' '))
617 return p;
618 p = strchr(p + 1, ' ');
619 }
620 return (const char *) 0;
621}
622
623/* return the ordinal suffix of a number */
624const char *

Callers 1

plnamesuffixFunction · 0.85

Calls 1

strncmpiFunction · 0.70

Tested by

no test coverage detected