Commit c7560266 by Michael Koch Committed by Michael Koch

2003-10-20 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.

From-SVN: r72716
parent d15f01e3
2003-10-20 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-18 Michael Koch <konqueror@gmx.de> 2003-10-18 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/file/Connection.java, * gnu/java/net/protocol/file/Connection.java,
......
...@@ -180,6 +180,9 @@ public class RuleBasedCollator extends Collator ...@@ -180,6 +180,9 @@ public class RuleBasedCollator extends Collator
*/ */
public RuleBasedCollator (String rules) throws ParseException public RuleBasedCollator (String rules) throws ParseException
{ {
if (rules.equals (""))
throw new ParseException ("empty rule set", 0);
this.rules = rules; this.rules = rules;
this.frenchAccents = false; this.frenchAccents = false;
...@@ -225,7 +228,19 @@ public class RuleBasedCollator extends Collator ...@@ -225,7 +228,19 @@ public class RuleBasedCollator extends Collator
if (argument.length() == 0) if (argument.length() == 0)
throw new ParseException ("invalid character", save); throw new ParseException ("invalid character", save);
String arg = argument.toString(); 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 (c != '&')
{ {
// If the argument already appears in the vector, then we // If the argument already appears in the vector, then we
...@@ -535,8 +550,7 @@ public class RuleBasedCollator extends Collator ...@@ -535,8 +550,7 @@ public class RuleBasedCollator extends Collator
private final boolean is_special (char c) private final boolean is_special (char c)
{ {
// Rules from JCL book. // Rules from JCL book.
return ((c >= 0x0009 && c <= 0x000d) return ((c >= 0x0021 && c <= 0x002f)
|| (c >= 0x0020 && c <= 0x002f)
|| (c >= 0x003a && c <= 0x0040) || (c >= 0x003a && c <= 0x0040)
|| (c >= 0x005b && c <= 0x0060) || (c >= 0x005b && c <= 0x0060)
|| (c >= 0x007b && c <= 0x007e)); || (c >= 0x007b && c <= 0x007e));
...@@ -549,15 +563,20 @@ public class RuleBasedCollator extends Collator ...@@ -549,15 +563,20 @@ public class RuleBasedCollator extends Collator
int len = rules.length(); int len = rules.length();
while (index < len) while (index < len)
{ {
char c = rules.charAt(index); char c = rules.charAt (index);
if (c == '\'' && index + 2 < len if (c == '\''
&& rules.charAt(index + 2) == '\'' && index + 2 < len
&& is_special (rules.charAt(index + 1))) && rules.charAt (index + 2) == '\'')
index += 2; {
else if (is_special (c) || Character.isWhitespace(c)) result.append (rules.charAt (index + 1));
index += 2;
}
else if (is_special (c))
return index; return index;
result.append(c); else if (!Character.isWhitespace (c))
++index; result.append (c);
++index;
} }
return index; return index;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment