about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-16 18:30:03 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-16 18:30:03 +0100
commita3b2d9189f3b25c7cf79985beac843cc46c37cfc (patch)
tree7b371adff64309f98edcf8115eba6461a9c3bce0 /src
parent3f2bc1069142ae13f9991102a0c01cd1291b08e8 (diff)
downloadchawan-a3b2d9189f3b25c7cf79985beac843cc46c37cfc.tar.gz
strwidth & url fixes
* actually search Combining for isCombining
* fix searchInMap
* fix cmpRange of url
Diffstat (limited to 'src')
-rw-r--r--src/types/url.nim6
-rw-r--r--src/utils/map.nim6
-rw-r--r--src/utils/strwidth.nim2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/types/url.nim b/src/types/url.nim
index 0f65e727..ee3f168e 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -250,10 +250,10 @@ type u32pair {.packed.} = object
   b: uint32
 
 func cmpRange(x: u32pair, y: uint32): int =
-  if x.a < y:
-    return -1
-  elif x.b > y:
+  if x.a > y:
     return 1
+  elif x.b < y:
+    return -1
   return 0
 
 func processIdna(str: string, checkhyphens, checkbidi, checkjoiners,
diff --git a/src/utils/map.nim b/src/utils/map.nim
index 2a3515a1..620dec58 100644
--- a/src/utils/map.nim
+++ b/src/utils/map.nim
@@ -11,10 +11,10 @@ func isInMap*[U, T](a: openArray[(U, T)], u: U): bool =
 
 func isInRange*[U](a: openArray[(U, U)], u: U): bool =
   let res = binarySearch(a, u, proc(x: (U, U), y: U): int =
-    if x[0] < y:
-      -1
-    elif x[1] > y:
+    if x[0] > y:
       1
+    elif x[1] < y:
+      -1
     else:
       0
   )
diff --git a/src/utils/strwidth.nim b/src/utils/strwidth.nim
index bcf9d034..a27cb8b1 100644
--- a/src/utils/strwidth.nim
+++ b/src/utils/strwidth.nim
@@ -98,7 +98,7 @@ func isDoubleWidthAmbiguousHigh(r: Rune): bool =
   return r.isDoubleWidthHigh()
 
 func isCombining(r: Rune): bool =
-  return DoubleWidthAmbiguousRanges.isInRange(uint32(r))
+  return Combining.isInRange(uint32(r))
 
 # Lookup tables for characters on the BMP. This "only" takes up 8k of space
 # per table, as opposed to the 135k that storing all characters would require.