Merge pull request #4314 from abudden/2146-unbuffered-io
Added setStdIoUnbuffered for unbuffered stdio (fixes #2146).
This commit is contained in:
commit
9bb31f6273
3 changed files with 12 additions and 0 deletions
|
|
@ -2715,6 +2715,9 @@ when not defined(JS): #and not defined(nimscript):
|
||||||
##
|
##
|
||||||
## Default mode is readonly. Returns true iff the file could be reopened.
|
## Default mode is readonly. Returns true iff the file could be reopened.
|
||||||
|
|
||||||
|
proc setStdIoUnbuffered*() {.tags: [], benign.}
|
||||||
|
## Configures `stdin`, `stdout` and `stderr` to be unbuffered.
|
||||||
|
|
||||||
proc close*(f: File) {.tags: [].}
|
proc close*(f: File) {.tags: [].}
|
||||||
## Closes the file.
|
## Closes the file.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,4 +369,12 @@ proc writeFile(filename, content: string) =
|
||||||
else:
|
else:
|
||||||
sysFatal(IOError, "cannot open: ", filename)
|
sysFatal(IOError, "cannot open: ", filename)
|
||||||
|
|
||||||
|
proc setStdIoUnbuffered() =
|
||||||
|
when declared(stdout):
|
||||||
|
discard c_setvbuf(stdout, nil, IONBF, 0)
|
||||||
|
when declared(stderr):
|
||||||
|
discard c_setvbuf(stderr, nil, IONBF, 0)
|
||||||
|
when declared(stdin):
|
||||||
|
discard c_setvbuf(stdin, nil, IONBF, 0)
|
||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ Library Additions
|
||||||
|
|
||||||
- Added ``readHeaderRow`` and ``rowEntry`` to ``parsecsv.nim`` to provide
|
- Added ``readHeaderRow`` and ``rowEntry`` to ``parsecsv.nim`` to provide
|
||||||
a lightweight alternative to python's ``csv.DictReader``.
|
a lightweight alternative to python's ``csv.DictReader``.
|
||||||
|
- Added ``setStdIoUnbuffered`` proc to ``system.nim`` to enable unbuffered I/O.
|
||||||
|
|
||||||
Compiler Additions
|
Compiler Additions
|
||||||
------------------
|
------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue