[kaffe] CVS kaffe (robilad): Small cleanup

Kaffe CVS cvs-commits at kaffe.org
Tue Feb 1 17:45:44 PST 2005


PatchSet 5959 
Date: 2005/02/02 01:41:00
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Small cleanup

2005-02-02  Dalibor Topic  <robilad at kaffe.org>

        * libraries/javalib/gnu/regexp/CharIndexedReader.java,
        libraries/javalib/gnu/regexp/REFilterReader.java,
        libraries/javalib/java/awt/TextBuffer.java:
        Removed redundant classes.

Members: 
	ChangeLog:1.3498->1.3499 
	libraries/javalib/Makefile.am:1.304->1.305 
	libraries/javalib/Makefile.in:1.388->1.389 
	libraries/javalib/all.files:1.86->1.87 
	libraries/javalib/gnu/regexp/CharIndexedReader.java:1.2->1.3(DEAD) 
	libraries/javalib/gnu/regexp/REFilterReader.java:1.1->1.2(DEAD) 
	libraries/javalib/java/awt/TextBuffer.java:1.1->1.2(DEAD) 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3498 kaffe/ChangeLog:1.3499
--- kaffe/ChangeLog:1.3498	Tue Feb  1 16:57:29 2005
+++ kaffe/ChangeLog	Wed Feb  2 01:41:00 2005
@@ -1,3 +1,10 @@
+2005-02-02  Dalibor Topic  <robilad at kaffe.org>
+
+	* libraries/javalib/gnu/regexp/CharIndexedReader.java,
+	libraries/javalib/gnu/regexp/REFilterReader.java,
+	libraries/javalib/java/awt/TextBuffer.java:
+	Removed redundant classes.
+
 2005-02-01  Nektarios K. Papadopoulos  <npapadop at inaccessnetworks.com>
 
 	* FAQ.classlibrary-compile: Added missing information about
Index: kaffe/libraries/javalib/Makefile.am
diff -u kaffe/libraries/javalib/Makefile.am:1.304 kaffe/libraries/javalib/Makefile.am:1.305
--- kaffe/libraries/javalib/Makefile.am:1.304	Mon Jan 31 19:22:45 2005
+++ kaffe/libraries/javalib/Makefile.am	Wed Feb  2 01:41:04 2005
@@ -1620,13 +1620,11 @@
 	gnu/regexp/CharIndexed.java \
 	gnu/regexp/CharIndexedCharArray.java \
 	gnu/regexp/CharIndexedInputStream.java \
-	gnu/regexp/CharIndexedReader.java \
 	gnu/regexp/CharIndexedString.java \
 	gnu/regexp/CharIndexedStringBuffer.java \
 	gnu/regexp/RE.java \
 	gnu/regexp/REException.java \
 	gnu/regexp/REFilterInputStream.java \
-	gnu/regexp/REFilterReader.java \
 	gnu/regexp/REMatch.java \
 	gnu/regexp/REMatchEnumeration.java \
 	gnu/regexp/RESyntax.java \
@@ -1971,7 +1969,6 @@
 	java/awt/Stroke.java \
 	java/awt/SystemColor.java \
 	java/awt/TextArea.java \
-	java/awt/TextBuffer.java \
 	java/awt/TextComponent.java \
 	java/awt/TextField.java \
 	java/awt/TexturePaint.java \
Index: kaffe/libraries/javalib/Makefile.in
diff -u kaffe/libraries/javalib/Makefile.in:1.388 kaffe/libraries/javalib/Makefile.in:1.389
--- kaffe/libraries/javalib/Makefile.in:1.388	Mon Jan 31 19:22:46 2005
+++ kaffe/libraries/javalib/Makefile.in	Wed Feb  2 01:41:05 2005
@@ -2073,13 +2073,11 @@
 	gnu/regexp/CharIndexed.java \
 	gnu/regexp/CharIndexedCharArray.java \
 	gnu/regexp/CharIndexedInputStream.java \
-	gnu/regexp/CharIndexedReader.java \
 	gnu/regexp/CharIndexedString.java \
 	gnu/regexp/CharIndexedStringBuffer.java \
 	gnu/regexp/RE.java \
 	gnu/regexp/REException.java \
 	gnu/regexp/REFilterInputStream.java \
-	gnu/regexp/REFilterReader.java \
 	gnu/regexp/REMatch.java \
 	gnu/regexp/REMatchEnumeration.java \
 	gnu/regexp/RESyntax.java \
