summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-12-24 00:21:22 +0100
committerAraq <rumpf_a@web.de>2013-12-24 00:21:22 +0100
commitfeb9af48f1600ce814bc3b62765894ba503ec108 (patch)
treecf3282dc69888f0816d70e0ed5ed3efba99fbb32 /lib
parent32ef1f8f323044c0d92f1beef396ce3223a96231 (diff)
downloadNim-feb9af48f1600ce814bc3b62765894ba503ec108.tar.gz
NoFakeVars progress
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/os.nim29
-rw-r--r--lib/pure/sockets.nim2
-rw-r--r--lib/system/ansi_c.nim15
-rw-r--r--lib/system/sysio.nim4
4 files changed, 35 insertions, 15 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 91893d169..2e15587f4 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -165,8 +165,12 @@ else: # UNIX-like operating system
     DynlibFormat* = when defined(macosx): "lib$1.dylib" else: "lib$1.so"
 
 when defined(posix):
-  var
-    pathMax {.importc: "PATH_MAX", header: "<stdlib.h>".}: cint
+  when NoFakeVars:
+    const pathMax = 5000 # doesn't matter really. The concept of PATH_MAX
+                         # doesn't work anymore on modern OSes.
+  else:
+    var
+      pathMax {.importc: "PATH_MAX", header: "<stdlib.h>".}: cint
 
 const
   ExtSep* = '.'
@@ -517,7 +521,7 @@ proc `/` * (head, tail: string): string {.noSideEffect.} =
   ##   assert "" / "lib" == "lib"
   ##   assert "" / "/lib" == "/lib"
   ##   assert "usr/" / "/lib" == "usr/lib"
-  return JoinPath(head, tail)
+  return joinPath(head, tail)
 
 proc splitPath*(path: string): tuple[head, tail: string] {.
   noSideEffect, rtl, extern: "nos$1".} =
@@ -527,11 +531,11 @@ proc splitPath*(path: string): tuple[head, tail: string] {.
   ## Examples:
   ##
   ## .. code-block:: nimrod
-  ##   SplitPath("usr/local/bin") -> ("usr/local", "bin")
-  ##   SplitPath("usr/local/bin/") -> ("usr/local/bin", "")
-  ##   SplitPath("bin") -> ("", "bin")
-  ##   SplitPath("/bin") -> ("", "bin")
-  ##   SplitPath("") -> ("", "")
+  ##   splitPath("usr/local/bin") -> ("usr/local", "bin")
+  ##   splitPath("usr/local/bin/") -> ("usr/local/bin", "")
+  ##   splitPath("bin") -> ("", "bin")
+  ##   splitPath("/bin") -> ("", "bin")
+  ##   splitPath("") -> ("", "")
   var sepPos = -1
   for i in countdown(len(path)-1, 0):
     if path[i] in {dirsep, altsep}:
@@ -957,7 +961,10 @@ proc moveFile*(source, dest: string) {.rtl, extern: "nos$1",
     raise newException(EOS, $strerror(errno))
 
 when not defined(ENOENT) and not defined(Windows):
-  var ENOENT {.importc, header: "<errno.h>".}: cint
+  when NoFakeVars:
+    const ENOENT = cint(2) # 2 on most systems including Solaris
+  else:
+    var ENOENT {.importc, header: "<errno.h>".}: cint
 
 when defined(Windows):
   when useWinUnicode:
@@ -1014,7 +1021,7 @@ when defined(windows):
     proc strEnd(cstr: wideCString, c = 0'i32): wideCString {.
       importc: "wcschr", header: "<string.h>".}
   else:
-    proc strEnd(cstr: CString, c = 0'i32): CString {.
+    proc strEnd(cstr: cstring, c = 0'i32): cstring {.
       importc: "strchr", header: "<string.h>".}
 
   proc getEnvVarsC() =
@@ -1319,7 +1326,7 @@ proc copyDir*(source, dest: string) {.rtl, extern: "nos$1",
       copyFile(path, dest / noSource)
     of pcDir:
       copyDir(path, dest / noSource)
-    else: nil
+    else: discard
 
 proc parseCmdLine*(c: string): seq[string] {.
   noSideEffect, rtl, extern: "nos$1".} =
diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim
index 66bb1e6a9..684def978 100644
--- a/lib/pure/sockets.nim
+++ b/lib/pure/sockets.nim
@@ -131,7 +131,7 @@ type
 
   ETimeout* = object of ESynch
 
-let
+const
   InvalidSocket*: TSocket = nil ## invalid socket
 
 when defined(windows):
diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim
index 25b6d9c48..398656d0a 100644
--- a/lib/system/ansi_c.nim
+++ b/lib/system/ansi_c.nim
@@ -49,6 +49,14 @@ when not defined(SIGINT):
         SIGINT = cint(2)

         SIGSEGV = cint(11)

         SIGTERM = cint(15)
+    elif defined(macosx):
+      const
+        SIGABRT = cint(6)
+        SIGFPE = cint(8)
+        SIGILL = cint(4)
+        SIGINT = cint(2)
+        SIGSEGV = cint(11)
+        SIGTERM = cint(15)
     else:
       {.error: "SIGABRT not ported to your platform".}
   else:
@@ -60,9 +68,10 @@ when not defined(SIGINT):
       SIGILL {.importc: "SIGILL", nodecl.}: cint
 
 when defined(macosx):
-  var
-    SIGBUS {.importc: "SIGBUS", nodecl.}: cint
-      # hopefully this does not lead to new bugs
+  when NoFakeVars:
+    const SIGBUS = cint(10)
+  else:
+    var SIGBUS {.importc: "SIGBUS", nodecl.}: cint
 else:
   template SIGBUS: expr = SIGSEGV
 
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 23f4e874c..8d9400a7d 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -50,6 +50,10 @@ when NoFakeVars:
     const
       IOFBF = cint(0)

       IONBF = cint(4)
+  elif defined(macosx):
+    const
+      IOFBF = cint(0)
+      IONBF = cint(2)
   else:
     {.error: "IOFBF not ported to your platform".}
 else: