| 586 | |
| 587 | |
| 588 | static int searcher_Croot (lua_State *L) { |
| 589 | const char *filename; |
| 590 | const char *name = luaL_checkstring(L, 1); |
| 591 | const char *p = strchr(name, '.'); |
| 592 | int stat; |
| 593 | if (p == NULL) return 0; /* is root */ |
| 594 | lua_pushlstring(L, name, p - name); |
| 595 | filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP); |
| 596 | if (filename == NULL) return 1; /* root not found */ |
| 597 | if ((stat = loadfunc(L, filename, name)) != 0) { |
| 598 | if (stat != ERRFUNC) |
| 599 | return checkload(L, 0, filename); /* real error */ |
| 600 | else { /* open function not found */ |
| 601 | lua_pushfstring(L, "no module '%s' in file '%s'", name, filename); |
| 602 | return 1; |
| 603 | } |
| 604 | } |
| 605 | lua_pushstring(L, filename); /* will be 2nd argument to module */ |
| 606 | return 2; |
| 607 | } |
| 608 | |
| 609 | |
| 610 | static int searcher_preload (lua_State *L) { |
nothing calls this directly
no test coverage detected