Skip to content

Commit

Permalink
Fixes an issue where importing the strutils module, or any other im…
Browse files Browse the repository at this point in the history
…porting the `strutils` module, ends up with a compile time error on platforms where ints are less then 32-bit wide.
  • Loading branch information
Abathargh committed Dec 28, 2023
1 parent 1324d2e commit ee5c6a7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pure/unicode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,12 @@ proc cmpRunesIgnoreCase*(a, b: openArray[char]): int {.rtl, extern: "nuc$1".} =
# slow path:
fastRuneAt(a, i, ar)
fastRuneAt(b, j, br)
result = RuneImpl(toLower(ar)) - RuneImpl(toLower(br))
when sizeof(int) < 4:
const lo = low(int).int32
const hi = high(int).int32
result = clamp(RuneImpl(toLower(ar)) - RuneImpl(toLower(br)), lo, hi).int
else:
result = RuneImpl(toLower(ar)) - RuneImpl(toLower(br))
if result != 0: return
result = a.len - b.len

Expand Down

0 comments on commit ee5c6a7

Please sign in to comment.