This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: java.text.RuleBasedCollator - several fixes
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org, tromey at redhat dot com
- Date: Fri, 17 Oct 2003 21:58:00 +0200
- Subject: Patch: java.text.RuleBasedCollator - several fixes
Hi list, hi Tom,
I just wrote a little patch to fix several mauve failures. Please review and
comment.
Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2273
diff -u -b -B -r1.2273 ChangeLog
--- ChangeLog 15 Oct 2003 15:50:44 -0000 1.2273
+++ ChangeLog 17 Oct 2003 19:49:55 -0000
@@ -1,3 +1,12 @@
+2003-10-17 Michael Koch <konqueror@gmx.de>
+
+ * java/text/RuleBasedCollator.java
+ (RuleBasedCollator): Check rules not empty, fixed search in already
+ existing collation elements.
+ (is_special): Removed common whitespace characters.
+ (text_argument): Dont return on whitespaces, add characters between
+ two ' to string buffer.
+
2003-10-15 Michael Koch <konqueror@gmx.de>
* java/text/RuleBasedCollator.java
Index: java/text/RuleBasedCollator.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/RuleBasedCollator.java,v
retrieving revision 1.11
diff -u -b -B -r1.11 RuleBasedCollator.java
--- java/text/RuleBasedCollator.java 15 Oct 2003 15:50:47 -0000 1.11
+++ java/text/RuleBasedCollator.java 17 Oct 2003 19:49:56 -0000
@@ -180,6 +180,9 @@
*/
public RuleBasedCollator (String rules) throws ParseException
{
+ if (rules.equals (""))
+ throw new ParseException ("empty rule set", 0);
+
this.rules = rules;
this.frenchAccents = false;
@@ -225,7 +228,19 @@
if (argument.length() == 0)
throw new ParseException ("invalid character", save);
String arg = argument.toString();
- int item_index = vec.indexOf(arg);
+ int item_index = -1;
+
+ for (int j = 0; j < vec.size(); ++j)
+ {
+ CollationElement e = (CollationElement) vec.elementAt (j);
+
+ if (arg.equals (e.key))
+ {
+ item_index = j;
+ break;
+ }
+ }
+
if (c != '&')
{
// If the argument already appears in the vector, then we
@@ -535,8 +550,7 @@
private final boolean is_special (char c)
{
// Rules from JCL book.
- return ((c >= 0x0009 && c <= 0x000d)
- || (c >= 0x0020 && c <= 0x002f)
+ return ((c >= 0x0021 && c <= 0x002f)
|| (c >= 0x003a && c <= 0x0040)
|| (c >= 0x005b && c <= 0x0060)
|| (c >= 0x007b && c <= 0x007e));
@@ -549,14 +563,19 @@
int len = rules.length();
while (index < len)
{
- char c = rules.charAt(index);
- if (c == '\'' && index + 2 < len
- && rules.charAt(index + 2) == '\''
- && is_special (rules.charAt(index + 1)))
+ char c = rules.charAt (index);
+ if (c == '\''
+ && index + 2 < len
+ && rules.charAt (index + 2) == '\'')
+ {
+ result.append (rules.charAt (index + 1));
index += 2;
- else if (is_special (c) || Character.isWhitespace(c))
+ }
+ else if (is_special (c))
return index;
- result.append(c);
+ else if (!Character.isWhitespace (c))
+ result.append (c);
+
++index;
}
return index;