Implement #2811 - Unicode en-dash (U+2013) as hump/snake alt.

This commit is contained in:
Oscar Campbell 2015-05-31 01:31:06 +02:00
commit 1b4db5a34c
3 changed files with 29 additions and 7 deletions

View file

@ -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 =