summary refs log tree commit diff stats
path: root/lib/pure/strutils.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-03-03 02:01:22 +0100
committerAraq <rumpf_a@web.de>2011-03-03 02:01:22 +0100
commite424e13bd9d05ab3fbcbe3572e49c1bc611a1fc9 (patch)
treee0c60da1e1ddd60d040f02508deb554f687f23aa /lib/pure/strutils.nim
parentf93ca8e42a7c987bf03606319d9dfcc0772684f5 (diff)
downloadNim-e424e13bd9d05ab3fbcbe3572e49c1bc611a1fc9.tar.gz
various bugfixes for generics; added generic sort proc
Diffstat (limited to 'lib/pure/strutils.nim')
-rwxr-xr-xlib/pure/strutils.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index 8d5966670..0673a9588 100755
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -97,14 +97,15 @@ proc normalize*(s: string): string {.noSideEffect, procvar,
       add result, s[i]

 

 proc cmpIgnoreCase*(a, b: string): int {.noSideEffect,

-  rtl, extern: "nsuCmpIgnoreCase".} =

+  rtl, extern: "nsuCmpIgnoreCase", procvar.} =

   ## Compares two strings in a case insensitive manner. Returns:

   ##

   ## | 0 iff a == b

   ## | < 0 iff a < b

   ## | > 0 iff a > b

-  var i = 0

-  while i < a.len and i < b.len:

+  var i = 0
+  var m = min(a.len, b.len)

+  while i < m:

     result = ord(toLower(a[i])) - ord(toLower(b[i]))

     if result != 0: return

     inc(i)

@@ -114,7 +115,7 @@ proc cmpIgnoreCase*(a, b: string): int {.noSideEffect,
                                        # thus we compile without checks here

 

 proc cmpIgnoreStyle*(a, b: string): int {.noSideEffect,

-  rtl, extern: "nsuCmpIgnoreStyle".} =

+  rtl, extern: "nsuCmpIgnoreStyle", procvar.} =

   ## Compares two strings normalized (i.e. case and

   ## underscores do not matter). Returns:

   ##