From f051c0952e5fa4c1373dc1410c8da8c65ff7b9fc Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Wed, 17 Jul 2024 20:11:00 +0300 Subject: teal bug --- src/luarocks/core/util.tl | 9 +++++++++ src/luarocks/path.tl | 21 ++++++++++----------- src/luarocks/util.tl | 33 +++++++++++++-------------------- 3 files changed, 32 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/luarocks/core/util.tl b/src/luarocks/core/util.tl index 30461566..e278ebf0 100644 --- a/src/luarocks/core/util.tl +++ b/src/luarocks/core/util.tl @@ -117,6 +117,15 @@ function util.show_table(t: {any:any}, tname: string, top_indent: string): strin return cart .. autoref end +--- Produce a Lua pattern that matches precisely the given string +-- (this is suitable to be concatenating to other patterns, +-- so it does not include beginning- and end-of-string markers (^$) +-- @param s string: The input string +-- @return string: The equivalent pattern +function util.matchquote(s: string): string + return (s:gsub("[?%-+*%[%].%%()$^]","%%%1")) +end + --- Merges contents of src on top of dst's contents -- (i.e. if an key from src already exists in dst, replace it). -- @param dst Destination table, which will receive src's contents. diff --git a/src/luarocks/path.tl b/src/luarocks/path.tl index 93fb6aae..4bf2e47c 100644 --- a/src/luarocks/path.tl +++ b/src/luarocks/path.tl @@ -6,7 +6,7 @@ local cfg = require("luarocks.core.cfg") local core = require("luarocks.core.path") local dir = require("luarocks.dir") --- local util = require("luarocks.util") --! crashes teal +local util = require("luarocks.core.util") local type Tree = cfg.Tree @@ -28,6 +28,14 @@ path.deploy_lib_dir = core.deploy_lib_dir path.map_trees = core.map_trees path.rocks_tree_to_string = core.rocks_tree_to_string +function path.root_dir(tree: string | Tree): string + if tree is string then + return tree + else + return tree.root + end +end + --- Infer rockspec filename from a rock filename. -- @param rock_name string: Pathname of a rock file. -- @return string: Filename of the rockspec, without path. @@ -37,16 +45,7 @@ function path.rockspec_name_from_rock(rock_name: string): string end function path.root_from_rocks_dir(rocks_dir: string): string - return "" --! temp - -- return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$") --! only depends here on util -end - -function path.root_dir(tree: string | Tree): string - if tree is string then - return tree - else - return tree.root - end + return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$") end function path.deploy_bin_dir(tree: string | Tree): string diff --git a/src/luarocks/util.tl b/src/luarocks/util.tl index 77d6f5c4..aff245b8 100644 --- a/src/luarocks/util.tl +++ b/src/luarocks/util.tl @@ -19,6 +19,7 @@ local record util printerr: function(...: string | number) warning: function(string) keys: function({K : V}): {K} + matchquote: function(string): string record Fn fn: function(...: any) @@ -63,16 +64,17 @@ local record util end end --- util.cleanup_path = core.cleanup_path --tlcheck acting funny --- util.split_string = core.split_string --- util.sortedpairs = core.sortedpairs --- util.deep_merge = core.deep_merge --- util.deep_merge_under = core.deep_merge_under --- util.popen_read = core.popen_read --- util.show_table = core.show_table --- util.printerr = core.printerr --- util.warning = core.warning --- util.keys = core.keys +util.cleanup_path = core.cleanup_path --tlcheck acting funny +util.split_string = core.split_string +util.sortedpairs = core.sortedpairs +util.deep_merge = core.deep_merge +util.deep_merge_under = core.deep_merge_under +util.popen_read = core.popen_read +util.show_table = core.show_table +util.printerr = core.printerr +util.warning = core.warning +util.keys = core.keys +util.matchquote = core.matchquote local type Fn = util.Fn local type Rockspec = util.Rockspec @@ -122,15 +124,6 @@ function util.run_scheduled_functions() end end ---- Produce a Lua pattern that matches precisely the given string --- (this is suitable to be concatenating to other patterns, --- so it does not include beginning- and end-of-string markers (^$) --- @param s string: The input string --- @return string: The equivalent pattern -function util.matchquote(s: string): string - return (s:gsub("[?%-+*%[%].%%()$^]","%%%1")) -end - local var_format_pattern = "%$%((%a[%a%d_]+)%)" -- Check if a set of needed variables are referenced @@ -305,7 +298,7 @@ end function util.announce_install(rockspec: Rockspec) local cfg = require("luarocks.core.cfg") - local path = require("luarocks.path") + local path = require("luarocks.core.path") --TEAL BUG? local suffix = "" if rockspec.description and rockspec.description.license then -- cgit v1.2.3-55-g6feb