summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Washburn <geoffrey.washburn@epfl.ch>2008-08-12 11:04:01 +0000
committerGeoffrey Washburn <geoffrey.washburn@epfl.ch>2008-08-12 11:04:01 +0000
commitd789698f45023a19b4ae4d5802d64690268b74bb (patch)
tree8b341fdd1758c7d9b5dbca1dd601e4ea833ff5c0
parent13fddf993cb528a32a29e28986630462f5a5fcd5 (diff)
downloadscala-d789698f45023a19b4ae4d5802d64690268b74bb.tar.gz
scala-d789698f45023a19b4ae4d5802d64690268b74bb.tar.bz2
scala-d789698f45023a19b4ae4d5802d64690268b74bb.zip
Correction to Sean's decoding fix.
Added a simple test for the unicode decoding stuff.
-rw-r--r--src/compiler/scala/tools/nsc/util/NameTransformer.scala9
-rw-r--r--test/files/pos/unicode-decode.scala9
2 files changed, 14 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/util/NameTransformer.scala b/src/compiler/scala/tools/nsc/util/NameTransformer.scala
index 855b2d563d..f57334e362 100644
--- a/src/compiler/scala/tools/nsc/util/NameTransformer.scala
+++ b/src/compiler/scala/tools/nsc/util/NameTransformer.scala
@@ -109,11 +109,12 @@ object NameTransformer {
}
/* Handle the decoding of Unicode glyphs that are
* not valid Java/JVM identifiers */
- } else if (ch1 == 'u' &&
- (Character.isDigit(ch2)) ||
- ('A' <= ch2 && ch2 <= 'F')) {
+ } else if ((len - i) >= 6 && // Check that there are enough characters left
+ ch1 == 'u' &&
+ (Character.isDigit(ch2)) ||
+ ('A' <= ch2 && ch2 <= 'F')) {
/* Skip past "$u", next four should be hexadecimal */
- val hex = name.substring(i+2, if (i+6 <= len) i+6 else len)
+ val hex = name.substring(i+2, i+6)
try {
val str = Integer.parseInt(hex, 16).toChar
if (buf eq null) {
diff --git a/test/files/pos/unicode-decode.scala b/test/files/pos/unicode-decode.scala
new file mode 100644
index 0000000000..9818ed64a4
--- /dev/null
+++ b/test/files/pos/unicode-decode.scala
@@ -0,0 +1,9 @@
+object Test {
+
+ val ↑ = 3
+ val x$u20A2 = 4
+ val y$ub = 5
+ val y$u0A = 6
+ val z$up = 2
+
+}