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

Function str_start_is

src/hacklib.c:212–237  ·  view source on GitHub ↗

determine whether 'str' starts with 'chkstr', possibly ignoring case; * panics on huge strings */

Source from the content-addressed store, hash-verified

210/* determine whether 'str' starts with 'chkstr', possibly ignoring case;
211 * panics on huge strings */
212boolean
213str_start_is(
214 const char *str,
215 const char *chkstr,
216 boolean caseblind)
217{
218 char t1, t2;
219 int n = LARGEST_INT;
220
221 while (--n) {
222 if (!*str)
223 return (*chkstr == 0); /* chkstr >= str */
224 else if (!*chkstr)
225 return TRUE; /* chkstr < str */
226 t1 = caseblind ? lowc(*str) : *str;
227 t2 = caseblind ? lowc(*chkstr) : *chkstr;
228 str++, chkstr++;
229 if (t1 != t2)
230 return FALSE;
231 }
232#if 0
233 if (n == 0)
234 panic("string too long");
235#endif
236 return TRUE;
237}
238
239/* determine whether 'str' ends in 'chkstr' */
240boolean

Callers 7

parseoptionsFunction · 0.85
optfn_autounlockFunction · 0.85
optfn_runmodeFunction · 0.85
msgtype_parse_addFunction · 0.85
set_option_mod_statusFunction · 0.85
wizterrainwishFunction · 0.85
title_to_monFunction · 0.85

Calls 2

lowcFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected