diff options
Diffstat (limited to 'lib/system/sysio.nim')
-rwxr-xr-x | lib/system/sysio.nim | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index af6ba49b2..cb4aaae54 100755 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -36,13 +36,16 @@ var IOFBF {.importc: "_IOFBF", nodecl.}: cint IONBF {.importc: "_IONBF", nodecl.}: cint +proc raiseEIO(msg: string) {.noinline, noreturn.} = + raise newException(EIO, msg) + proc rawReadLine(f: TFile, result: var string) = # of course this could be optimized a bit; but IO is slow anyway... # and it was difficult to get this CORRECT with Ansi C's methods setLen(result, 0) # reuse the buffer! while True: var c = fgetc(f) - if c < 0'i32: break # EOF + if c < 0'i32: raiseEIO("EOF reached") if c == 10'i32: break # LF if c == 13'i32: # CR c = fgetc(f) # is the next char LF? @@ -76,11 +79,6 @@ proc write(f: TFile, c: Char) = putc(c, f) proc write(f: TFile, a: openArray[string]) = for x in items(a): write(f, x) -#{.error: "for debugging.".} - -proc raiseEIO(msg: string) {.noinline, noreturn.} = - raise newException(EIO, msg) - proc readFile(filename: string): string = var f = open(filename) try: |