diff options
author | Burak Emir <emir@epfl.ch> | 2005-12-12 13:35:52 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2005-12-12 13:35:52 +0000 |
commit | 31f89d28888fdfd4c58f231e83bd8d68b06738d9 (patch) | |
tree | fe23fd51325daca52cc35038c41f54d1555acb84 /sources | |
parent | 54d61d5149854784432d34bc221cdb6af01969ae (diff) | |
download | scala-31f89d28888fdfd4c58f231e83bd8d68b06738d9.tar.gz scala-31f89d28888fdfd4c58f231e83bd8d68b06738d9.tar.bz2 scala-31f89d28888fdfd4c58f231e83bd8d68b06738d9.zip |
descr for URL sources
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/io/Source.scala | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sources/scala/io/Source.scala b/sources/scala/io/Source.scala index bc46aef302..a22657e4be 100644 --- a/sources/scala/io/Source.scala +++ b/sources/scala/io/Source.scala @@ -27,6 +27,14 @@ object Source { def fromBytes(bytes: Array[Byte], enc: String): Source = fromString(new String(bytes, enc)); + /** creates Source from a single char */ + def fromChar(c: Char): Source = { + val it = Iterator.single(c); + new Source { + def reset = fromChar(c); + val iter = it; + } + } /** creates Source from array of characters, with empty description */ def fromChars(chars: Array[Char]): Source = { @@ -106,10 +114,12 @@ object Source { val bufIn = new java.io.BufferedInputStream(in); data = bufIn.read() } - new Source { + val s = new Source { def reset = fromURL(url); val iter = it; - } + }; + s.descr = url.toString(); + s } } @@ -216,10 +226,10 @@ abstract class Source extends Iterator[Char] { def report(pos: Int, msg: String, out: PrintStream): Unit = { val line = Position.line(pos); - Console.println(descr+":"+line+": "+msg); + val col = Position.column(pos); + Console.println(descr+":"+line+":"+col+": "+msg); Console.println(getLine(line)); var i = 1; - val col = Position.column(pos); while( i < col ) { Console.print(' '); i = i + 1; |