various bugfixes for generics; added generic sort proc
This commit is contained in:
parent
f93ca8e42a
commit
e424e13bd9
18 changed files with 392 additions and 113 deletions
|
|
@ -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:
|
||||
##
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue