summary refs log tree commit diff stats
path: root/lib/core/macros.nim
diff options
context:
space:
mode:
authorChris Heller <chris.heller@greyheller.com>2015-03-03 09:29:38 -0800
committerChris Heller <chris.heller@greyheller.com>2015-03-03 09:29:38 -0800
commit0553758ebd66ae7f10dca46f594d1503192ebaa6 (patch)
tree3c559e95c4523a386c72d574c0a7a58002caa0e8 /lib/core/macros.nim
parentb54dfbce1664a6f0c9deb845d94ce173e5e0831d (diff)
downloadNim-0553758ebd66ae7f10dca46f594d1503192ebaa6.tar.gz
Clone the implementation of cmpIgnoreStyle into macros.nim from typeinfo.nim so that we get rid of any imports in the core modules
Diffstat (limited to 'lib/core/macros.nim')
-rw-r--r--lib/core/macros.nim18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 19c10fb93..0888a8767 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -339,8 +339,6 @@ proc quote*(bl: stmt, op = "``"): PNimrodNode {.magic: "QuoteAst", noSideEffect.
   ##       if not `ex`:
   ##         echo `info` & ": Check failed: " & `expString`
 
-from strutils import cmpIgnoreStyle
-
 proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} =
   ## checks that `n` is of kind `k`. If this is not the case,
   ## compilation aborts with an error message. This is useful for writing
@@ -776,6 +774,22 @@ proc copy*(node: PNimrodNode): PNimrodNode {.compileTime.} =
   ## An alias for copyNimTree().
   return node.copyNimTree()
 
+proc cmpIgnoreStyle(a, b: cstring): int {.noSideEffect.} =
+  proc toLower(c: char): char {.inline.} =
+    if c in {'A'..'Z'}: result = chr(ord(c) + (ord('a') - ord('A')))
+    else: result = c
+  var i = 0
+  var j = 0
+  while true:
+    while a[i] == '_': inc(i)
+    while b[j] == '_': inc(j) # BUGFIX: typo
+    var aa = toLower(a[i])
+    var bb = toLower(b[j])
+    result = ord(aa) - ord(bb)
+    if result != 0 or aa == '\0': break
+    inc(i)
+    inc(j)
+
 proc eqIdent* (a, b: string): bool = cmpIgnoreStyle(a, b) == 0
   ## Check if two idents are identical.