Mercurial > trustbridge > nss-cmake-static
comparison nspr/lib/libc/src/strcase.c @ 0:1e5118fa0cb1
This is NSS with a Cmake Buildsyste
To compile a static NSS library for Windows we've used the
Chromium-NSS fork and added a Cmake buildsystem to compile
it statically for Windows. See README.chromium for chromium
changes and README.trustbridge for our modifications.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 28 Jul 2014 10:47:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e5118fa0cb1 |
---|---|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |
2 /* This Source Code Form is subject to the terms of the Mozilla Public | |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
5 | |
6 #include "plstr.h" | |
7 #include <string.h> | |
8 | |
9 static const unsigned char uc[] = | |
10 { | |
11 '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', | |
12 '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', | |
13 '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', | |
14 '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', | |
15 ' ', '!', '"', '#', '$', '%', '&', '\'', | |
16 '(', ')', '*', '+', ',', '-', '.', '/', | |
17 '0', '1', '2', '3', '4', '5', '6', '7', | |
18 '8', '9', ':', ';', '<', '=', '>', '?', | |
19 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', | |
20 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', | |
21 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', | |
22 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', | |
23 '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', | |
24 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', | |
25 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', | |
26 'X', 'Y', 'Z', '{', '|', '}', '~', '\177', | |
27 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, | |
28 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, | |
29 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, | |
30 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, | |
31 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, | |
32 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, | |
33 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, | |
34 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, | |
35 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, | |
36 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, | |
37 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, | |
38 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, | |
39 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, | |
40 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, | |
41 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, | |
42 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 | |
43 }; | |
44 | |
45 PR_IMPLEMENT(PRIntn) | |
46 PL_strcasecmp(const char *a, const char *b) | |
47 { | |
48 const unsigned char *ua = (const unsigned char *)a; | |
49 const unsigned char *ub = (const unsigned char *)b; | |
50 | |
51 if( ((const char *)0 == a) || (const char *)0 == b ) | |
52 return (PRIntn)(a-b); | |
53 | |
54 while( (uc[*ua] == uc[*ub]) && ('\0' != *a) ) | |
55 { | |
56 a++; | |
57 ua++; | |
58 ub++; | |
59 } | |
60 | |
61 return (PRIntn)(uc[*ua] - uc[*ub]); | |
62 } | |
63 | |
64 PR_IMPLEMENT(PRIntn) | |
65 PL_strncasecmp(const char *a, const char *b, PRUint32 max) | |
66 { | |
67 const unsigned char *ua = (const unsigned char *)a; | |
68 const unsigned char *ub = (const unsigned char *)b; | |
69 | |
70 if( ((const char *)0 == a) || (const char *)0 == b ) | |
71 return (PRIntn)(a-b); | |
72 | |
73 while( max && (uc[*ua] == uc[*ub]) && ('\0' != *a) ) | |
74 { | |
75 a++; | |
76 ua++; | |
77 ub++; | |
78 max--; | |
79 } | |
80 | |
81 if( 0 == max ) return (PRIntn)0; | |
82 | |
83 return (PRIntn)(uc[*ua] - uc[*ub]); | |
84 } | |
85 | |
86 PR_IMPLEMENT(char *) | |
87 PL_strcasestr(const char *big, const char *little) | |
88 { | |
89 PRUint32 ll; | |
90 | |
91 if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; | |
92 if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; | |
93 | |
94 ll = strlen(little); | |
95 | |
96 for( ; *big; big++ ) | |
97 /* obvious improvement available here */ | |
98 if( 0 == PL_strncasecmp(big, little, ll) ) | |
99 return (char *)big; | |
100 | |
101 return (char *)0; | |
102 } | |
103 | |
104 PR_IMPLEMENT(char *) | |
105 PL_strcaserstr(const char *big, const char *little) | |
106 { | |
107 const char *p; | |
108 PRUint32 bl, ll; | |
109 | |
110 if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; | |
111 if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; | |
112 | |
113 bl = strlen(big); | |
114 ll = strlen(little); | |
115 if( bl < ll ) return (char *)0; | |
116 p = &big[ bl - ll ]; | |
117 | |
118 for( ; p >= big; p-- ) | |
119 /* obvious improvement available here */ | |
120 if( 0 == PL_strncasecmp(p, little, ll) ) | |
121 return (char *)p; | |
122 | |
123 return (char *)0; | |
124 } | |
125 | |
126 PR_IMPLEMENT(char *) | |
127 PL_strncasestr(const char *big, const char *little, PRUint32 max) | |
128 { | |
129 PRUint32 ll; | |
130 | |
131 if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; | |
132 if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; | |
133 | |
134 ll = strlen(little); | |
135 if( ll > max ) return (char *)0; | |
136 max -= ll; | |
137 max++; | |
138 | |
139 for( ; max && *big; big++, max-- ) | |
140 /* obvious improvement available here */ | |
141 if( 0 == PL_strncasecmp(big, little, ll) ) | |
142 return (char *)big; | |
143 | |
144 return (char *)0; | |
145 } | |
146 | |
147 PR_IMPLEMENT(char *) | |
148 PL_strncaserstr(const char *big, const char *little, PRUint32 max) | |
149 { | |
150 const char *p; | |
151 PRUint32 ll; | |
152 | |
153 if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; | |
154 if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; | |
155 | |
156 ll = strlen(little); | |
157 | |
158 for( p = big; max && *p; p++, max-- ) | |
159 ; | |
160 | |
161 p -= ll; | |
162 if( p < big ) return (char *)0; | |
163 | |
164 for( ; p >= big; p-- ) | |
165 /* obvious improvement available here */ | |
166 if( 0 == PL_strncasecmp(p, little, ll) ) | |
167 return (char *)p; | |
168 | |
169 return (char *)0; | |
170 } |