MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / dolibrary

Function dolibrary

lib/lua/src/lua.c:217–238  ·  view source on GitHub ↗

** Receives 'globname[=modname]' and runs 'globname = require(modname)'. ** If there is no explicit modname and globname contains a '-', cut ** the suffix after '-' (the "version") to make the global name. */

Source from the content-addressed store, hash-verified

215** the suffix after '-' (the "version") to make the global name.
216*/
217static int dolibrary (lua_State *L, char *globname) {
218 int status;
219 char *suffix = NULL;
220 char *modname = strchr(globname, '=');
221 if (modname == NULL) { /* no explicit name? */
222 modname = globname; /* module name is equal to global name */
223 suffix = strchr(modname, *LUA_IGMARK); /* look for a suffix mark */
224 }
225 else {
226 *modname = '\0'; /* global name ends here */
227 modname++; /* module name starts after the '=' */
228 }
229 lua_getglobal(L, "require");
230 lua_pushstring(L, modname);
231 status = docall(L, 1, 1); /* call 'require(modname)' */
232 if (status == LUA_OK) {
233 if (suffix != NULL) /* is there a suffix mark? */
234 *suffix = '\0'; /* remove suffix from global name */
235 lua_setglobal(L, globname); /* globname = require(modname) */
236 }
237 return report(L, status);
238}
239
240
241/*

Callers 1

runargsFunction · 0.85

Calls 5

lua_getglobalFunction · 0.85
lua_pushstringFunction · 0.85
docallFunction · 0.85
lua_setglobalFunction · 0.85
reportFunction · 0.85

Tested by

no test coverage detected