classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] zeroBasedStringValue to java.lang.String


From: C. Scott Ananian
Subject: [patch] zeroBasedStringValue to java.lang.String
Date: Tue, 24 Sep 2002 12:37:03 -0400 (EDT)

Attached is a patch to move zeroBasedStringValue to java.lang.String (from
java.lang.Character) to avoid making java.lang.Character, java.lang.Class,
and java.security.ProtectionDomain "core classes".
 --scott
[in addition to being attached, patch is also appended below for your
 easy-reading pleasure.]

Bejing Waco, Texas India Flintlock Bush Khaddafi Yakima operative 
NORAD Honduras Sudan planning Richard Tomlinson East Timor D5 SLBM 
                         ( http://cscott.net/ )

Index: java/lang/Character.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Character.java,v
retrieving revision 1.31
diff -u -p -r1.31 Character.java
--- java/lang/Character.java    13 Aug 2002 20:51:07 -0000      1.31
+++ java/lang/Character.java    24 Sep 2002 16:33:01 -0000
@@ -1384,41 +1384,19 @@ public final class Character implements 
   public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18;
 
   /**
-   * Returns the value array of the given string if it is zero based or a
-   * copy of it that is zero based (stripping offset and making length equal
-   * to count). Used for accessing the char[]s of gnu.java.lang.CharData.
-   * Package private for use in String.
-   */
-  static char[] zeroBasedStringValue(String s)
-  {
-    char[] value;
-
-    if (s.offset == 0 && s.count == s.value.length)
-      value = s.value;
-    else
-      {
-       int count = s.count;
-       value = new char[count];
-       System.arraycopy(s.value, s.offset, value, 0, count);
-      }
-
-    return value;
-  }
-
-  /**
    * Stores unicode block offset lookup table. Exploit package visibility of
    * String.value to avoid copying the array.
    * @see #readChar(char)
    * @see CharData#BLOCKS
    */
-  private static final char[] blocks = zeroBasedStringValue(CharData.BLOCKS);
+  private static final char[] blocks = 
String.zeroBasedStringValue(CharData.BLOCKS);
 
   /**
    * Stores unicode attribute offset lookup table. Exploit package visibility
    * of String.value to avoid copying the array.
    * @see CharData#DATA
    */
-  private static final char[] data = zeroBasedStringValue(CharData.DATA);
+  private static final char[] data = 
String.zeroBasedStringValue(CharData.DATA);
 
   /**
    * Stores unicode numeric value attribute table. Exploit package visibility
@@ -1426,21 +1404,21 @@ public final class Character implements 
    * @see CharData#NUM_VALUE
    */
   private static final char[] numValue
-         = zeroBasedStringValue(CharData.NUM_VALUE);
+         = String.zeroBasedStringValue(CharData.NUM_VALUE);
 
   /**
    * Stores unicode uppercase attribute table. Exploit package visibility
    * of String.value to avoid copying the array.
    * @see CharData#UPPER
    */
-  private static final char[] upper = zeroBasedStringValue(CharData.UPPER);
+  private static final char[] upper = 
String.zeroBasedStringValue(CharData.UPPER);
 
   /**
    * Stores unicode lowercase attribute table. Exploit package visibility
    * of String.value to avoid copying the array.
    * @see CharData#LOWER
    */
-  private static final char[] lower = zeroBasedStringValue(CharData.LOWER);
+  private static final char[] lower = 
String.zeroBasedStringValue(CharData.LOWER);
 
   /**
    * Stores unicode direction attribute table. Exploit package visibility
@@ -1448,14 +1426,14 @@ public final class Character implements 
    * @see CharData#DIRECTION
    */
   // Package visible for use by String.
-  static final char[] direction = zeroBasedStringValue(CharData.DIRECTION);
+  static final char[] direction = 
String.zeroBasedStringValue(CharData.DIRECTION);
 
   /**
    * Stores unicode titlecase table. Exploit package visibility of
    * String.value to avoid copying the array.
    * @see CharData#TITLE
    */
-  private static final char[] title = zeroBasedStringValue(CharData.TITLE);
+  private static final char[] title = 
String.zeroBasedStringValue(CharData.TITLE);
 
   /**
    * Mask for grabbing the type out of the contents of data.
Index: java/lang/String.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/String.java,v
retrieving revision 1.51
diff -u -p -r1.51 String.java
--- java/lang/String.java       16 Sep 2002 13:31:08 -0000      1.51
+++ java/lang/String.java       24 Sep 2002 16:33:02 -0000
@@ -99,7 +99,7 @@ public final class String implements Ser
    * @see CharData#UPPER_EXPAND
    */
   private static final char[] upperExpand
-       = Character.zeroBasedStringValue(CharData.UPPER_EXPAND);
+       = zeroBasedStringValue(CharData.UPPER_EXPAND);
 
   /**
    * Stores unicode multi-character uppercase special casing table.
@@ -107,7 +107,7 @@ public final class String implements Ser
    * @see CharData#UPPER_SPECIAL
    */
   private static final char[] upperSpecial
-         = Character.zeroBasedStringValue(CharData.UPPER_SPECIAL);
+         = zeroBasedStringValue(CharData.UPPER_SPECIAL);
   
   /**
    * Characters which make up the String.
@@ -1668,5 +1668,27 @@ public final class String implements Ser
         c = upperSpecial[mid];
       }
     return upperSpecial[mid + 1];
+  }
+
+  /**
+   * Returns the value array of the given string if it is zero based or a
+   * copy of it that is zero based (stripping offset and making length equal
+   * to count). Used for accessing the char[]s of gnu.java.lang.CharData.
+   * Package private for use in String.
+   */
+  static char[] zeroBasedStringValue(String s)
+  {
+    char[] value;
+
+    if (s.offset == 0 && s.count == s.value.length)
+      value = s.value;
+    else
+      {
+       int count = s.count;
+       value = new char[count];
+       System.arraycopy(s.value, s.offset, value, 0, count);
+      }
+
+    return value;
   }
 } // class String

Attachment: patch.string0
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]