mirror of git://gcc.gnu.org/git/gcc.git
MessageFormat.java (scanString): Changed how quoting is handled.
* java/text/MessageFormat.java (scanString): Changed how quoting is handled. (scanFormatElement): Likewise. From-SVN: r93804
This commit is contained in:
parent
e5cd332117
commit
5526a514c9
|
|
@ -1,3 +1,9 @@
|
||||||
|
2005-01-17 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* java/text/MessageFormat.java (scanString): Changed how quoting
|
||||||
|
is handled.
|
||||||
|
(scanFormatElement): Likewise.
|
||||||
|
|
||||||
2004-12-07 Mark Wielaard <mark@klomp.org>
|
2004-12-07 Mark Wielaard <mark@klomp.org>
|
||||||
|
|
||||||
* java/text/MessageFormat.java (scanFormat): Chain thrown exception.
|
* java/text/MessageFormat.java (scanFormat): Chain thrown exception.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* MessageFormat.java - Localized message formatting.
|
/* MessageFormat.java - Localized message formatting.
|
||||||
Copyright (C) 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
|
Copyright (C) 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
|
@ -193,27 +193,36 @@ public class MessageFormat extends Format
|
||||||
{
|
{
|
||||||
int max = pat.length();
|
int max = pat.length();
|
||||||
buffer.setLength(0);
|
buffer.setLength(0);
|
||||||
|
boolean quoted = false;
|
||||||
for (; index < max; ++index)
|
for (; index < max; ++index)
|
||||||
{
|
{
|
||||||
char c = pat.charAt(index);
|
char c = pat.charAt(index);
|
||||||
if (c == '\'' && index + 2 < max && pat.charAt(index + 2) == '\'')
|
if (quoted)
|
||||||
{
|
{
|
||||||
buffer.append(pat.charAt(index + 1));
|
// In a quoted context, a single quote ends the quoting.
|
||||||
index += 2;
|
if (c == '\'')
|
||||||
|
quoted = false;
|
||||||
|
else
|
||||||
|
buffer.append(c);
|
||||||
}
|
}
|
||||||
else if (c == '\'' && index + 1 < max
|
// Check for '', which is a single quote.
|
||||||
&& pat.charAt(index + 1) == '\'')
|
else if (c == '\'' && index + 1 < max && pat.charAt(index + 1) == '\'')
|
||||||
{
|
{
|
||||||
buffer.append(c);
|
buffer.append(c);
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
else if (c == '\'')
|
||||||
|
{
|
||||||
|
// Start quoting.
|
||||||
|
quoted = true;
|
||||||
|
}
|
||||||
else if (c == '{')
|
else if (c == '{')
|
||||||
break;
|
break;
|
||||||
else if (c == '}')
|
|
||||||
throw new IllegalArgumentException("Found '}' without '{'");
|
|
||||||
else
|
else
|
||||||
buffer.append(c);
|
buffer.append(c);
|
||||||
}
|
}
|
||||||
|
// Note that we explicitly allow an unterminated quote. This is
|
||||||
|
// done for compatibility.
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,39 +234,42 @@ public class MessageFormat extends Format
|
||||||
int max = pat.length();
|
int max = pat.length();
|
||||||
buffer.setLength(0);
|
buffer.setLength(0);
|
||||||
int brace_depth = 1;
|
int brace_depth = 1;
|
||||||
|
boolean quoted = false;
|
||||||
|
|
||||||
for (; index < max; ++index)
|
for (; index < max; ++index)
|
||||||
{
|
{
|
||||||
char c = pat.charAt(index);
|
char c = pat.charAt(index);
|
||||||
if (c == '\'' && index + 2 < max && pat.charAt(index + 2) == '\'')
|
// First see if we should turn off quoting.
|
||||||
|
if (quoted)
|
||||||
{
|
{
|
||||||
buffer.append(c);
|
if (c == '\'')
|
||||||
buffer.append(pat.charAt(index + 1));
|
quoted = false;
|
||||||
buffer.append(c);
|
// In both cases we fall through to inserting the
|
||||||
index += 2;
|
// character here.
|
||||||
}
|
}
|
||||||
|
// See if we have just a plain quote to insert.
|
||||||
else if (c == '\'' && index + 1 < max
|
else if (c == '\'' && index + 1 < max
|
||||||
&& pat.charAt(index + 1) == '\'')
|
&& pat.charAt(index + 1) == '\'')
|
||||||
{
|
{
|
||||||
buffer.append(c);
|
buffer.append(c);
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
// See if quoting should turn on.
|
||||||
|
else if (c == '\'')
|
||||||
|
quoted = true;
|
||||||
else if (c == '{')
|
else if (c == '{')
|
||||||
{
|
++brace_depth;
|
||||||
buffer.append(c);
|
|
||||||
++brace_depth;
|
|
||||||
}
|
|
||||||
else if (c == '}')
|
else if (c == '}')
|
||||||
{
|
{
|
||||||
if (--brace_depth == 0)
|
if (--brace_depth == 0)
|
||||||
break;
|
break;
|
||||||
buffer.append(c);
|
|
||||||
}
|
}
|
||||||
// Check for TERM after braces, because TERM might be `}'.
|
// Check for TERM after braces, because TERM might be `}'.
|
||||||
else if (c == term)
|
else if (c == term)
|
||||||
break;
|
break;
|
||||||
else
|
// All characters, including opening and closing quotes, are
|
||||||
buffer.append(c);
|
// inserted here.
|
||||||
|
buffer.append(c);
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue