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

Function strcasecpy

src/hacklib.c:322–341  ·  view source on GitHub ↗

overwrite string, preserving old chars' case; for case-insensitive editions of makeplural() and makesingular(); src might be shorter, same length, or longer than dst */

Source from the content-addressed store, hash-verified

320 for case-insensitive editions of makeplural() and makesingular();
321 src might be shorter, same length, or longer than dst */
322char *
323strcasecpy(char *dst, const char *src)
324{
325 char *result = dst;
326 int ic, oc, dst_exhausted = 0;
327
328 /* while dst has characters, replace each one with corresponding
329 character from src, converting case in the process if they differ;
330 once dst runs out, propagate the case of its last character to any
331 remaining src; if dst starts empty, it must be a pointer to the
332 tail of some other string because we examine the char at dst[-1] */
333 while ((ic = (int) *src++) != '\0') {
334 if (!dst_exhausted && !*dst)
335 dst_exhausted = 1;
336 oc = (int) *(dst - dst_exhausted);
337 *dst++ = chrcasecpy(oc, ic);
338 }
339 *dst = '\0';
340 return result;
341}
342
343/* return a name converted to possessive */
344char *

Callers

nothing calls this directly

Calls 1

chrcasecpyFunction · 0.85

Tested by

no test coverage detected