[Kaffe] bugs found and fixed in Character.java

Moses DeJong dejong at cs.umn.edu
Sun Jan 24 02:12:49 PST 1999


Hi all.

There were a number of bugs in the java.lang.Character class.
Here is a patch that fixes most of them (Unicode still does
not work but at least chars lower than 160 work with my patch).


*** /tmp/mo/Character.java	Sun Jan 24 01:32:49 1999
--- libraries/javalib/java/lang/Character.java	Sun Jan 24 03:43:31 1999
***************
*** 90,96 ****
  
    public static boolean isLetterOrDigit(char ch)
    {
!     return (isJavaIdentifierPart(ch));
    }
    
    public static boolean isJavaLetter(char ch)
--- 90,96 ----
  
    public static boolean isLetterOrDigit(char ch)
    {
!     return (isLetter(ch) || isDigit(ch));
    }
    
    public static boolean isJavaLetter(char ch)
***************
*** 257,263 ****
  
    public static boolean isJavaIdentifierPart(char ch)
    {
!     return (isLetter(ch) || ch == '$' || ch == '_' || isDigit(ch));
    }
  
    public static boolean isJavaIdentifierStart(char ch)
--- 257,267 ----
  
    public static boolean isJavaIdentifierPart(char ch)
    {
!       return ((ch >= '\u0000' && ch <= '\u0008') ||
! 	(ch >= '\u000e' && ch <= '\u001b') ||
! 	(ch >= '\u007f' && ch <= '\u009f') ||
! 	ch == '$' || ch == '_' ||
!         isLetter(ch) || isDigit(ch));
    }
  
    public static boolean isJavaIdentifierStart(char ch)
***************
*** 267,293 ****
  
    public static boolean isSpaceChar(char ch)
    {
!     if (ch == 0x0009 || ch == 0x000a || ch == 0x0000c || ch == 0x000d || ch == 0x0020) {
!       return (true);
!     }
!     else {
!       return (false);
!     }
    }
  
    public static boolean isUnicodeIdentifierPart(char ch)
    {
!     return (isJavaIdentifierPart(ch));
    }
  
    public static boolean isUnicodeIdentifierStart(char ch)
    {
!     return (isJavaIdentifierStart(ch));
    }
  
    public static boolean isWhitespace(char ch)
    {
!     if (ch == 0x0009 || ch == 0x000A || ch == 0x000B || ch == 0x000C || ch == 0x000D || ch == 0x001C || ch == 0x001D || ch == 0x001F) {
        return (true);
      }
      else if (ch == ' ') {
--- 271,292 ----
  
    public static boolean isSpaceChar(char ch)
    {
!       return (ch == ' ');
    }
  
    public static boolean isUnicodeIdentifierPart(char ch)
    {
!       return (ch != '$' && (isLetter(ch) || isJavaIdentifierPart(ch)));
    }
  
    public static boolean isUnicodeIdentifierStart(char ch)
    {
!       return (isLetter(ch));
    }
  
    public static boolean isWhitespace(char ch)
    {
!     if (ch == 0x0009 || ch == 0x000A || ch == 0x000B || ch == 0x000C || ch == 0x000D || ch == 0x001C || ch == 0x001D || ch == 0x001E || ch == 0x001F) {
        return (true);
      }
      else if (ch == ' ') {




If you want proof that these are the right changes you may want to
run this example class. Try running it under the JDK and save the
results to jout then run it under kaffe and save the results to
kout. At that point do a "diff -c jout kout" to see that there
an no differences after my patch has been applied. If you do this
same test without my patch you will see a TON of differences (bugs).


public class CharTest3 {
    public static void main(String[] argv) {
	char c;
	int i;
	for (i = 0; i < 160 ; i++) {
	    c = (char) i;
	    test(c);
	}
    }

    public static void test(char c) {
	if (Character.isLetterOrDigit(c)) {
	System.out.println("testing charcter '" + c + "'");
	}

	System.out.println("unicode value is " + ((int) c) );	

	System.out.println("isDigit() is " +
			   Character.isDigit(c));   
	System.out.println("isLetter() is " +
			   Character.isLetter(c));
	System.out.println("isLetterOrDigit() is " +
			   Character.isLetterOrDigit(c));

	System.out.println("isSpaceChar() is " +
			   Character.isSpaceChar(c));
	System.out.println("isWhitespace() is " +
			   Character.isWhitespace(c));

	System.out.println("isJavaIdentifierStart() is " +
			   Character.isJavaIdentifierStart(c));


	System.out.println("isJavaIdentifierPart() is " +
			   Character.isJavaIdentifierPart(c));
	System.out.println("isJavaIdentifierStart() is " +
			   Character.isJavaIdentifierStart(c));
	System.out.println("isIdentifierIgnorable() is " +
			   Character.isIdentifierIgnorable(c));
	System.out.println("isUnicodeIdentifierStart() is " +
			   Character.isUnicodeIdentifierStart(c));
	System.out.println("isUnicodeIdentifierPart() is " +
			   Character.isUnicodeIdentifierPart(c));
	
	System.out.println();
    }


}



later
mo dejong
dejong at cs.umn.edu




More information about the kaffe mailing list