< prev index next >

src/hotspot/share/utilities/utf8.hpp

Print this page
rev 58452 : imported patch pkg_name_from_class

@@ -68,11 +68,20 @@
   // the surrogate pair when seeing a supplementary character in string,
   // stores the result in value, and returns the end of the current utf8 chararacter.
   static char* next_character(const char* str, jint* value);
 
   // Utility methods
-  static const jbyte* strrchr(const jbyte* base, int length, jbyte c);
+
+  // Returns NULL if 'c' it not found. This only works as long
+  // as 'c' is an ASCII character
+  static const jbyte* strrchr(const jbyte* base, int length, jbyte c) {
+    assert(length >= 0, "sanity check");
+    assert(c >= 0, "does not work for non-ASCII characters");
+    // Skip backwards in string until 'c' is found or end is reached
+    while(--length >= 0 && base[length] != c);
+    return (length < 0) ? NULL : &base[length];
+  }
   static bool   equal(const jbyte* base1, int length1, const jbyte* base2,int length2);
   static bool   is_supplementary_character(const unsigned char* str);
   static jint   get_supplementary_character(const unsigned char* str);
 
   static bool   is_legal_utf8(const unsigned char* buffer, int length,
< prev index next >