File: _strict.lua

package info (click to toggle)
lua-posix 36.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,720 kB
  • sloc: ansic: 5,462; makefile: 21; sh: 6
file content (35 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--[[
 POSIX library for Lua 5.1, 5.2, 5.3 & 5.4.
 Copyright (C) 2014-2025 Gary V. Vaughan
]]
--[[--
 Private argument checking helpers.

 Undocumented internal helpers for strict environment wrapping.

 @module posix._strict
]]


local setfenv = rawget(_G, 'setfenv') or function() end


local strict
do
   local ok, _debug = pcall(require, 'std._debug.init')
   if ok and _debug.strict then
      ok, strict = pcall(require, 'std.strict.init')
   end
   if not ok then
      strict = function(env)
         return env
      end
   end
end


return function(env, level)
   env = strict(env)
   setfenv(1+(level or 1), env)
   return env
end