diff options
author | Gianmarco <gim.marcello@gmail.com> | 2024-03-25 10:59:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 10:59:48 +0100 |
commit | 4c38569229ade43d9570f92e08637f2bcd66bdc5 (patch) | |
tree | 06b1c1ab7d6052c0c6e5afcde1e1314c7103d07e /lib | |
parent | 280f877145dffbf74e28605ab3d0dd9afdb1c5b2 (diff) | |
download | Nim-4c38569229ade43d9570f92e08637f2bcd66bdc5.tar.gz |
Change unicode lookup tables to have int32 elements to support platforms where sizeof(int) < 4 (#23433)
Fixes an issue that comes up when using strutils.`%` or any other strutils/strformat feature that uses the unicode lookup tables behind the scenes, on systems where ints are than 32-bit wide. Tested with: ```bash ./koch test cat lib ``` Refer to the discussion in #23125.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/includes/unicode_ranges.nim | 16 | ||||
-rw-r--r-- | lib/pure/unicode.nim | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/pure/includes/unicode_ranges.nim b/lib/pure/includes/unicode_ranges.nim index 74c8c6399..5bb22bd8b 100644 --- a/lib/pure/includes/unicode_ranges.nim +++ b/lib/pure/includes/unicode_ranges.nim @@ -2,7 +2,7 @@ const toLowerRanges = [ - 0x00041, 0x0005A, 532, + 0x00041'i32, 0x0005A, 532, 0x000C0, 0x000D6, 532, 0x000D8, 0x000DE, 532, 0x00189, 0x0018A, 705, @@ -50,7 +50,7 @@ const ] toLowerSinglets = [ - 0x00100, 501, + 0x00100'i32, 501, 0x00102, 501, 0x00104, 501, 0x00106, 501, @@ -663,7 +663,7 @@ const ] toUpperRanges = [ - 0x00061, 0x0007A, 468, + 0x00061'i32, 0x0007A, 468, 0x000E0, 0x000F6, 468, 0x000F8, 0x000FE, 468, 0x0023F, 0x00240, 11315, @@ -712,7 +712,7 @@ const ] toUpperSinglets = [ - 0x000B5, 1243, + 0x000B5'i32, 1243, 0x000FF, 621, 0x00101, 499, 0x00103, 499, @@ -1339,7 +1339,7 @@ const ] toTitleSinglets = [ - 0x001C4, 501, + 0x001C4'i32, 501, 0x001C6, 499, 0x001C7, 501, 0x001C9, 499, @@ -1350,7 +1350,7 @@ const ] alphaRanges = [ - 0x00041, 0x0005A, + 0x00041'i32, 0x0005A, 0x00061, 0x0007A, 0x000C0, 0x000D6, 0x000D8, 0x000F6, @@ -1824,7 +1824,7 @@ const ] alphaSinglets = [ - 0x000AA, + 0x000AA'i32, 0x000B5, 0x000BA, 0x002EC, @@ -1974,7 +1974,7 @@ const ] spaceRanges = [ - 0x00009, 0x0000D, + 0x00009'i32, 0x0000D, 0x00020, 0x00020, 0x00085, 0x00085, 0x000A0, 0x000A0, diff --git a/lib/pure/unicode.nim b/lib/pure/unicode.nim index 4b557e16e..f329aa1e3 100644 --- a/lib/pure/unicode.nim +++ b/lib/pure/unicode.nim @@ -464,7 +464,7 @@ proc `==`*(a, b: Rune): bool = include "includes/unicode_ranges" -proc binarySearch(c: RuneImpl, tab: openArray[int], len, stride: int): int = +proc binarySearch(c: RuneImpl, tab: openArray[int32], len, stride: int): int = var n = len var t = 0 while n > 1: |