| 498 | #include <dlfcn.h> |
| 499 | |
| 500 | static void lua_initreadline (lua_State *L) { |
| 501 | void *lib = dlopen(LUA_READLINELIB, RTLD_NOW | RTLD_LOCAL); |
| 502 | if (lib == NULL) |
| 503 | lua_warning(L, "library '" LUA_READLINELIB "' not found", 0); |
| 504 | else { |
| 505 | const char **name = cast(const char**, dlsym(lib, "rl_readline_name")); |
| 506 | if (name != NULL) |
| 507 | *name = "lua"; |
| 508 | l_readline = cast(l_readlineT, cast_func(dlsym(lib, "readline"))); |
| 509 | l_addhist = cast(l_addhistT, cast_func(dlsym(lib, "add_history"))); |
| 510 | if (l_readline == NULL) |
| 511 | lua_warning(L, "unable to load 'readline'", 0); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | #else /* }{ */ |
| 516 | /* no dlopen or LUA_READLINELIB undefined */ |
no test coverage detected