My present version is:
static int dolibrary (lua_State *L, const char *name) {
int status;
char *eq = strchr(name,'=');
lua_getglobal(L, "require");
if (eq) lua_pushstring(L, eq+1);
else lua_pushstring(L, name);
status = docall(L, 1, 1); /* call 'require(name)' */
if (status == LUA_OK) {
if (eq) *eq = 0;
lua_setglobal(L, name); /* global[name] = require return */
if (eq) *eq = '=';
}
return report(L, status);
}
Luiz has neither approved nor rejected the temporary modification of
a character inside a "const char*", but the compiler is happy :-)