@@ -2437,7 +2435,6 @@
 	java/awt/Stroke.java \
 	java/awt/SystemColor.java \
 	java/awt/TextArea.java \
-	java/awt/TextBuffer.java \
 	java/awt/TextComponent.java \
 	java/awt/TextField.java \
 	java/awt/TexturePaint.java \
Index: kaffe/libraries/javalib/all.files
diff -u kaffe/libraries/javalib/all.files:1.86 kaffe/libraries/javalib/all.files:1.87
--- kaffe/libraries/javalib/all.files:1.86	Mon Jan 31 19:22:49 2005
+++ kaffe/libraries/javalib/all.files	Wed Feb  2 01:41:06 2005
@@ -1187,13 +1187,11 @@
 gnu/regexp/CharIndexed.java
 gnu/regexp/CharIndexedCharArray.java
 gnu/regexp/CharIndexedInputStream.java
-gnu/regexp/CharIndexedReader.java
 gnu/regexp/CharIndexedString.java
 gnu/regexp/CharIndexedStringBuffer.java
 gnu/regexp/RE.java
 gnu/regexp/REException.java
 gnu/regexp/REFilterInputStream.java
-gnu/regexp/REFilterReader.java
 gnu/regexp/REMatch.java
 gnu/regexp/REMatchEnumeration.java
 gnu/regexp/RESyntax.java
@@ -1525,7 +1523,6 @@
 java/awt/Stroke.java
 java/awt/SystemColor.java
 java/awt/TextArea.java
-java/awt/TextBuffer.java
 java/awt/TextComponent.java
 java/awt/TextField.java
 java/awt/TexturePaint.java
