162 } |
162 } |
163 } |
163 } |
164 |
164 |
165 // Returns NULL if 'c' it not found. This only works as long |
165 // Returns NULL if 'c' it not found. This only works as long |
166 // as 'c' is an ASCII character |
166 // as 'c' is an ASCII character |
167 jbyte* UTF8::strrchr(jbyte* base, int length, jbyte c) { |
167 const jbyte* UTF8::strrchr(const jbyte* base, int length, jbyte c) { |
168 assert(length >= 0, "sanity check"); |
168 assert(length >= 0, "sanity check"); |
169 assert(c >= 0, "does not work for non-ASCII characters"); |
169 assert(c >= 0, "does not work for non-ASCII characters"); |
170 // Skip backwards in string until 'c' is found or end is reached |
170 // Skip backwards in string until 'c' is found or end is reached |
171 while(--length >= 0 && base[length] != c); |
171 while(--length >= 0 && base[length] != c); |
172 return (length < 0) ? NULL : &base[length]; |
172 return (length < 0) ? NULL : &base[length]; |
173 } |
173 } |
174 |
174 |
175 bool UTF8::equal(jbyte* base1, int length1, jbyte* base2, int length2) { |
175 bool UTF8::equal(const jbyte* base1, int length1, const jbyte* base2, int length2) { |
176 // Length must be the same |
176 // Length must be the same |
177 if (length1 != length2) return false; |
177 if (length1 != length2) return false; |
178 for (int i = 0; i < length1; i++) { |
178 for (int i = 0; i < length1; i++) { |
179 if (base1[i] != base2[i]) return false; |
179 if (base1[i] != base2[i]) return false; |
180 } |
180 } |