| 536 | |
| 537 | |
| 538 | static int searcher_Croot (lua_State *L) { |
| 539 | const char *filename; |
| 540 | const char *name = luaL_checkstring(L, 1); |
| 541 | const char *p = strchr(name, '.'); |
| 542 | int stat; |
| 543 | if (p == NULL) return 0; /* is root */ |
| 544 | lua_pushlstring(L, name, p - name); |
| 545 | filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP); |
| 546 | if (filename == NULL) return 1; /* root not found */ |
| 547 | if ((stat = loadfunc(L, filename, name)) != 0) { |
| 548 | if (stat != ERRFUNC) |
| 549 | return checkload(L, 0, filename); /* real error */ |
| 550 | else { /* open function not found */ |
| 551 | lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename); |
| 552 | return 1; |
| 553 | } |
| 554 | } |
| 555 | lua_pushstring(L, filename); /* will be 2nd argument to module */ |
| 556 | return 2; |
| 557 | } |
| 558 | |
| 559 | |
| 560 | static int searcher_preload (lua_State *L) { |
nothing calls this directly
no test coverage detected