===================================================================
Checking out kaffe/libraries/javalib/gnu/regexp/CharIndexedReader.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/regexp/Attic/CharIndexedReader.java,v
VERS: 1.2
***************
--- kaffe/libraries/javalib/gnu/regexp/CharIndexedReader.java	Wed Feb  2 01:45:44 2005
+++ /dev/null	Sun Aug  4 19:57:58 2002
@@ -1,142 +0,0 @@
-/*
- *  gnu/regexp/CharIndexedReader.java
- *  Copyright (C) 2001 Lee Sau Dan
- *  Based on gnu.regexp.CharIndexedInputStream by Wes Biggs
- *
- *  This library is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Lesser General Public License as published
- *  by the Free Software Foundation; either version 2.1 of the License, or
- *  (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package gnu.regexp;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-
-// TODO: move(x) shouldn't rely on calling next() x times
-
-class CharIndexedReader implements CharIndexed {
-    private static final int BUFFER_INCREMENT = 1024;
-    private static final int UNKNOWN = Integer.MAX_VALUE; // value for end
-    
-    private final BufferedReader br;
-    // so that we don't try to reset() right away
-    private int index = -1;
-
-    private int bufsize = BUFFER_INCREMENT;
-
-    private int end = UNKNOWN;
-
-    private char cached = OUT_OF_BOUNDS;
-
-    // Big enough for a \r\n pair
-    // lookBehind[0] = most recent
-    // lookBehind[1] = second most recent
-    private char[] lookBehind = new char[] { OUT_OF_BOUNDS, OUT_OF_BOUNDS }; 
-  
-    CharIndexedReader(Reader reader, int index) {
-	if (reader instanceof BufferedReader) {
-	    br = (BufferedReader) reader; 
-	} else {
-	    br = new BufferedReader(reader,BUFFER_INCREMENT);
-	}
-	next();
-	if (index > 0) move(index);
-    }
-    
-    private boolean next() {
-	lookBehind[1] = lookBehind[0];
-	lookBehind[0] = cached;
-
-	if (end == 1) {
-	    cached = OUT_OF_BOUNDS;
-	    return false;
-	}
-	end--; // closer to end
-	
-	try {
-	    if (index != -1) {
-		br.reset();
-	    }
-	    int i = br.read();
-	    br.mark(bufsize);
-	    if (i == -1) {
-		end = 1;
-		cached = OUT_OF_BOUNDS;
-		return false;
-	    }
-
-	    // convert the byte read into a char
-	    cached = (char) i;
-	    index = 1;
-	} catch (IOException e) { 
-	    e.printStackTrace();
-	    cached = OUT_OF_BOUNDS;
-	    return false; 
-	}
-	return true;
-    }
-    
-    public char charAt(int index) {
-	if (index == 0) {
-	    return cached;
-	} else if (index >= end) {
-	    return OUT_OF_BOUNDS;
-	} else if (index >= bufsize) {
-	    // Allocate more space in the buffer.
-	    try {
-		while (bufsize <= index) bufsize += BUFFER_INCREMENT;
-		br.reset();
-		br.mark(bufsize);
-		br.skip(index-1);
-	    } catch (IOException e) { }
-	} else if (this.index != index) {
-	    try {
-		br.reset();
-		br.skip(index-1);
-	    } catch (IOException e) { }
-	} else if (index == -1) {
-	    return lookBehind[0];
-	} else if (index == -2) {
-	    return lookBehind[1];
-	} else if (index < -2) {
-	    return OUT_OF_BOUNDS;
-	}
-
-	char ch = OUT_OF_BOUNDS;
-	
-	try {
-	    int i = br.read();
-	    this.index = index+1; // this.index is index of next pos relative to charAt(0)
-	    if (i == -1) {
-		// set flag that next should fail next time?
-		end = index;
-		return ch;
-	    }
-	    ch = (char) i;
-	} catch (IOException ie) { }
-	
-	return ch;
-    }
-    
-    public boolean move(int index) {
-	// move read position [index] clicks from 'charAt(0)'
-	boolean retval = true;
-	while (retval && (index-- > 0)) retval = next();
-	return retval;
-    }
-    
-    public boolean isValid() {
-	return (cached != OUT_OF_BOUNDS);
-    }
-}
===================================================================
Checking out kaffe/libraries/javalib/gnu/regexp/REFilterReader.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/regexp/Attic/REFilterReader.java,v
VERS: 1.1
***************
--- kaffe/libraries/javalib/gnu/regexp/REFilterReader.java	Wed Feb  2 01:45:44 2005
+++ /dev/null	Sun Aug  4 19:57:58 2002
@@ -1,117 +0,0 @@
-/*
- *  gnu/regexp/REFilterReader.java
- *  Copyright (C) 2001 Lee Sau Dan
- *  Based on gnu.regexp.REFilterInputStream by Wes Biggs
- *
- *  This library is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Lesser General Public License as published
- *  by the Free Software Foundation; either version 2.1 of the License, or
- *  (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package gnu.regexp;
-import java.io.FilterReader;
-import java.io.Reader;
-
-/**
- * Replaces instances of a given RE with replacement text. 
- *
- * @author <A HREF="http://www.csis.hku.hk/~sdlee/">Lee Sau Dan</A>
- * @since gnu.regexp 1.1.0
- */
-
-public class REFilterReader extends FilterReader {
-
-  private RE expr;
-  private String replace;
-  private String buffer;
-  private int bufpos;
-  private int offset;
-  private CharIndexedReader stream;
-
-  /**
-   * Creates an REFilterReader.  When reading from this stream,
-   * occurrences of patterns matching the supplied regular expression
-   * will be replaced with the supplied replacement text (the
-   * metacharacters $0 through $9 may be used to refer to the full
-   * match or subexpression matches.
-   *
-   * @param stream The Reader to be filtered.
-   * @param expr The regular expression to search for.
-   * @param replace The text pattern to replace matches with.  
-   */
-  public REFilterReader(Reader stream, RE expr, String replace) {
-    super(stream);
-    this.stream = new CharIndexedReader(stream,0);
-    this.expr = expr;
-    this.replace = replace;
-  }
-
-  /**
-   * Reads the next character from the stream per the general contract of
-   * Reader.read().  Returns -1 on error or end of stream.
-   */
-  public int read() {
-    // If we have buffered replace data, use it.
-    if ((buffer != null) && (bufpos < buffer.length())) {
-      return (int) buffer.charAt(bufpos++);
-    }
-
-    // check if input is at a valid position
-    if (!stream.isValid()) return -1;
-
-    REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0);
-    if (expr.match(stream,mymatch)) {
-      mymatch.end[0] = mymatch.index;
-      mymatch.finish(stream);
-      stream.move(mymatch.toString().length());
-      offset += mymatch.toString().length();
-      buffer = mymatch.substituteInto(replace);
-      bufpos = 1;
-
-      if (buffer.length() > 0) {
-	  return buffer.charAt(0);
-      }
-    }
-    char ch = stream.charAt(0);
-    if (ch == CharIndexed.OUT_OF_BOUNDS) return -1;
-    stream.move(1);
-    offset++;
-    return ch;
-  }
-
-  /** 
-   * Returns false.  REFilterReader does not support mark() and
-   * reset() methods. 
-   */
-  public boolean markSupported() {
-    return false;
-  }
-
-  /** Reads from the stream into the provided array. */
-  public int read(char[] b, int off, int len) {
-    int i;
-    int ok = 0;
-    while (len-- > 0) {
-      i = read();
-      if (i == -1) return (ok == 0) ? -1 : ok;
-      b[off++] = (char) i;
-      ok++;
-    }
-    return ok;
-  }
-
-  /** Reads from the stream into the provided array. */
-  public int read(char[] b) {
-    return read(b,0,b.length);
-  }
-}
===================================================================
Checking out kaffe/libraries/javalib/java/awt/TextBuffer.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/java/awt/Attic/TextBuffer.java,v
VERS: 1.1
***************
--- kaffe/libraries/javalib/java/awt/TextBuffer.java	Wed Feb  2 01:45:44 2005
+++ /dev/null	Sun Aug  4 19:57:58 2002
@@ -1,290 +0,0 @@
-package java.awt;
-
-
-class TextBuffer
-{
-	char[] buf;
-	int len;
-	int tabWidth;
-	FontMetrics fm;
-	static int defLen = 128;
-
-public TextBuffer() {
-	this( defLen);
-}
-
-public TextBuffer( String str) {
-	this( defLen);
-	append( str);
-}
-
-public TextBuffer( int length) {
-	buf = new char[length];
-}
-
-public void append( String s) {
-	insert( len, s);
-}
-
-public void append( TextBuffer tb) {
-	checkCapacity( len + tb.len);
-	for ( int i=0; i<tb.len; i++)
-		buf[len++] = tb.buf[i];
-}
-
-public void append( char c) {
-	insert( len, c);
-}
-
-void checkCapacity( int newLen) {
-	if ( newLen <= buf.length)
-		return;
-	int nl = buf.length+defLen;
-	if ( newLen > nl)
-		nl = newLen;
-	char[] pb = buf;
-	buf = new char[nl];
-	System.arraycopy( pb, 0, buf, 0, pb.length);
-}
-
-public void copyLevelFrom( TextBuffer tb){
-	int orgLevel = tb.getLevel();
-	int level = getLevel();
-	
-	for ( int i = 0; i<orgLevel - level; i++)
-		insert( 0, '\t');
-}
-
-public int getIdx( int pos){
-	return getIdxFrom( 0, pos);
-}
-
-public int getIdxFrom( int start, int pos){
-	int idx = start;
-	int x = 0;
-	
-	if ( pos < 0 ) {
-		if ( idx == 0 )
-			return 0;
-		for ( idx--; idx >= 0; idx--) {
-			if ( buf[idx] == '\t')
-				x = (x+tabWidth)/tabWidth*tabWidth;
-			else
-				x += fm.charWidth( buf[idx]);
-			if ( -x < pos)
-				return idx;
-		}
-	}
-	else {
-		for ( ; idx<len; idx++){
-			if ( buf[idx] == '\t')
-				x = (x+tabWidth)/tabWidth*tabWidth;
-			else
-				x += fm.charWidth( buf[idx]);
-			if ( x > pos)
-				return idx;
-		}
-	}
-	return idx;
-}
-
-public int getLevel(){
-	int level = 0;
-	
-	for ( int i=0; i<len; i++) {
-		if ( buf[i] != '\t' )
-			break;
-		level++;
-	}
-
-	return level;	
-}
-
-public int getPos( int idx){
-	int x = 0;
-
-	if ( idx > len)
-		idx = len;
-
-	for ( int i=0; i<idx; i++){
-		if ( buf[i] == '\t')
-			x = (x+tabWidth)/tabWidth*tabWidth;
-		else 
-			x += fm.charWidth( buf[i]);
-	}
-	return x;
-}
-
-public String getString( int start, int len){
-	if ( this.len < start + len)
-		len = this.len - start;
-	if ( len > 0)
-		return new String( buf, start, len);
-	return null;
-}
-
-public int getWidth(){
-	int x0 = getPos( 0);
-	int x1 = getPos( len);
-	return x1 - x0;
-}
-
-public int getWidth( int sIdx, int eIdx){
-	int x0 = getPos( sIdx);
-	int x1 = getPos( eIdx);
-	return x1 - x0;
-}
-
-public void insert( int idx, String s) {
-	replace( idx, 0, s);
-}
-
-public void insert( int idx, char c) {
-	replace( idx, 0, c);
-}
-
-public static void main( String[] args) {
-	TextBuffer tb = new TextBuffer();
-	tb.append( "12356789");
-	System.out.println( tb);
-	tb.insert( 3, '4');
-	System.out.println( tb);
-	tb.replace( 3, 2, "xxxxxxxx"); 
-	System.out.println( tb);
-	tb.replace( 3, 8, "45");
-	System.out.println( tb);
-	tb.remove( 0, 2);
-	System.out.println( tb);
-}
-
-public void paint( Graphics g, int x, int y, int height) {
-	paint( g, x, y, height, 0, len);
-}
-
-public void paint( Graphics g, int x, int y, int height, int start) {
-	paint( g, x, y, height, start, len - start);
-}
-
-public void paint( Graphics g, int x, int y, int height, int start, int len) {
-	int x0 = getPos( start);
-	int y0;
-	int i0 = start;
-	int idx = start;
-
-	if ( fm == null) {
-		fm = g.getFontMetrics();
-		tabWidth = 4 * fm.charWidth('x');
-	}
-	
-	y0 = y + height - (height - fm.getHeight() ) / 2 - fm.getDescent();
-	
-	if ( this.len < start + len)
-		len = this.len - start;
-		
-	for ( ; idx<start+len; idx++) {
-		if ( buf[idx] == '\t' ){
-			if ( idx > i0) {
-				g.drawChars( buf, i0, idx-i0, x+x0, y0);
-				x0 += fm.charsWidth( buf, i0, idx-i0);
-			}
-			i0 = idx+1;
-			x0 = (x0 + tabWidth)/tabWidth * tabWidth;
-		}
-	}
-
-	if ( i0 < idx)
-		g.drawChars( buf, i0, idx-i0, x+x0, y0);
-}
-
-public void paintFrom( Graphics g, int x, int y, int height, int bIdx, int start, int len) {
-	int x0, y0;
-	int i0 = start;
-	int idx = start;
-
-	if ( fm == null) {
-		fm = g.getFontMetrics();
-		tabWidth = 4 * fm.charWidth('x');
-	}
-	
-	x0 = getWidth( bIdx, start);
-	y0 = y + height - (height - fm.getHeight() ) / 2 - fm.getDescent();
-	
-	if ( this.len < start + len)
-		len = this.len - start;
-		
-	for ( ; idx<start+len; idx++) {
-		if ( buf[idx] == '\t' ){
-			if ( idx > i0) {
-				g.drawChars( buf, i0, idx-i0, x+x0, y0);
-				x0 += fm.charsWidth( buf, i0, idx-i0);
-			}
-			i0 = idx+1;
-			x0 = (x0 + tabWidth)/tabWidth * tabWidth;
-		}
-	}
-
-	if ( i0 < idx)
-		g.drawChars( buf, i0, idx-i0, x+x0, y0);
-}
-
-public void remove( int start, int len) {
-	if ( (start > this.len) || (len <= 0) )
-		return;
-	int ll = this.len - start - len;
-	if ( ll > 0 )
-		System.arraycopy( buf, start+len, buf, start, ll);
-	this.len -= len; 
-}
-
-public void replace( int start, int len, String s) {
-	int sLen = ( s != null) ? s.length() : 0;
-	int dl = sLen - len;
-
-	checkCapacity( this.len+dl);
-	int eIdx = start+len;
-	System.arraycopy( buf, eIdx, buf, eIdx+dl, this.len-eIdx);
-	
-	if ( s != null)
-		s.getChars(0, sLen, buf, start);
-	this.len += dl; 
-}
-
-public void replace( int start, int len, char c) {
-	int dl = 1 - len;
-
-	checkCapacity( this.len+dl);
-	int eIdx = start+len;
-	System.arraycopy( buf, eIdx, buf, eIdx+dl, this.len-eIdx);
-	
-	buf[start] = c;
-	this.len += dl; 
-}
-
-public void set( String s) {
-	if ( (s == null) || (s.length() == 0) ){
-		len = 0;
-	}
-	else {
-		int sLen = s.length();
-		checkCapacity( sLen);
-		s.getChars( 0, sLen, buf, 0);
-		len = sLen;
-	}
-}
-
-public void set( char c, int count) {
-	checkCapacity( count);
-	
-	for ( len = 0; len < count; len++)
-		buf[len] = c;
-}
-
-public void setMetrics( FontMetrics fm, int tabWidth) {
-	this.fm = fm;
-	this.tabWidth = tabWidth;
-}
-
-public String toString() {
-	return new String( buf, 0, len);
-}
-}




More information about the kaffe mailing list