old 'readline' and 'endOfFile' not deprecated anymore; too convenient for 1 liners (see examples/maximum.nim)

This commit is contained in:
Araq 2011-11-29 08:41:06 +01:00
commit 455994664e
5 changed files with 7 additions and 16 deletions

View file

@ -14,7 +14,7 @@
## wanted functionality. ## wanted functionality.
when defined(Windows): when defined(Windows):
proc ReadLineFromStdin*(prompt: string): TaintedString {.deprecated.} = proc ReadLineFromStdin*(prompt: string): TaintedString =
## Reads a line from stdin. ## Reads a line from stdin.
stdout.write(prompt) stdout.write(prompt)
result = readLine(stdin) result = readLine(stdin)
@ -32,7 +32,7 @@ when defined(Windows):
else: else:
import readline, history import readline, history
proc ReadLineFromStdin*(prompt: string): TaintedString {.deprecated.} = proc ReadLineFromStdin*(prompt: string): TaintedString =
var buffer = readline.readLine(prompt) var buffer = readline.readLine(prompt)
if isNil(buffer): quit(0) if isNil(buffer): quit(0)
result = TaintedString($buffer) result = TaintedString($buffer)

View file

@ -43,10 +43,9 @@ proc close*(s, unused: PStream) {.deprecated.} =
## closes the stream `s`. ## closes the stream `s`.
s.closeImpl(s) s.closeImpl(s)
proc atEnd*(s: PStream): bool {.deprecated.} = proc atEnd*(s: PStream): bool =
## checks if more data can be read from `f`. Returns true if all data has ## checks if more data can be read from `f`. Returns true if all data has
## been read. ## been read.
## **Deprecated since version 0.8.14**: Because Posix supports it poorly.
result = s.atEndImpl(s) result = s.atEndImpl(s)
proc atEnd*(s, unused: PStream): bool {.deprecated.} = proc atEnd*(s, unused: PStream): bool {.deprecated.} =
@ -170,10 +169,9 @@ proc readLine*(s: PStream, line: var TaintedString): bool =
line.string.add(c) line.string.add(c)
result = true result = true
proc readLine*(s: PStream): TaintedString {.deprecated.} = proc readLine*(s: PStream): TaintedString =
## Reads a line from a stream `s`. Note: This is not very efficient. Raises ## Reads a line from a stream `s`. Note: This is not very efficient. Raises
## `EIO` if an error occured. ## `EIO` if an error occured.
## **Deprecated since version 0.8.14**: Because Posix supports it poorly.
result = TaintedString"" result = TaintedString""
while true: while true:
var c = readChar(s) var c = readChar(s)

View file

@ -1672,9 +1672,8 @@ when not defined(EcmaScript) and not defined(NimrodVM):
proc Close*(f: TFile) {.importc: "fclose", nodecl.} proc Close*(f: TFile) {.importc: "fclose", nodecl.}
## Closes the file. ## Closes the file.
proc EndOfFile*(f: TFile): Bool {.deprecated.} proc EndOfFile*(f: TFile): Bool
## Returns true iff `f` is at the end. ## Returns true iff `f` is at the end.
## **Deprecated since version 0.8.14**: Because Posix supports it poorly.
proc readChar*(f: TFile): char {.importc: "fgetc", nodecl.} proc readChar*(f: TFile): char {.importc: "fgetc", nodecl.}
## Reads a single character from the stream `f`. If the stream ## Reads a single character from the stream `f`. If the stream
@ -1704,13 +1703,10 @@ when not defined(EcmaScript) and not defined(NimrodVM):
proc write*(f: TFile, a: openArray[string]) proc write*(f: TFile, a: openArray[string])
## Writes a value to the file `f`. May throw an IO exception. ## Writes a value to the file `f`. May throw an IO exception.
proc readLine*(f: TFile): TaintedString {.deprecated.} proc readLine*(f: TFile): TaintedString
## reads a line of text from the file `f`. May throw an IO exception. ## reads a line of text from the file `f`. May throw an IO exception.
## A line of text may be delimited by ``CR``, ``LF`` or ## A line of text may be delimited by ``CR``, ``LF`` or
## ``CRLF``. The newline character(s) are not part of the returned string. ## ``CRLF``. The newline character(s) are not part of the returned string.
##
## **Deprecated since 0.8.14**: Use the `readLine` that takes a ``var``
## parameter instead.
proc readLine*(f: TFile, line: var TaintedString): bool proc readLine*(f: TFile, line: var TaintedString): bool
## reads a line of text from the file `f` into `line`. `line` must not be ## reads a line of text from the file `f` into `line`. `line` must not be
@ -1719,7 +1715,6 @@ when not defined(EcmaScript) and not defined(NimrodVM):
## ``CRLF``. The newline character(s) are not part of the returned string. ## ``CRLF``. The newline character(s) are not part of the returned string.
## Returns ``false`` if the end of the file has been reached, ``true`` ## Returns ``false`` if the end of the file has been reached, ``true``
## otherwise. If ``false`` is returned `line` contains no new data. ## otherwise. If ``false`` is returned `line` contains no new data.
proc writeln*[Ty](f: TFile, x: Ty) {.inline.} proc writeln*[Ty](f: TFile, x: Ty) {.inline.}
## writes a value `x` to `f` and then writes "\n". ## writes a value `x` to `f` and then writes "\n".
## May throw an IO exception. ## May throw an IO exception.

View file

@ -114,7 +114,7 @@ proc runThreadTests(r: var TResults, options: string) =
template test(filename: expr): stmt = template test(filename: expr): stmt =
runSingleTest(r, "tests/threads" / filename, options) runSingleTest(r, "tests/threads" / filename, options)
runSingleTest(r, "tests/threads" / filename, options & " -d:release") runSingleTest(r, "tests/threads" / filename, options & " -d:release")
runSingleTest(r, "tests/threads" / filename, options & " -tlsEmulation:on") runSingleTest(r, "tests/threads" / filename, options & " --tlsEmulation:on")
test "tactors" test "tactors"
test "threadex" test "threadex"

View file

@ -53,8 +53,6 @@ Changes affecting backwards compatibility
because they should not be used directly anymore. because they should not be used directly anymore.
Wrapper procs have been created that should be used instead. Wrapper procs have been created that should be used instead.
- ``export`` is now a keyword. - ``export`` is now a keyword.
- ``system.endOfFile``, ``system.readLine`` and their stream equivalents
are deprecated because Posix supports it poorly.
Language Additions Language Additions