summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/pure/os.nim3
-rwxr-xr-xlib/system.nim18
-rwxr-xr-xlib/system/sysio.nim10
3 files changed, 25 insertions, 6 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 229fad441..987662975 100755
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -861,7 +861,7 @@ iterator walkDir*(dir: string): tuple[kind: TPathComponent, path: string] =
         if y != "." and y != "..":
           var s: TStat
           y = dir / y
-          if stat(y, s) < 0'i32: break
+          if lstat(y, s) < 0'i32: break
           var k = pcFile
           if S_ISDIR(s.st_mode): k = pcDir
           if S_ISLNK(s.st_mode): k = succ(k)
@@ -1245,3 +1245,4 @@ proc findExe*(exe: string): string =
   result = ""
 
 {.pop.}
+
diff --git a/lib/system.nim b/lib/system.nim
index e6ef4fa6f..d632b7367 100755
--- a/lib/system.nim
+++ b/lib/system.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.
@@ -247,6 +247,14 @@ proc sizeof*[T](x: T): natural {.magic: "SizeOf", noSideEffect.}
   ## that one never needs to know ``x``'s size. As a special semantic rule,
   ## ``x`` may also be a type identifier (``sizeof(int)`` is valid).
 
+proc `<`*[T](x: ordinal[T]): T {.magic: "UnaryLt", noSideEffect.}
+  ## unary ``<`` that can be used for nice looking excluding ranges:
+  ## 
+  ## .. code-block:: nimrod
+  ##   for i in 0 .. <10: echo i
+  ##
+  ## Semantically this is the same as ``pred``. 
+
 proc succ*[T](x: ordinal[T], y = 1): T {.magic: "Succ", noSideEffect.}
   ## returns the ``y``-th successor of the value ``x``. ``T`` has to be
   ## an ordinal type. If such a value does not exist, ``EOutOfRange`` is raised
@@ -1017,11 +1025,11 @@ iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
     yield res
     dec(res, step)
 
-iterator countup*[T](a, b: T, step = 1): T {.inline.} =
+iterator countup*[S, T](a: S, b: T, step = 1): T {.inline.} =
   ## Counts from ordinal value `a` up to `b` with the given
-  ## step count. `T` may be any ordinal type, `step` may only
+  ## step count. `S`, `T` may be any ordinal type, `step` may only
   ## be positive.
-  var res = a
+  var res: T = a
   while res <= b:
     yield res
     inc(res, step)
@@ -1459,6 +1467,8 @@ when not defined(EcmaScript) and not defined(NimrodVM):
 
   proc write*(f: TFile, r: float)
   proc write*(f: TFile, i: int)
+  proc write*(f: TFile, i: biggestInt)
+  proc write*(f: TFile, r: biggestFloat)
   proc write*(f: TFile, s: string)
   proc write*(f: TFile, b: Bool)
   proc write*(f: TFile, c: char)
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index e342296c7..80d9b1495 100755
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#        (c) Copyright 2011 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -59,11 +59,19 @@ proc write(f: TFile, i: int) =
     fprintf(f, "%lld", i)
   else:
     fprintf(f, "%ld", i)
+
+proc write(f: TFile, i: biggestInt) = 
+  when sizeof(biggestint) == 8:
+    fprintf(f, "%lld", i)
+  else:
+    fprintf(f, "%ld", i)
     
 proc write(f: TFile, b: bool) =
   if b: write(f, "true")
   else: write(f, "false")
 proc write(f: TFile, r: float) = fprintf(f, "%g", r)
+proc write(f: TFile, r: biggestFloat) = fprintf(f, "%g", r)
+
 proc write(f: TFile, c: Char) = putc(c, f)
 proc write(f: TFile, a: openArray[string]) =
   for x in items(a): write(f, x)