summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2005-04-20 10:47:54 +0000
committerburaq <buraq@epfl.ch>2005-04-20 10:47:54 +0000
commit6f7a94d6e4b7094abd2b1d978d3cba07ff9e9d8f (patch)
treea8c75449e8b1fa04108c925c49f35d1ec1a9a500 /sources
parent250399c9e174f0cd6e74074bfa13ab284dac964c (diff)
downloadscala-6f7a94d6e4b7094abd2b1d978d3cba07ff9e9d8f.tar.gz
scala-6f7a94d6e4b7094abd2b1d978d3cba07ff9e9d8f.tar.bz2
scala-6f7a94d6e4b7094abd2b1d978d3cba07ff9e9d8f.zip
bug, char.getType doesn't work after all
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/io/Source.scala17
1 files changed, 9 insertions, 8 deletions
diff --git a/sources/scala/io/Source.scala b/sources/scala/io/Source.scala
index 65fced08e6..3926655d27 100644
--- a/sources/scala/io/Source.scala
+++ b/sources/scala/io/Source.scala
@@ -127,24 +127,25 @@ abstract class Source extends Iterator[Char] {
// -- methods
//
- /** convenience method, returns given line from Source */
+ /** convenience method, returns given line (not including newline)
+ * from Source
+ */
def getLine(line: Int): String = {
val buf = new StringBuffer();
val it = reset;
var i = 0;
- while( it.hasNext
- && i < (line-1)
- && Character.LINE_SEPARATOR != Character.getType(it.next) ) {
- i = i + 1
- }
+
+ while( it.hasNext && i < (line-1))
+ if('\n' == it.next)
+ i = i + 1;
+
if(!it.hasNext) { // this should not happen
throw new java.lang.IllegalArgumentException(
"line "+line+" does not exist?!"
);
}
var ch = it.next;
- while( it.hasNext
- && Character.LINE_SEPARATOR != ch ) {
+ while(it.hasNext && '\n' != ch) {
buf.append( ch );
ch = it.next;
}