From 1ce9c63d502d0a3f68d71c05a9186b84664905f5 Mon Sep 17 00:00:00 2001
From: Michael Koch <mkoch@gcc.gnu.org>
Date: Thu, 11 Mar 2004 15:50:34 +0000
Subject: [PATCH] [multiple changes]

2004-03-11  Dalibor Topic  <robilad@kaffe.org>

	* java/text/AttributedString.java
	(addAttribute(AttributedCharacterIterator.Attribute,Object,int,int)):
	Use HashMap instead of Hashtable since value can be null, and
	you can not store a null value in a Hashtable.

2004-03-11  Guilhem Lavaux <guilhem@kaffe.org>

	* java/text/AttributedStringIterator.java
	(getAllAttributesKey): Return only keys concerned
	by the current iterator.
	(getAttributes): Use strict inequality for
	end_index.

From-SVN: r79329
---
 libjava/ChangeLog                               | 15 +++++++++++++++
 libjava/java/text/AttributedString.java         | 11 ++++++-----
 libjava/java/text/AttributedStringIterator.java | 10 +++++++---
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 2ed64719e0fd..2d741cf4468c 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,18 @@
+2004-03-11  Dalibor Topic  <robilad@kaffe.org>
+
+	* java/text/AttributedString.java
+	(addAttribute(AttributedCharacterIterator.Attribute,Object,int,int)):
+	Use HashMap instead of Hashtable since value can be null, and
+	you can not store a null value in a Hashtable.
+
+2004-03-11  Guilhem Lavaux <guilhem@kaffe.org>
+
+	* java/text/AttributedStringIterator.java
+	(getAllAttributesKey): Return only keys concerned
+	by the current iterator.
+	(getAttributes): Use strict inequality for
+	end_index. 
+
 2004-03-11  Michael Koch  <konqueror@gmx.de>
 
 	* java/net/HttpURLConnection.java:
diff --git a/libjava/java/text/AttributedString.java b/libjava/java/text/AttributedString.java
index d689d87ac58d..a8eede813fc8 100644
--- a/libjava/java/text/AttributedString.java
+++ b/libjava/java/text/AttributedString.java
@@ -1,5 +1,5 @@
 /* AttributedString.java -- Models text with attributes
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -39,6 +39,7 @@ exception statement from your version. */
 package java.text;
 
 import java.util.Iterator;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.HashSet;
 import java.util.Map;
@@ -329,7 +330,7 @@ addAttribute(AttributedCharacterIterator.Attribute attrib, Object value)
   * of the string.
   *
   * @param attrib The attribute to add.
-  * @param value The value of the attribute.
+  * @param value The value of the attribute, which may be null.
   * @param begin_index The beginning index of the subrange.
   * @param end_index The ending index of the subrange.
   *
@@ -342,10 +343,10 @@ addAttribute(AttributedCharacterIterator.Attribute attrib, Object value,
   if (attrib == null)
     throw new IllegalArgumentException("null attribute");
 
-  Hashtable ht = new Hashtable();
-  ht.put(attrib, value);
+  HashMap hm = new HashMap();
+  hm.put(attrib, value);
 
-  addAttributes(ht, begin_index, end_index);
+  addAttributes(hm, begin_index, end_index);
 }
 
 /*************************************************************************/
diff --git a/libjava/java/text/AttributedStringIterator.java b/libjava/java/text/AttributedStringIterator.java
index d3193382bfde..77c5981703d6 100644
--- a/libjava/java/text/AttributedStringIterator.java
+++ b/libjava/java/text/AttributedStringIterator.java
@@ -179,8 +179,12 @@ getAllAttributeKeys()
   if (attribs == null)
     return(s);
 
-  for (int i = 0; i < attribs.length; i++)
+    for (int i = 0; i < attribs.length; i++)
     {
+      if (attribs[i].begin_index > getEndIndex()
+	  || attribs[i].end_index <= getBeginIndex())
+	continue;
+
       Set key_set = attribs[i].attribs.keySet();
       Iterator iter = key_set.iterator();
       while (iter.hasNext())
@@ -327,7 +331,7 @@ getAttribute(AttributedCharacterIterator.Attribute attrib)
           // Check for attribute match and range match
           if (obj.equals(attrib))
             if ((ci.getIndex() >= attribs[i].begin_index) &&
-                (ci.getIndex() <= attribs[i].end_index))
+                (ci.getIndex() < attribs[i].end_index))
               return(attribs[i].attribs.get(obj));
         }
     }
@@ -351,7 +355,7 @@ getAttributes()
   for (int i = 0; i < attribs.length; i++)
     {
        if ((ci.getIndex() >= attribs[i].begin_index) &&
-           (ci.getIndex() <= attribs[i].end_index))
+           (ci.getIndex() < attribs[i].end_index))
          m.putAll(attribs[i].attribs);
     }
 
-- 
GitLab