133965Sjdp/* 233965Sjdp * Copyright (c) 1987 Regents of the University of California. 333965Sjdp * All rights reserved. 433965Sjdp * 533965Sjdp * Redistribution and use in source and binary forms are permitted 633965Sjdp * provided that this notice is preserved and that due credit is given 733965Sjdp * to the University of California at Berkeley. The name of the University 833965Sjdp * may not be used to endorse or promote products derived from this 933965Sjdp * software without specific written prior permission. This software 1033965Sjdp * is provided ``as is'' without express or implied warranty. 1133965Sjdp */ 1233965Sjdp 1389857Sobrien/* 1489857Sobrien 1589857Sobrien@deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2}) 1689857Sobrien 1789857SobrienA case-insensitive @code{strcmp}. 1889857Sobrien 1989857Sobrien@end deftypefn 2089857Sobrien 2189857Sobrien*/ 2289857Sobrien 2333965Sjdp#if defined(LIBC_SCCS) && !defined(lint) 2433965Sjdpstatic char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; 2533965Sjdp#endif /* LIBC_SCCS and not lint */ 2633965Sjdp 2733965Sjdp#include <ansidecl.h> 2833965Sjdp#include <stddef.h> 2933965Sjdp 3033965Sjdp/* 3133965Sjdp * This array is designed for mapping upper and lower case letter 3233965Sjdp * together for a case independent comparison. The mappings are 3333965Sjdp * based upon ascii character sequences. 3433965Sjdp */ 3533965Sjdptypedef unsigned char uc; 3689857Sobrienstatic const unsigned char charmap[] = { 3733965Sjdp (uc)'\000',(uc)'\001',(uc)'\002',(uc)'\003',(uc)'\004',(uc)'\005',(uc)'\006',(uc)'\007', 3833965Sjdp (uc)'\010',(uc)'\011',(uc)'\012',(uc)'\013',(uc)'\014',(uc)'\015',(uc)'\016',(uc)'\017', 3933965Sjdp (uc)'\020',(uc)'\021',(uc)'\022',(uc)'\023',(uc)'\024',(uc)'\025',(uc)'\026',(uc)'\027', 4033965Sjdp (uc)'\030',(uc)'\031',(uc)'\032',(uc)'\033',(uc)'\034',(uc)'\035',(uc)'\036',(uc)'\037', 4133965Sjdp (uc)'\040',(uc)'\041',(uc)'\042',(uc)'\043',(uc)'\044',(uc)'\045',(uc)'\046',(uc)'\047', 4233965Sjdp (uc)'\050',(uc)'\051',(uc)'\052',(uc)'\053',(uc)'\054',(uc)'\055',(uc)'\056',(uc)'\057', 4333965Sjdp (uc)'\060',(uc)'\061',(uc)'\062',(uc)'\063',(uc)'\064',(uc)'\065',(uc)'\066',(uc)'\067', 4433965Sjdp (uc)'\070',(uc)'\071',(uc)'\072',(uc)'\073',(uc)'\074',(uc)'\075',(uc)'\076',(uc)'\077', 4533965Sjdp (uc)'\100',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147', 4633965Sjdp (uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157', 4733965Sjdp (uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167', 4833965Sjdp (uc)'\170',(uc)'\171',(uc)'\172',(uc)'\133',(uc)'\134',(uc)'\135',(uc)'\136',(uc)'\137', 4933965Sjdp (uc)'\140',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147', 5033965Sjdp (uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157', 5133965Sjdp (uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167', 5233965Sjdp (uc)'\170',(uc)'\171',(uc)'\172',(uc)'\173',(uc)'\174',(uc)'\175',(uc)'\176',(uc)'\177', 5333965Sjdp (uc)'\200',(uc)'\201',(uc)'\202',(uc)'\203',(uc)'\204',(uc)'\205',(uc)'\206',(uc)'\207', 5433965Sjdp (uc)'\210',(uc)'\211',(uc)'\212',(uc)'\213',(uc)'\214',(uc)'\215',(uc)'\216',(uc)'\217', 5533965Sjdp (uc)'\220',(uc)'\221',(uc)'\222',(uc)'\223',(uc)'\224',(uc)'\225',(uc)'\226',(uc)'\227', 5633965Sjdp (uc)'\230',(uc)'\231',(uc)'\232',(uc)'\233',(uc)'\234',(uc)'\235',(uc)'\236',(uc)'\237', 5733965Sjdp (uc)'\240',(uc)'\241',(uc)'\242',(uc)'\243',(uc)'\244',(uc)'\245',(uc)'\246',(uc)'\247', 5833965Sjdp (uc)'\250',(uc)'\251',(uc)'\252',(uc)'\253',(uc)'\254',(uc)'\255',(uc)'\256',(uc)'\257', 5933965Sjdp (uc)'\260',(uc)'\261',(uc)'\262',(uc)'\263',(uc)'\264',(uc)'\265',(uc)'\266',(uc)'\267', 6033965Sjdp (uc)'\270',(uc)'\271',(uc)'\272',(uc)'\273',(uc)'\274',(uc)'\275',(uc)'\276',(uc)'\277', 6133965Sjdp (uc)'\300',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347', 6233965Sjdp (uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357', 6333965Sjdp (uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367', 6433965Sjdp (uc)'\370',(uc)'\371',(uc)'\372',(uc)'\333',(uc)'\334',(uc)'\335',(uc)'\336',(uc)'\337', 6533965Sjdp (uc)'\340',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347', 6633965Sjdp (uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357', 6733965Sjdp (uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367', 6833965Sjdp (uc)'\370',(uc)'\371',(uc)'\372',(uc)'\373',(uc)'\374',(uc)'\375',(uc)'\376',(uc)'\377', 6933965Sjdp}; 7033965Sjdp 7133965Sjdpint 72218822Sdimstrcasecmp(const char *s1, const char *s2) 7333965Sjdp{ 7433965Sjdp register unsigned char u1, u2; 7533965Sjdp 7633965Sjdp for (;;) { 7733965Sjdp u1 = (unsigned char) *s1++; 7833965Sjdp u2 = (unsigned char) *s2++; 7933965Sjdp if (charmap[u1] != charmap[u2]) { 8033965Sjdp return charmap[u1] - charmap[u2]; 8133965Sjdp } 8233965Sjdp if (u1 == '\0') { 8333965Sjdp return 0; 8433965Sjdp } 8533965Sjdp } 8633965Sjdp} 8733965Sjdp 88