summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorOscar Campbell <oscar@campbell.nu>2015-05-31 01:31:06 +0200
committerOscar Campbell <oscar@campbell.nu>2015-05-31 01:31:06 +0200
commit1b4db5a34caf301995b3c08eb9a1e3b75c54a9ba (patch)
treeb9bcf3444852500625b06d5b83fee615189a8c5c /lib/pure
parent6820b2fea919c033405e7e204343fddd947c2ef3 (diff)
downloadNim-1b4db5a34caf301995b3c08eb9a1e3b75c54a9ba.tar.gz
Implement #2811 - Unicode en-dash (U+2013) as hump/snake alt.
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/hashes.nim12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim
index 2ce8ac796..c6af8f918 100644
--- a/lib/pure/hashes.nim
+++ b/lib/pure/hashes.nim
@@ -38,7 +38,7 @@
 ##    result = !$h
 
 import
-  strutils
+  strutils, etcpriv
 
 type
   THash* = int ## a hash value; hash tables using these values should
@@ -124,13 +124,21 @@ proc hash*(x: string): THash =
 proc hashIgnoreStyle*(x: string): THash =
   ## efficient hashing of strings; style is ignored
   var h: THash = 0
-  for i in 0..x.len-1:
+  var i = 0
+  let xLen = x.len
+  while i < xLen:
     var c = x[i]
     if c == '_':
+      inc(i)
       continue                # skip _
+    if isMagicIdentSeparatorRune(cstring(x), i):
+      inc(i, magicIdentSeparatorRuneByteWidth)
+      continue                # skip 'ยท' (unicode middle dot)
     if c in {'A'..'Z'}:
       c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
     h = h !& ord(c)
+    inc(i)
+
   result = !$h
 
 proc hashIgnoreCase*(x: string): THash =