diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2022-02-16 18:05:24 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2022-02-16 18:05:24 -0300 |
commit | e31102e8c9de467fa21e3f73c74c6a782648b2a5 (patch) | |
tree | 7e83cf90fd0f274a9ed92b3731514d2d7fd2e7d4 /src | |
parent | 99b1ba350d3c933322db541f86ee7a5f70995e30 (diff) | |
download | luarocks-e31102e8c9de467fa21e3f73c74c6a782648b2a5.tar.gz luarocks-e31102e8c9de467fa21e3f73c74c6a782648b2a5.tar.bz2 luarocks-e31102e8c9de467fa21e3f73c74c6a782648b2a5.zip |
no need for a make_shallow_copy utility function
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/core/cfg.lua | 7 | ||||
-rw-r--r-- | src/luarocks/core/util.lua | 13 | ||||
-rw-r--r-- | src/luarocks/util.lua | 8 |
3 files changed, 11 insertions, 17 deletions
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 264c88b6..f0e5aa93 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -77,11 +77,16 @@ local load_config_file | |||
77 | do | 77 | do |
78 | -- Create global environment for the config files; | 78 | -- Create global environment for the config files; |
79 | local function env_for_config_file(cfg, platforms) | 79 | local function env_for_config_file(cfg, platforms) |
80 | local platforms_copy = {} | ||
81 | for k,v in pairs(platforms) do | ||
82 | platforms_copy[k] = v | ||
83 | end | ||
84 | |||
80 | local e | 85 | local e |
81 | e = { | 86 | e = { |
82 | home = cfg.home, | 87 | home = cfg.home, |
83 | lua_version = cfg.lua_version, | 88 | lua_version = cfg.lua_version, |
84 | platforms = util.make_shallow_copy(platforms), | 89 | platforms = platforms_copy, |
85 | processor = cfg.target_cpu, -- remains for compat reasons | 90 | processor = cfg.target_cpu, -- remains for compat reasons |
86 | target_cpu = cfg.target_cpu, -- replaces `processor` | 91 | target_cpu = cfg.target_cpu, -- replaces `processor` |
87 | os_getenv = os.getenv, | 92 | os_getenv = os.getenv, |
diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index 67a10b42..26e78369 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua | |||
@@ -28,19 +28,6 @@ function util.popen_read(cmd, spec) | |||
28 | return out or "" | 28 | return out or "" |
29 | end | 29 | end |
30 | 30 | ||
31 | --- Create a new shallow copy of a table: a new table with | ||
32 | -- the same keys and values. Keys point to the same objects as | ||
33 | -- the original table (ie, does not copy recursively). | ||
34 | -- @param tbl table: the input table | ||
35 | -- @return table: a new table with the same contents. | ||
36 | function util.make_shallow_copy(tbl) | ||
37 | local copy = {} | ||
38 | for k,v in pairs(tbl) do | ||
39 | copy[k] = v | ||
40 | end | ||
41 | return copy | ||
42 | end | ||
43 | |||
44 | --- | 31 | --- |
45 | -- Formats tables with cycles recursively to any depth. | 32 | -- Formats tables with cycles recursively to any depth. |
46 | -- References to other tables are shown as values. | 33 | -- References to other tables are shown as values. |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index bb474ff0..fa3a628e 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -90,14 +90,16 @@ local var_format_pattern = "%$%((%a[%a%d_]+)%)" | |||
90 | -- needed variables. | 90 | -- needed variables. |
91 | -- @param msg string: the warning message to display. | 91 | -- @param msg string: the warning message to display. |
92 | function util.warn_if_not_used(var_defs, needed_set, msg) | 92 | function util.warn_if_not_used(var_defs, needed_set, msg) |
93 | needed_set = core.make_shallow_copy(needed_set) | 93 | local seen = {} |
94 | for _, val in pairs(var_defs) do | 94 | for _, val in pairs(var_defs) do |
95 | for used in val:gmatch(var_format_pattern) do | 95 | for used in val:gmatch(var_format_pattern) do |
96 | needed_set[used] = nil | 96 | seen[used] = true |
97 | end | 97 | end |
98 | end | 98 | end |
99 | for var, _ in pairs(needed_set) do | 99 | for var, _ in pairs(needed_set) do |
100 | util.warning(msg:format(var)) | 100 | if not seen[var] then |
101 | util.warning(msg:format(var)) | ||
102 | end | ||
101 | end | 103 | end |
102 | end | 104 | end |
103 | 105 | ||