summary refs log tree commit diff stats
path: root/lib/system/sysio.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-09-24 19:18:08 +0200
committerAraq <rumpf_a@web.de>2011-09-24 19:18:08 +0200
commit485c371942cbbb1f9a10c64b6fcc699e59511460 (patch)
tree06afc132570838dd1b64c70b79d64f8fff3509b6 /lib/system/sysio.nim
parent72ceda98cbbef896c31102a2c90d5f9fe1033d03 (diff)
downloadNim-485c371942cbbb1f9a10c64b6fcc699e59511460.tar.gz
renamed optional to discardable
Diffstat (limited to 'lib/system/sysio.nim')
-rwxr-xr-xlib/system/sysio.nim19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 56815c0c5..313d9fd95 100755
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -56,8 +56,12 @@ proc rawReadLine(f: TFile, result: var string) =
     add result, chr(int(c))
 
 proc readLine(f: TFile): TaintedString =
-  result = TaintedString("")
-  rawReadLine(f, result)
+  when taintMode:
+    result = TaintedString""
+    rawReadLine(f, result.string)
+  else:
+    result = ""
+    rawReadLine(f, result)
 
 proc write(f: TFile, i: int) = 
   when sizeof(int) == 8:
@@ -86,9 +90,14 @@ proc readFile(filename: string): TaintedString =
   try:
     var len = getFileSize(f)
     if len < high(int):
-      result = newString(int(len))
-      if readBuffer(f, addr(result[0]), int(len)) != len:
-        raiseEIO("error while reading from file")
+      when taintMode:
+        result = newString(int(len)).TaintedString
+        if readBuffer(f, addr(string(result)[0]), int(len)) != len:
+          raiseEIO("error while reading from file")
+      else:
+        result = newString(int(len))
+        if readBuffer(f, addr(result[0]), int(len)) != len:
+          raiseEIO("error while reading from file")
     else:
       raiseEIO("file too big to fit in memory")
   finally: