about summary refs log tree commit diff stats
path: root/src/local/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-02 10:56:42 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-02 10:56:42 +0100
commitc9588388d04bb3180c3cfec4359462421c0407f0 (patch)
treeea0de3de960bfb88ae2463c92cf7a3f745f2b63b /src/local/client.nim
parent2fb87f5c609be4d42f71fbd6a9439de47c6d0189 (diff)
downloadchawan-c9588388d04bb3180c3cfec4359462421c0407f0.tar.gz
Get rid of clang 16 workaround
* bindings/quickjs: importc and use correct pointer types
* add constcharp module for when it is unavoidable
Diffstat (limited to 'src/local/client.nim')
-rw-r--r--src/local/client.nim11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/local/client.nim b/src/local/client.nim
index 752012a3..4dc29f24 100644
--- a/src/local/client.nim
+++ b/src/local/client.nim
@@ -1,4 +1,3 @@
-import cstrutils
 import nativesockets
 import net
 import options
@@ -14,6 +13,7 @@ when defined(posix):
 
 import std/exitprocs
 
+import bindings/constcharp
 import bindings/quickjs
 import config/config
 import display/lineedit
@@ -442,13 +442,14 @@ proc headlessLoop(client: Client) =
     client.loader.unregistered.setLen(0)
     client.acceptBuffers()
 
-proc clientLoadJSModule(ctx: JSContext, module_name: cstring,
+proc clientLoadJSModule(ctx: JSContext, module_name: cstringConst,
     opaque: pointer): JSModuleDef {.cdecl.} =
   let global = JS_GetGlobalObject(ctx)
   JS_FreeValue(ctx, global)
   var x: Option[URL]
-  if module_name.startsWith("/") or module_name.startsWith("./") or
-      module_name.startsWith("../"):
+  if module_name[0] == '/' or module_name[0] == '.' and
+      (module_name[1] == '/' or
+      module_name[1] == '.' and module_name[2] == '/'):
     let cur = getCurrentDir()
     x = parseURL($module_name, parseURL("file://" & cur & "/"))
   else:
@@ -458,7 +459,7 @@ proc clientLoadJSModule(ctx: JSContext, module_name: cstring,
     return nil
   try:
     let f = readFile($x.get.path)
-    return finishLoadModule(ctx, f, module_name)
+    return finishLoadModule(ctx, f, cstring(module_name))
   except IOError:
     JS_ThrowTypeError(ctx, "Failed to open file %s", module_name)
     return nil