00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if defined(LIBC_SCCS) && !defined(lint)
00024 static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
00025 #endif
00026
00027 #include <ansidecl.h>
00028 #ifdef ANSI_PROTOTYPES
00029 #include <stddef.h>
00030 #else
00031 #define size_t unsigned long
00032 #endif
00033
00034
00035
00036
00037
00038
00039 static const unsigned char charmap[] = {
00040 '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
00041 '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
00042 '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
00043 '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
00044 '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
00045 '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
00046 '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
00047 '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
00048 '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
00049 '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
00050 '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
00051 '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
00052 '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
00053 '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
00054 '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
00055 '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
00056 '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
00057 '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
00058 '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
00059 '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
00060 '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
00061 '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
00062 '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
00063 '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
00064 '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
00065 '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
00066 '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
00067 '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
00068 '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
00069 '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
00070 '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
00071 '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
00072 };
00073
00074 int
00075 strncasecmp(s1, s2, n)
00076 const char *s1, *s2;
00077 register size_t n;
00078 {
00079 register unsigned char u1, u2;
00080
00081 for (; n != 0; --n) {
00082 u1 = (unsigned char) *s1++;
00083 u2 = (unsigned char) *s2++;
00084 if (charmap[u1] != charmap[u2]) {
00085 return charmap[u1] - charmap[u2];
00086 }
00087 if (u1 == '\0') {
00088 return 0;
00089 }
00090 }
00091 return 0;
00092 }