summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mfluadir/mfluac.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/mfluadir/mfluac.c')
-rw-r--r--Build/source/texk/web2c/mfluadir/mfluac.c92
1 files changed, 61 insertions, 31 deletions
diff --git a/Build/source/texk/web2c/mfluadir/mfluac.c b/Build/source/texk/web2c/mfluadir/mfluac.c
index 5c1ddd5f66a..044bd05633e 100644
--- a/Build/source/texk/web2c/mfluadir/mfluac.c
+++ b/Build/source/texk/web2c/mfluadir/mfluac.c
@@ -9,7 +9,7 @@
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
-
+#include <kpathsea/kpathsea.h>
/**************************************************************/
/* */
/* private functions */
@@ -408,12 +408,13 @@ static int priv_mfweb_LUAGLOBALGET_boundary_char(lua_State *L)
int mfluabeginprogram(void)
{
lua_State *L = luaL_newstate();
- const char* luafile = "begin_program.lua";
+ char* luafile = kpse_find_file("begin_program.lua", kpse_lua_format, 0);
int res ;
luaL_openlibs(L);
Luas[0] = L;
/* execute Lua external "begin_program.lua" */
res = luaL_loadfile(L, luafile);
+ if(luafile) free(luafile);
if ( res==0 ) {
res = lua_pcall(L, 0, 0, 0);
}
@@ -426,8 +427,9 @@ int mfluaendprogram(void)
{
lua_State *L = Luas[0];
/* execute Lua external "end_program.lua" */
- const char* file = "end_program.lua";
+ char* file = kpse_find_file("end_program.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if(file) free(file);
if ( res==0 ) {
res = lua_pcall(L, 0, 0, 0);
}
@@ -440,8 +442,9 @@ int mfluaendprogram(void)
int mfluaPREstartofMF(void)
{
lua_State *L = Luas[0];
- const char* file = "start_of_MF.lua";
+ char* file = kpse_find_file("start_of_MF.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -473,8 +476,9 @@ int mfluaPREstartofMF(void)
int mfluaPREmaincontrol(void)
{
lua_State *L = Luas[0];
- const char* file = "main_control.lua";
+ char* file = kpse_find_file("main_control.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -506,8 +510,9 @@ int mfluaPREmaincontrol(void)
int mfluaPOSTmaincontrol(void)
{
lua_State *L = Luas[0];
- const char* file = "main_control.lua";
+ char* file = kpse_find_file("main_control.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -541,7 +546,7 @@ int mfluainitialize(void)
{
/* execute Lua external "mfluaini.lua" */
lua_State *L = Luas[0];
- const char* file = "mfluaini.lua";
+ char* file = kpse_find_file("mfluaini.lua", kpse_lua_format, 0);
int res ;
/* register lua functions */
lua_pushcfunction(L, priv_mfweb_link);lua_setglobal(L, "link");
@@ -582,6 +587,7 @@ int mfluainitialize(void)
/*lua_pushcfunction(L, priv_mfweb_SKELETON);lua_setglobal(L, "SKELETON");*/
/* execute Lua external "mfluaini.lua" */
res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ) {
res = lua_pcall(L, 0, 0, 0);
}
@@ -593,8 +599,9 @@ int mfluainitialize(void)
int mfluaPOSTfinalcleanup(void)
{
lua_State *L = Luas[0];
- const char* file = "final_cleanup.lua";
+ char* file = kpse_find_file("final_cleanup.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
/*if (res!=0) {fprintf(stderr,"\n! Warning: file final_cleanup not loaded\n",lua_tostring(L, -1)); return res;}*/
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
@@ -643,8 +650,9 @@ int mfluaPOSTfinalcleanup(void)
/* fprintf(stderr,"\n! %s\n","*end***************"); */
/* lua_State *L = Luas[0]; */
-/* const char* file = "print_path.lua"; */
+/* char* file = kpse_find_file("print_path.lua", kpse_lua_format, 0); */
/* int res = luaL_loadfile(L, file); */
+/* if (file) free (file); */
/* if ( res==0 ) { */
/* res = lua_pcall(L, 0, 0, 0); */
/* } */
@@ -660,8 +668,9 @@ int mfluaPOSTfinalcleanup(void)
int mfluaprintpath(halfword h, strnumber s, boolean nuline)
{
lua_State *L = Luas[0];
- const char* file = "print_path.lua";
+ char* file = kpse_find_file("print_path.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -697,8 +706,9 @@ int mfluaprintedges(strnumber s, boolean nuline, integer xoff, integer yoff)
{
lua_State *L = Luas[0];
- const char* file = "print_edges.lua";
+ char* file = kpse_find_file("print_edges.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -735,8 +745,9 @@ int mfluaprintedges(strnumber s, boolean nuline, integer xoff, integer yoff)
/* { */
/* lua_State *L = Luas[0]; */
-/* const char* file = "offset_prep.lua"; */
+/* char* file = kpse_find_file("offset_prep.lua",kpse_lua_format, 0); */
/* int res = luaL_loadfile(L, file); */
+/* if (file) free (file); */
/* if ( res==0 ){ */
/* res = lua_pcall(L, 0, 0, 0); */
/* if (res==0){ */
@@ -776,8 +787,9 @@ int mfluaPREoffsetprep(halfword c, halfword h)
{
lua_State *L = Luas[0];
- const char* file = "offset_prep.lua";
+ char* file = kpse_find_file("offset_prep.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -811,8 +823,9 @@ int mfluaPOSToffsetprep(halfword c, halfword h)
{
lua_State *L = Luas[0];
- const char* file = "offset_prep.lua";
+ char* file = kpse_find_file("offset_prep.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -846,8 +859,9 @@ int mfluaPOSToffsetprep(halfword c, halfword h)
int mfluaPREfillenveloperhs(halfword rhs)
{
lua_State *L = Luas[0];
- const char* file = "do_add_to.lua";
+ char* file = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -879,8 +893,9 @@ int mfluaPREfillenveloperhs(halfword rhs)
int mfluaPOSTfillenveloperhs(halfword rhs)
{
lua_State *L = Luas[0];
- const char* file = "do_add_to.lua";
+ char* file = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -913,8 +928,9 @@ int mfluaPOSTfillenveloperhs(halfword rhs)
int mfluaPREfillenvelopelhs(halfword lhs)
{
lua_State *L = Luas[0];
- const char* file = "do_add_to.lua";
+ char* file = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -946,8 +962,9 @@ int mfluaPREfillenvelopelhs(halfword lhs)
int mfluaPOSTfillenvelopelhs(halfword lhs)
{
lua_State *L = Luas[0];
- const char* file = "do_add_to.lua";
+ char* file = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -980,8 +997,9 @@ int mfluaPOSTfillenvelopelhs(halfword lhs)
int mfluaPREfillspecrhs(halfword rhs)
{
lua_State *L = Luas[0];
- const char* file = "do_add_to.lua";
+ char* file = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1013,8 +1031,9 @@ int mfluaPREfillspecrhs(halfword rhs)
int mfluaPOSTfillspecrhs(halfword rhs)
{
lua_State *L = Luas[0];
- const char* file = "do_add_to.lua";
+ char* file = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1046,8 +1065,9 @@ int mfluaPOSTfillspecrhs(halfword rhs)
int mfluaPREfillspeclhs(halfword lhs)
{
lua_State *L = Luas[0];
- const char* file = "do_add_to.lua";
+ char* file = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1079,8 +1099,9 @@ int mfluaPREfillspeclhs(halfword lhs)
int mfluaPOSTfillspeclhs(halfword lhs)
{
lua_State *L = Luas[0];
- const char* file = "do_add_to.lua";
+ char* file = kpse_find_file("do_add_to.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1111,8 +1132,9 @@ int mfluaPOSTfillspeclhs(halfword lhs)
int mfluaPREmovetoedges(halfword lhs)
{
lua_State *L = Luas[0];
- const char* file = "fill_spec.lua";
+ char* file = kpse_find_file("fill_spec.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1145,8 +1167,9 @@ int mfluaPREmovetoedges(halfword lhs)
int mfluaPOSTmovetoedges(halfword lhs)
{
lua_State *L = Luas[0];
- const char* file = "fill_spec.lua";
+ char* file = kpse_find_file("fill_spec.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1179,8 +1202,9 @@ int mfluaPOSTmovetoedges(halfword lhs)
int mfluaPREmakechoices(halfword p)
{
lua_State *L = Luas[0];
- const char* file = "scan_direction.lua";
+ char* file = kpse_find_file("scan_direction.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1212,8 +1236,9 @@ int mfluaPREmakechoices(halfword p)
int mfluaPOSTmakechoices(halfword p)
{
lua_State *L = Luas[0];
- const char* file = "scan_direction.lua";
+ char* file = kpse_find_file("scan_direction.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1249,8 +1274,9 @@ int mfluaPOSTmakechoices(halfword p)
int mfluaprintretrogradeline(integer x0, integer y0, integer cur_x, integer cur_y)
{
lua_State *L = Luas[0];
- const char* file = "skew_line_edges.lua";
+ char* file = kpse_find_file("skew_line_edges.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1286,8 +1312,9 @@ int mfluaprintretrogradeline(integer x0, integer y0, integer cur_x, integer cur_
int mfluaPREmakeellipse(integer major_axis, integer minor_axis, integer theta , integer tx, integer ty,integer q)
{
lua_State *L = Luas[0];
- const char* file = "make_ellipse.lua";
+ char* file = kpse_find_file("make_ellipse.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1325,8 +1352,9 @@ int mfluaPREmakeellipse(integer major_axis, integer minor_axis, integer theta ,
int mfluaPOSTmakeellipse(integer major_axis, integer minor_axis, integer theta , integer tx, integer ty,integer q)
{
lua_State *L = Luas[0];
- const char* file = "make_ellipse.lua";
+ char* file = kpse_find_file("make_ellipse.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1370,8 +1398,9 @@ int mfluaPOSTmakeellipse(integer major_axis, integer minor_axis, integer theta ,
int mfluaprinttransitionlinefrom(integer x, integer y)
{
lua_State *L = Luas[0];
- const char* file = "fill_envelope.lua";
+ char* file = kpse_find_file("fill_envelope.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){
@@ -1403,8 +1432,9 @@ int mfluaprinttransitionlinefrom(integer x, integer y)
int mfluaprinttransitionlineto(integer x, integer y)
{
lua_State *L = Luas[0];
- const char* file = "fill_envelope.lua";
+ char* file = kpse_find_file("fill_envelope.lua", kpse_lua_format, 0);
int res = luaL_loadfile(L, file);
+ if (file) free (file);
if ( res==0 ){
res = lua_pcall(L, 0, 0, 0);
if (res==0){