summary refs log tree commit diff stats
path: root/lib/pure/pegs.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-06-16 10:47:44 +0200
committerAraq <rumpf_a@web.de>2011-06-16 10:47:44 +0200
commit04f9c2585ae53555cdbec4031b0d9af270b8dc86 (patch)
tree5432c3fb2b25a70b1e74aed01731be6f74b2ed66 /lib/pure/pegs.nim
parentde659eba65b5ad098a403449c4b2b1067d04a2cf (diff)
downloadNim-04f9c2585ae53555cdbec4031b0d9af270b8dc86.tar.gz
readFile raises EIO instead of returning nil; added system.writeFile
Diffstat (limited to 'lib/pure/pegs.nim')
-rwxr-xr-xlib/pure/pegs.nim12
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim
index 988e510e3..b7469f65b 100755
--- a/lib/pure/pegs.nim
+++ b/lib/pure/pegs.nim
@@ -947,18 +947,10 @@ proc transformFile*(infile, outfile: string,
                     subs: openArray[tuple[pattern: TPeg, repl: string]]) {.
                     rtl, extern: "npegs$1".} =
   ## reads in the file `infile`, performs a parallel replacement (calls
-  ## `parallelReplace`) and writes back to `outfile`. Calls ``quit`` if an
+  ## `parallelReplace`) and writes back to `outfile`. Raises ``EIO`` if an
   ## error occurs. This is supposed to be used for quick scripting.
   var x = readFile(infile)
-  if not isNil(x):
-    var f: TFile
-    if open(f, outfile, fmWrite):
-      write(f, x.parallelReplace(subs))
-      close(f)
-    else:
-      quit("cannot open for writing: " & outfile)
-  else:
-    quit("cannot open for reading: " & infile)
+  writeFile(outfile, x.parallelReplace(subs))
   
 iterator split*(s: string, sep: TPeg): string =
   ## Splits the string `s` into substrings.