about summary refs log tree commit diff stats
path: root/src/types/url.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-05-09 21:57:00 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-09 22:11:30 +0200
commit2453c63b0b12baa9bd78c0a114b58f1c3833e967 (patch)
tree34b37fa375f8500669877ec726afea0ba2ed2d99 /src/types/url.nim
parent200a3784de44b90351f7d9a1da47e85e06ff8e15 (diff)
downloadchawan-2453c63b0b12baa9bd78c0a114b58f1c3833e967.tar.gz
luwrap: replace Nim unicode maps with libunicode
Instead of using the built-in (and outdated, and buggy) tables, we now
use libunicode from QJS.  This shaves some bytes off the executable,
though far less than I had imagined it would.

Also, a surprising effect of this change: because libunicode's tables
aren't glitched out, kanji properly gets classified as alpha.  I found
this greatly annoying because `w' in Japanese text would now jump
through whole sentences.  As a band-aid solution I added an extra
Han category, but I wish we had a more robust solution that could
differentiate between *all* scripts.

TODO: I suspect that separately loading the tables for every rune in
breaksViWordCat is rather inefficient.  Using some context object (at
least per operation) would probably be beneficial.
Diffstat (limited to 'src/types/url.nim')
-rw-r--r--src/types/url.nim13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/types/url.nim b/src/types/url.nim
index 54d6f8ed..abb76f56 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -245,17 +245,6 @@ func endsInNumber(input: string): bool =
       inc i
   return true
 
-type u32pair {.packed.} = object
-  a: uint32
-  b: uint32
-
-func cmpRange(x: u32pair; y: uint32): int =
-  if x.a > y:
-    return 1
-  elif x.b < y:
-    return -1
-  return 0
-
 type
   IDNATableStatus = enum
     itsValid, itsIgnored, itsMapped, itsDeviation, itsDisallowed
@@ -306,7 +295,7 @@ func processIdna(str: string; beStrict: bool): Option[string] =
     of itsDeviation: mapped &= r
     of itsValid: mapped &= r
   if mapped.len == 0: return
-  mapped.mnormalize()
+  mapped = mapped.normalize()
   var cr: CharRange
   {.cast(noSideEffect).}:
     cr_init(addr cr, nil, passRealloc)