diff --git a/lkpselib.c b/lkpselib.c index 4046550..1b71632 100644 --- a/lkpselib.c +++ b/lkpselib.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -299,6 +300,24 @@ static int lua_kpathsea_var_value(lua_State * L) return 1; } +static int is_absolute(lua_State * L) +{ + const char *path = luaL_checkstring(L, 1); + boolean accept_relative = lua_toboolean(L, 2); + TEST_PROGRAM_NAME_SET; + lua_pushboolean(L, kpse_absolute_p(path, accept_relative)); + return 1; +} + +static int lua_kpathsea_is_absolute(lua_State * L) +{ + kpathsea *kp = (kpathsea *) luaL_checkudata(L, 1, KPATHSEA_METATABLE); + const char *path = luaL_checkstring(L, 2); + boolean accept_relative = lua_toboolean(L, 3); + lua_pushboolean(L, kpathsea_absolute_p(*kp, path, accept_relative)); + return 1; +} + static unsigned find_dpi(const_string s) { unsigned dpi_number = 0; @@ -821,6 +840,7 @@ static const struct luaL_Reg kpselib_m[] = { {"default_texmfcnf", show_texmfcnf}, {"record_input_file", lua_record_input_file}, {"record_output_file", lua_record_output_file}, + {"is_absolute", lua_kpathsea_is_absolute}, {NULL, NULL} /* sentinel */ }; @@ -839,6 +859,7 @@ static const struct luaL_Reg kpselib_l[] = { {"set_maketex", lua_set_maketex}, {"version", lua_kpse_version}, {"default_texmfcnf", show_texmfcnf}, + {"is_absolute", is_absolute}, {NULL, NULL} /* sentinel */ };