summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-05-08 09:23:50 +0200
committerAraq <rumpf_a@web.de>2011-05-08 09:23:50 +0200
commit1893f4101a59497d9c5713068ad396efdddb8574 (patch)
treeb7fc49c51b492dd5db17b777dd28f26673ab99c2 /lib
parent0db6f3c00f7975d49b5d4d1c061d6f29162176af (diff)
downloadNim-1893f4101a59497d9c5713068ad396efdddb8574.tar.gz
bugfix: don't change OSError()'s behaviour
Diffstat (limited to 'lib')
-rwxr-xr-xlib/pure/os.nim17
-rwxr-xr-xlib/pure/osproc.nim8
2 files changed, 11 insertions, 14 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 81a038de7..7847fa332 100755
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#        (c) Copyright 2011 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -148,8 +148,9 @@ const
     ## for example, the '.' in ``os.nim``.
 
 proc OSErrorMsg*(): string {.rtl, extern: "nos$1".} =
-  ## Retrieves the operating system's error flag, ``errno`` on Posix and 
-  ## ``GetLastError`` on Windows.
+  ## Retrieves the operating system's error flag, ``errno``.
+  ## On Windows ``GetLastError`` is checked before ``errno``.
+  ## Returns "" if no error occured.
   result = ""
   when defined(Windows):
     var err = GetLastError()
@@ -161,9 +162,8 @@ proc OSErrorMsg*(): string {.rtl, extern: "nos$1".} =
         if msgbuf != nil:
           LocalFree(msgbuf)
         result = m
-  else:
-    if errno != 0'i32:
-      result = $os.strerror(errno)
+  if errno != 0'i32:
+    result = $os.strerror(errno)
 
 proc OSError*(msg: string = "") {.noinline, rtl, extern: "nos$1".} =
   ## raises an EOS exception with the given message ``msg``.
@@ -173,10 +173,7 @@ proc OSError*(msg: string = "") {.noinline, rtl, extern: "nos$1".} =
   ## If no error flag is set, the message ``unknown OS error`` is used.
   if len(msg) == 0:
     var m = OSErrorMsg()
-    if m != "":
-      raise newException(EOS, m)
-    else:
-      raise newException(EOS, "unknown OS error")
+    raise newException(EOS, if m.len > 0: m else: "unknown OS error")
   else:
     raise newException(EOS, msg)
 
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index a539e5f39..a4a854c49 100755
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -200,10 +200,10 @@ proc execProcesses*(cmds: openArray[string],
       result = max(waitForExit(p), result)
 
 proc select*(readfds: var seq[PProcess], timeout = 500): int
-  ## select with a sensible Nimrod interface. `timeout` is in miliseconds.
-  ## Specify -1 for no timeout. Returns the number of file handles that are
-  ## ready. The processes that are ready to be read from are removed from 
-  ## `readfds`.
+  ## `select` with a sensible Nimrod interface. `timeout` is in miliseconds.
+  ## Specify -1 for no timeout. Returns the number of processes that are
+  ## ready to read from. The processes that are ready to be read from are
+  ## removed from `readfds`.
 
 when not defined(useNimRtl):
   proc execProcess(command: string,