[PATCH] Respect find_{output,write}_file result
Hi, according to the documentation find_{output,write}_file should return the name of the to be written file. Currently this is mostly ignored and the original name is always used. Here is a patch to fix this. Best regards, Marcel Krüger --- source/texk/web2c/luatexdir/tex/texfileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/texk/web2c/luatexdir/tex/texfileio.c b/source/texk/web2c/luatexdir/tex/texfileio.c index 143e694e1..158757080 100644 --- a/source/texk/web2c/luatexdir/tex/texfileio.c +++ b/source/texk/web2c/luatexdir/tex/texfileio.c @@ -347,7 +347,7 @@ boolean lua_a_open_out(alpha_file * f, char *fn, int n) messaging is left to \LUA\ then. */ - ret = open_outfile(f, fn, FOPEN_W_MODE); + ret = open_outfile(f, str_string(fnam), FOPEN_W_MODE); } } else { if (openoutnameok(fn)) { @@ -379,7 +379,7 @@ boolean lua_b_open_out(alpha_file * f, char *fn) fnam = 0; test = run_callback(callback_id, "S->s", fn, &fnam); if ((test) && (fnam != 0) && (str_length(fnam) > 0)) { - ret = open_outfile(f, fn, FOPEN_WBIN_MODE); + ret = open_outfile(f, str_string(fnam), FOPEN_WBIN_MODE); } } else { if (openoutnameok(fn)) { -- 2.21.0
On 5/26/2019 2:26 PM, Marcel Fabian Krüger wrote:
Hi,
according to the documentation find_{output,write}_file should return the name of the to be written file. Currently this is mostly ignored and the original name is always used. Here is a patch to fix this.
Best regards, Marcel Krüger --- source/texk/web2c/luatexdir/tex/texfileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source/texk/web2c/luatexdir/tex/texfileio.c b/source/texk/web2c/luatexdir/tex/texfileio.c index 143e694e1..158757080 100644 --- a/source/texk/web2c/luatexdir/tex/texfileio.c +++ b/source/texk/web2c/luatexdir/tex/texfileio.c @@ -347,7 +347,7 @@ boolean lua_a_open_out(alpha_file * f, char *fn, int n) messaging is left to \LUA\ then.
*/ - ret = open_outfile(f, fn, FOPEN_W_MODE); + ret = open_outfile(f, str_string(fnam), FOPEN_W_MODE); } } else { if (openoutnameok(fn)) { @@ -379,7 +379,7 @@ boolean lua_b_open_out(alpha_file * f, char *fn) fnam = 0; test = run_callback(callback_id, "S->s", fn, &fnam); if ((test) && (fnam != 0) && (str_length(fnam) > 0)) { - ret = open_outfile(f, fn, FOPEN_WBIN_MODE); + ret = open_outfile(f, str_string(fnam), FOPEN_WBIN_MODE); } } else { if (openoutnameok(fn)) { indeed a bug but the solution is a bit different as we can avoid going via the string pool
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 5/26/2019 6:34 PM, Hans Hagen wrote:
indeed a bug but the solution is a bit different as we can avoid going via the string pool
Hans
More like this? Marcel --- source/texk/web2c/luatexdir/tex/texfileio.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/source/texk/web2c/luatexdir/tex/texfileio.c b/source/texk/web2c/luatexdir/tex/texfileio.c index 143e694e1..5480c30de 100644 --- a/source/texk/web2c/luatexdir/tex/texfileio.c +++ b/source/texk/web2c/luatexdir/tex/texfileio.c @@ -332,14 +332,13 @@ boolean lua_a_open_in(alpha_file * f, char *fn, int n) boolean lua_a_open_out(alpha_file * f, char *fn, int n) { boolean test; - str_number fnam; + const char *fnam; int callback_id; boolean ret = false; callback_id = callback_defined(find_write_file_callback); if (callback_id > 0) { - fnam = 0; - test = run_callback(callback_id, "dS->s", n, fn, &fnam); - if ((test) && (fnam != 0) && (str_length(fnam) > 0)) { + test = run_callback(callback_id, "dS->R", n, fn, &fnam); + if ((test) && (fnam != NULL) && (strlen(fnam) > 0)) { /*tex There is no message here because if that is needed the macro @@ -347,7 +346,7 @@ boolean lua_a_open_out(alpha_file * f, char *fn, int n) messaging is left to \LUA\ then. */ - ret = open_outfile(f, fn, FOPEN_W_MODE); + ret = open_outfile(f, fnam, FOPEN_W_MODE); } } else { if (openoutnameok(fn)) { @@ -371,15 +370,14 @@ boolean lua_a_open_out(alpha_file * f, char *fn, int n) boolean lua_b_open_out(alpha_file * f, char *fn) { boolean test; - str_number fnam; + const char *fnam; int callback_id; boolean ret = false; callback_id = callback_defined(find_output_file_callback); if (callback_id > 0) { - fnam = 0; - test = run_callback(callback_id, "S->s", fn, &fnam); - if ((test) && (fnam != 0) && (str_length(fnam) > 0)) { - ret = open_outfile(f, fn, FOPEN_WBIN_MODE); + test = run_callback(callback_id, "S->R", fn, &fnam); + if ((test) && (fnam != NULL) && (strlen(fnam) > 0)) { + ret = open_outfile(f, fnam, FOPEN_WBIN_MODE); } } else { if (openoutnameok(fn)) { -- 2.21.0
On 5/26/2019 9:50 PM, Marcel Fabian Krüger wrote:
On 5/26/2019 6:34 PM, Hans Hagen wrote:
indeed a bug but the solution is a bit different as we can avoid going via the string pool
Hans
More like this? indeed, sort of
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Sun, May 26, 2019 at 10:10 PM Hans Hagen
On 5/26/2019 9:50 PM, Marcel Fabian Krüger wrote:
On 5/26/2019 6:34 PM, Hans Hagen wrote:
indeed a bug but the solution is a bit different as we can avoid going via the string pool
Hans
More like this? indeed, sort of
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- _______________________________________________ dev-luatex mailing list dev-luatex@ntg.nl https://mailman.ntg.nl/mailman/listinfo/dev-luatex
applied in experimental -- luigi
On Mon, May 27, 2019 at 09:38:18AM +0200, luigi scarso wrote:
[...]
applied in experimental
Thanks. I still think ->R would make more sense than ->S though, because at least for find_write_file the documentation explicitly allows returning nil "if the file cannot be found", which I understand as "if no place for the file is found", so the message "callback should return a string, not: nil" seems at least misleading. Best regards, Marcel
On Mon, May 27, 2019 at 09:38:18AM +0200, luigi scarso wrote:
[...]
applied in experimental
Thanks.
I still think ->R would make more sense than ->S though, because at least for find_write_file the documentation explicitly allows returning nil "if the file cannot be found", which I understand as "if no place for the file is found", so the message "callback should return a string, not: nil" seems at least misleading. Here I already have R indeed as it is consistent with the other ones;
On 6/1/2019 12:40 AM, Marcel Fabian Krüger wrote: there's another place too. I was pondering some other adaption but will postpone that and submit the two R patches. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Sat, Jun 1, 2019 at 10:34 AM Hans Hagen
On Mon, May 27, 2019 at 09:38:18AM +0200, luigi scarso wrote:
[...]
applied in experimental
Thanks.
I still think ->R would make more sense than ->S though, because at least for find_write_file the documentation explicitly allows returning nil "if the file cannot be found", which I understand as "if no place for
is found", so the message "callback should return a string, not: nil" seems at least misleading. Here I already have R indeed as it is consistent with the other ones;
On 6/1/2019 12:40 AM, Marcel Fabian Krüger wrote: the file there's another place too. I was pondering some other adaption but will postpone that and submit the two R patches.
applied in r7151. -- luigi
participants (3)
-
Hans Hagen
-
luigi scarso
-
Marcel Fabian Krüger