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

Function chrcasecpy

src/hacklib.c:300–317  ·  view source on GitHub ↗

convert char nc into oc's case; mostly used by strcasecpy */

Source from the content-addressed store, hash-verified

298
299/* convert char nc into oc's case; mostly used by strcasecpy */
300char
301chrcasecpy(int oc, int nc)
302{
303#if 0 /* this will be necessary if we switch to <ctype.h> */
304 oc = (int) (unsigned char) oc;
305 nc = (int) (unsigned char) nc;
306#endif
307 if ('a' <= oc && oc <= 'z') {
308 /* old char is lower case; if new char is upper case, downcase it */
309 if ('A' <= nc && nc <= 'Z')
310 nc += 'a' - 'A'; /* lowc(nc) */
311 } else if ('A' <= oc && oc <= 'Z') {
312 /* old char is upper case; if new char is lower case, upcase it */
313 if ('a' <= nc && nc <= 'z')
314 nc += 'A' - 'a'; /* highc(nc) */
315 }
316 return (char) nc;
317}
318
319/* overwrite string, preserving old chars' case;
320 for case-insensitive editions of makeplural() and makesingular();

Callers 1

strcasecpyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected