summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andreas-desktop>2010-01-29 01:50:39 +0100
committerAndreas Rumpf <andreas@andreas-desktop>2010-01-29 01:50:39 +0100
commitecb5a8db9997dd9b986e7b5649af5b45561f871b (patch)
treea48a6a770b7319b9d9508299031c9f799e976e2e /lib/system
parent5eea125ba73a5768a264c5d4fc8cc55fba8d5fe8 (diff)
downloadNim-ecb5a8db9997dd9b986e7b5649af5b45561f871b.tar.gz
bugfixes for the high-level postgreSQL wrapper
Diffstat (limited to 'lib/system')
-rwxr-xr-xlib/system/excpt.nim6
-rwxr-xr-xlib/system/sysio.nim5
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index 01d98c205..4d7b41da2 100755
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -194,13 +194,15 @@ proc signalHandler(sig: cint) {.exportc: "signalHandler", noconv.} =
   rawWriteStackTrace(buf)
 
   if s == SIGINT: add(buf, "SIGINT: Interrupted by Ctrl-C.\n")
-  elif s == SIGSEGV: add(buf, "SIGSEGV: Illegal storage access.\n")
+  elif s == SIGSEGV: 
+    add(buf, "SIGSEGV: Illegal storage access. (Attempt to read from nil?)\n")
   elif s == SIGABRT:
     if dbgAborting: return # the debugger wants to abort
     add(buf, "SIGABRT: Abnormal termination.\n")
   elif s == SIGFPE: add(buf, "SIGFPE: Arithmetic error.\n")
   elif s == SIGILL: add(buf, "SIGILL: Illegal operation.\n")
-  elif s == SIGBUS: add(buf, "SIGBUS: Illegal storage access.\n")
+  elif s == SIGBUS: 
+    add(buf, "SIGBUS: Illegal storage access. (Attempt to read from nil?)\n")
   else: add(buf, "unknown signal\n")
   writeToStdErr(buf)
   dbgAborting = True # play safe here...
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 8b6d0e285..3c99a5eed 100755
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -51,7 +51,6 @@ proc readLine(f: TFile): string =
   result = ""
   rawReadLine(f, result)
 
-proc write(f: TFile, s: string) = fputs(s, f)
 proc write(f: TFile, i: int) = 
   when sizeof(int) == 8:
     fprintf(f, "%lld", i)
@@ -167,6 +166,10 @@ proc writeChars(f: TFile, a: openarray[char], start, len: int): int =
 proc writeBuffer(f: TFile, buffer: pointer, len: int): int =
   result = fwrite(buffer, 1, len, f)
 
+proc write(f: TFile, s: string) =
+  if writeBuffer(f, cstring(s), s.len) != s.len:
+    raise newException(EIO, "cannot write string to file")
+
 proc setFilePos(f: TFile, pos: int64) =
   if fseek(f, clong(pos), 0) != 0:
     raise newException(EIO, "cannot set file position")