convert char nc into oc's case; mostly used by strcasecpy */
| 298 | |
| 299 | /* convert char nc into oc's case; mostly used by strcasecpy */ |
| 300 | char |
| 301 | chrcasecpy(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(); |