mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-18 23:11:36 +00:00
old 'readline' and 'endOfFile' not deprecated anymore; too convenient for 1 liners (see examples/maximum.nim)
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
## wanted functionality.
|
||||
|
||||
when defined(Windows):
|
||||
proc ReadLineFromStdin*(prompt: string): TaintedString {.deprecated.} =
|
||||
proc ReadLineFromStdin*(prompt: string): TaintedString =
|
||||
## Reads a line from stdin.
|
||||
stdout.write(prompt)
|
||||
result = readLine(stdin)
|
||||
@@ -32,7 +32,7 @@ when defined(Windows):
|
||||
else:
|
||||
import readline, history
|
||||
|
||||
proc ReadLineFromStdin*(prompt: string): TaintedString {.deprecated.} =
|
||||
proc ReadLineFromStdin*(prompt: string): TaintedString =
|
||||
var buffer = readline.readLine(prompt)
|
||||
if isNil(buffer): quit(0)
|
||||
result = TaintedString($buffer)
|
||||
|
||||
@@ -43,10 +43,9 @@ proc close*(s, unused: PStream) {.deprecated.} =
|
||||
## closes the stream `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
|
||||
## been read.
|
||||
## **Deprecated since version 0.8.14**: Because Posix supports it poorly.
|
||||
result = s.atEndImpl(s)
|
||||
|
||||
proc atEnd*(s, unused: PStream): bool {.deprecated.} =
|
||||
@@ -170,10 +169,9 @@ proc readLine*(s: PStream, line: var TaintedString): bool =
|
||||
line.string.add(c)
|
||||
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
|
||||
## `EIO` if an error occured.
|
||||
## **Deprecated since version 0.8.14**: Because Posix supports it poorly.
|
||||
result = TaintedString""
|
||||
while true:
|
||||
var c = readChar(s)
|
||||
|
||||
@@ -1672,9 +1672,8 @@ when not defined(EcmaScript) and not defined(NimrodVM):
|
||||
proc Close*(f: TFile) {.importc: "fclose", nodecl.}
|
||||
## Closes the file.
|
||||
|
||||
proc EndOfFile*(f: TFile): Bool {.deprecated.}
|
||||
proc EndOfFile*(f: TFile): Bool
|
||||
## 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.}
|
||||
## 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])
|
||||
## 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.
|
||||
## A line of text may be delimited by ``CR``, ``LF`` or
|
||||
## ``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
|
||||
## 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.
|
||||
## Returns ``false`` if the end of the file has been reached, ``true``
|
||||
## otherwise. If ``false`` is returned `line` contains no new data.
|
||||
|
||||
proc writeln*[Ty](f: TFile, x: Ty) {.inline.}
|
||||
## writes a value `x` to `f` and then writes "\n".
|
||||
## May throw an IO exception.
|
||||
|
||||
@@ -114,7 +114,7 @@ proc runThreadTests(r: var TResults, options: string) =
|
||||
template test(filename: expr): stmt =
|
||||
runSingleTest(r, "tests/threads" / filename, options)
|
||||
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 "threadex"
|
||||
|
||||
@@ -53,8 +53,6 @@ Changes affecting backwards compatibility
|
||||
because they should not be used directly anymore.
|
||||
Wrapper procs have been created that should be used instead.
|
||||
- ``export`` is now a keyword.
|
||||
- ``system.endOfFile``, ``system.readLine`` and their stream equivalents
|
||||
are deprecated because Posix supports it poorly.
|
||||
|
||||
|
||||
Language Additions
|
||||
|
||||
Reference in New Issue
Block a user