diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2010-09-02 09:57:58 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2010-09-02 09:57:58 +0000 |
commit | c45a1430699d7438f46d5af6f4db63f3ed587805 (patch) | |
tree | 6c4adfd515c62430aef1f8c3cb23969f6bdf42f4 /src/library | |
parent | 512a7a03e0c0a964f067483930f430b05eae744d (diff) | |
download | scala-c45a1430699d7438f46d5af6f4db63f3ed587805.tar.gz scala-c45a1430699d7438f46d5af6f4db63f3ed587805.tar.bz2 scala-c45a1430699d7438f46d5af6f4db63f3ed587805.zip |
Merged revisions 22188-22189,22195,22198,22445,...
Merged revisions
22188-22189,22195,22198,22445,22450,22452,22457,22460,22462,22470,22484,
22489-22490,22556,22609,22667-22668,22684,22830 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk
........
r22188 | extempore | 2010-06-08 01:43:14 +0200 (Tue, 08 Jun 2010) | 4 lines
Most of the iterate implementations were calling the given function
one too many times, leading to tragic failure if the function could not
handle this (such as repeatedly applying tail.) Closes #3540, review by
prokopec. ........ r22189 | extempore | 2010-06-08 04:15:50 +0200 (Tue,
08 Jun 2010) | 4 lines
Taking another shot at negative constants as annotation arguments
since r22175 didn't quite get there. I call into the constant folder
with the unfolded tree at the last point before it's going to fail the
compile anyway. Closes #3521, review by odersky. ........ r22195 |
extempore | 2010-06-08 16:35:16 +0200 (Tue, 08 Jun 2010) | 2 lines
Fixed a regrettable oversight which was leaving temp files stacking up
in templand, and a partial fix for #3519. No review. ........ r22198 |
extempore | 2010-06-08 21:03:56 +0200 (Tue, 08 Jun 2010) | 3 lines
Put in some long overdue soft padding around repl completion so
when it pokes around the compiler in a way which surprises something,
we don't lose the repl. Closes #3548, no review. ........ r22445 |
extempore | 2010-06-30 22:51:18 +0200 (Wed, 30 Jun 2010) | 1 line
Added forkjoin to partest's classpath to unbreak the build. No review.
........ r22450 | extempore | 2010-07-01 02:16:32 +0200 (Thu, 01 Jul
2010) | 4 lines
Although everything now builds for me, the buildbot still fails
on src/dbc for lack of forkjoin.jar. We apparently have invented
non-deterministic jar dependencies. Added forkjoin.jar in another spot,
no review. ........ r22452 | extempore | 2010-07-01 20:29:09 +0200 (Thu,
01 Jul 2010) | 2 lines
Warded off a parser crash on certain invalid programs. Closes #3209,
no review. ........ r22457 | extempore | 2010-07-01 22:32:02 +0200 (Thu,
01 Jul 2010) | 2 lines
A crasher in the pattern matcher revealed a flaw in how equality
comparisons were constructed. Closes #3570, no review. ........ r22460 |
extempore | 2010-07-01 22:32:47 +0200 (Thu, 01 Jul 2010) | 2 lines
Fixed an infinite loop in the xml parser on invalid input. Also found
an off by one bug in Source while fixing it. No review. ........ r22462
| extempore | 2010-07-01 22:43:32 +0200 (Thu, 01 Jul 2010) | 4 lines
Since the buildbots won't meet me in the middle, am putting the
forkjoin.jar everywhere with the hope/expectation we will see a restoral
of order. Someone should definitely figure out how it is we developed
this non-deterministic dependency. Review by phaller. ........ r22470 |
extempore | 2010-07-02 06:20:28 +0200 (Fri, 02 Jul 2010) | 2 lines
Normalized protected type aliases before repl printing, so we don't
see things like x.Self. Closes #3193, no review. ........ r22484 |
extempore | 2010-07-04 22:26:55 +0200 (Sun, 04 Jul 2010) | 2 lines
Tightened how the repl prints types so we don't see OverloadedTypes
slip through sometimes. Review by apocalisp. ........ r22489 | extempore
| 2010-07-05 18:00:22 +0200 (Mon, 05 Jul 2010) | 3 lines
The take/drop methods in IndexedSeqOptimized were overridden to call
slice without checking bounds, causing it to fail when the argument is
too large. Restored expected behavior. No review. ........ r22490 |
extempore | 2010-07-05 18:06:36 +0200 (Mon, 05 Jul 2010) | 1 line
A brown bag on the head fix to that last patch. No review. ........
r22556 | extempore | 2010-07-14 10:00:03 +0200 (Wed, 14 Jul 2010) | 2
lines
Moved the burden of forgivingness for string slices into StringOps
where it belongs. Review by odersky. ........ r22609 | extempore |
2010-07-20 20:14:54 +0200 (Tue, 20 Jul 2010) | 2 lines
Fix for stability failure introduced in build.xml change. Review by
malayeri (as an FYI.) ........ r22667 | extempore | 2010-08-03 20:01:34
+0200 (Tue, 03 Aug 2010) | 3 lines
Parse ordering issue prevented passing properties containing a :.
There is a test case included, but note that partest passes it with or
without the patch: see ticket #3712. Closes #3495, no review. ........
r22668 | extempore | 2010-08-03 20:01:47 +0200 (Tue, 03 Aug 2010) | 2
lines
Reverted my brainless introduction of ## to a java file. Closes #3716,
no review. ........ r22684 | extempore | 2010-08-05 17:15:00 +0200 (Thu,
05 Aug 2010) | 2 lines
Widened a try block to unregress the error message for file not found.
Closes #3729, no review. ........ r22830 | extempore | 2010-08-23
18:57:10 +0200 (Mon, 23 Aug 2010) | 2 lines
Fix and test case for broken linked lists, contributed by Lucien
Pereira. Closes #3361, no review. ........
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Array.scala | 17 | ||||
-rw-r--r-- | src/library/scala/collection/generic/TraversableFactory.scala | 16 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/StringOps.scala | 12 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/DoubleLinkedList.scala | 16 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/LinkedListLike.scala | 3 | ||||
-rw-r--r-- | src/library/scala/io/Source.scala | 10 | ||||
-rw-r--r-- | src/library/scala/xml/parsing/MarkupParser.scala | 6 |
7 files changed, 51 insertions, 29 deletions
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index 8327b93d66..e7ee280cef 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -391,13 +391,18 @@ object Array extends FallbackArrayBuilding { */ def iterate[T: ClassManifest](start: T, len: Int)(f: T => T): Array[T] = { val b = newBuilder[T] - b.sizeHint(len) - var acc = start - var i = 0 - while (i < len) { + + if (len > 0) { + b.sizeHint(len) + var acc = start + var i = 1 b += acc - acc = f(acc) - i += 1 + + while (i < len) { + acc = f(acc) + i += 1 + b += acc + } } b.result } diff --git a/src/library/scala/collection/generic/TraversableFactory.scala b/src/library/scala/collection/generic/TraversableFactory.scala index d8541d2714..c6f5ce4dde 100644 --- a/src/library/scala/collection/generic/TraversableFactory.scala +++ b/src/library/scala/collection/generic/TraversableFactory.scala @@ -224,13 +224,17 @@ abstract class TraversableFactory[CC[X] <: Traversable[X] with GenericTraversabl */ def iterate[A](start: A, len: Int)(f: A => A): CC[A] = { val b = newBuilder[A] - b.sizeHint(len) - var acc = start - var i = 0 - while (i < len) { + if (len > 0) { + b.sizeHint(len) + var acc = start + var i = 1 b += acc - acc = f(acc) - i += 1 + + while (i < len) { + acc = f(acc) + i += 1 + b += acc + } } b.result } diff --git a/src/library/scala/collection/immutable/StringOps.scala b/src/library/scala/collection/immutable/StringOps.scala index 8a27a4ad4b..0d8f5f6b83 100644 --- a/src/library/scala/collection/immutable/StringOps.scala +++ b/src/library/scala/collection/immutable/StringOps.scala @@ -36,8 +36,16 @@ final class StringOps(override val repr: String) extends StringLike[String] { /** Creates a string builder buffer as builder for this class */ override protected[this] def newBuilder = new StringBuilder - override def slice(from: Int, until: Int): String = - repr.substring(from max 0, until min repr.length) + override def slice(from: Int, until: Int): String = { + /** Slice must be forgiving on all out of bounds indices and + * substring is not. + */ + val start = from max 0 + val end = until min repr.length + + if (start >= end) "" + else repr.substring(start, end) + } override def toString = repr } diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index e702301703..d3c86953c8 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -69,15 +69,21 @@ object DoubleLinkedList extends SeqFactory[DoubleLinkedList] { def newBuilder[A]: Builder[A, DoubleLinkedList[A]] = new Builder[A, DoubleLinkedList[A]] { var current: DoubleLinkedList[A] = _ + val emptyList = new DoubleLinkedList[A]() + if(null == current) + current = emptyList + def +=(elem: A): this.type = { - val tmp = new DoubleLinkedList(elem, null) - if (current != null) - current.insert(tmp) + if (current.nonEmpty) + current.insert(new DoubleLinkedList(elem, emptyList)) else - current = tmp + current = new DoubleLinkedList(elem, emptyList) this } - def clear() { current = null } + + def clear() { + current = emptyList + } def result() = current } } diff --git a/src/library/scala/collection/mutable/LinkedListLike.scala b/src/library/scala/collection/mutable/LinkedListLike.scala index ca904e0a24..6fb516d566 100644 --- a/src/library/scala/collection/mutable/LinkedListLike.scala +++ b/src/library/scala/collection/mutable/LinkedListLike.scala @@ -66,8 +66,7 @@ trait LinkedListLike[A, This <: Seq[A] with LinkedListLike[A, This]] extends Seq def insert(that: This): Unit = { require(nonEmpty, "insert into empty list") if (that.nonEmpty) { - that.append(next) - next = that + next = next.append(that) } } diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index 935fe022be..cb7403e255 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -198,7 +198,8 @@ abstract class Source extends Iterator[Char] { * */ @deprecated("Use a collections method such as getLines().toIndexedSeq for random access.") - def getLine(line: Int): String = getLines() drop (line - 1) next + def getLine(line: Int): String = lineNum(line) + private def lineNum(line: Int): String = getLines() drop (line - 1) next class LineIterator() extends Iterator[String] { private[this] val sb = new StringBuilder @@ -298,11 +299,10 @@ abstract class Source extends Iterator[Char] { * @param out PrintStream to use */ def report(pos: Int, msg: String, out: PrintStream) { - val line = Position line pos - val col = Position column pos - val str = getLines() toIndexedSeq line + val line = Position line pos + val col = Position column pos - out println "%s:%d:%d: %s%s%s^".format(descr, line, col, msg, str, spaces(col - 1)) + out println "%s:%d:%d: %s%s%s^".format(descr, line, col, msg, lineNum(line), spaces(col - 1)) } /** diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index 24e0d78c6f..4f6b89c07b 100644 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -310,7 +310,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests def xEntityValue(): String = { val endch = ch nextch - while (ch != endch) { + while (ch != endch && !eof) { putChar(ch) nextch } @@ -556,7 +556,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests if (ch != '\'' && ch != '"') reportSyntaxError("quote ' or \" expected"); nextch - while (ch != endch) { + while (ch != endch && !eof) { putChar(ch) nextch } @@ -572,7 +572,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests if (ch!='\'' && ch != '"') reportSyntaxError("quote ' or \" expected"); nextch - while (ch != endch) { + while (ch != endch && !eof) { putChar(ch) //Console.println("hello '"+ch+"'"+isPubIDChar(ch)); if (!isPubIDChar(ch)) |