| 399 | |
| 400 | |
| 401 | static const char *searchpath(lua_State *L, const char *name, |
| 402 | const char *path, |
| 403 | const char *sep, |
| 404 | const char *dirsep) { |
| 405 | //if (glua::util::starts_with(name, ADDRESS_CONTRACT_PREFIX)) |
| 406 | // return nullptr; |
| 407 | luaL_Buffer msg; /* to build error message */ |
| 408 | luaL_buffinit(L, &msg); |
| 409 | if (*sep != '\0') /* non-empty separator? */ |
| 410 | name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ |
| 411 | while ((path = pushnexttemplate(L, path)) != nullptr) { // 这步好像改变了lua_real_execute_contract_api函数中的api_name的内容 |
| 412 | const char *filename = luaL_gsub(L, lua_tostring(L, -1), |
| 413 | LUA_PATH_MARK, name); |
| 414 | lua_remove(L, -2); /* remove path template */ |
| 415 | if (readable(filename)) /* does file exist and is readable? */ |
| 416 | return filename; /* return that file name */ |
| 417 | lua_pushfstring(L, "\n\tno file '%s'", filename); |
| 418 | lua_remove(L, -2); // remove file name |
| 419 | luaL_addvalue(&msg); /* concatenate error msg. entry */ |
| 420 | } |
| 421 | luaL_pushresult(&msg); /* create error message */ |
| 422 | return nullptr; /* not found */ |
| 423 | } |
| 424 | |
| 425 | |
| 426 | static int ll_searchpath(lua_State *L) { |
no test coverage detected