From 4cad4b8d1a1de9d0978221f23d4f7112a7f4d410 Mon Sep 17 00:00:00 2001
From: Luigi Scarso <luigi.scarso@gmail.com>
Date: Sat, 30 Jul 2022 23:04:11 +0000
Subject: [PATCH] Fixed loading .tex when  --output-directory is enabled. Sync
 trunk with experimental.

[[Split portion of a mixed commit.]]
---
 source/texk/web2c/luatexdir/ChangeLog           |  6 ++++++
 source/texk/web2c/luatexdir/lang/texlang.c      |  1 +
 source/texk/web2c/luatexdir/luatex_svnversion.h |  2 +-
 source/texk/web2c/luatexdir/tex/texfileio.c     | 13 ++++---------
 4 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/source/texk/web2c/luatexdir/ChangeLog b/source/texk/web2c/luatexdir/ChangeLog
index f98db659a..d0be010ac 100644
--- a/source/texk/web2c/luatexdir/ChangeLog
+++ b/source/texk/web2c/luatexdir/ChangeLog
@@ -1,3 +1,9 @@
+2022-07-31  Luigi Scarso <luigi.scarso@gmail.com>
+    * Fixed loading .tex when  --output-directory is enabled
+
+2022-07-30  Luigi Scarso <luigi.scarso@gmail.com>
+    * Backtrack replace pointer when successive disc in exceptions  (H.Hagen)
+
 2022-07-30  Luigi Scarso <luigi.scarso@gmail.com>
     * Take exception pre/port disc font from wordstart (H.Hagen)
 
diff --git a/source/texk/web2c/luatexdir/lang/texlang.c b/source/texk/web2c/luatexdir/lang/texlang.c
index f9e53bbba..a0d067251 100644
--- a/source/texk/web2c/luatexdir/lang/texlang.c
+++ b/source/texk/web2c/luatexdir/lang/texlang.c
@@ -705,6 +705,7 @@ static void do_exception(halfword wordstart, halfword r, char *replacement)
             /*tex check if we have two exceptions in a row */
             if (uword[i + 1] == '{') {
                 i--;
+t = alink(t);
             }
         } else {
             t = vlink(t);
diff --git a/source/texk/web2c/luatexdir/luatex_svnversion.h b/source/texk/web2c/luatexdir/luatex_svnversion.h
index 50224b636..0f1c3154a 100644
--- a/source/texk/web2c/luatexdir/luatex_svnversion.h
+++ b/source/texk/web2c/luatexdir/luatex_svnversion.h
@@ -1,4 +1,4 @@
 #ifndef luatex_svn_revision_h
 #define luatex_svn_revision_h
-#define luatex_svn_revision 7531
+#define luatex_svn_revision 7532
 #endif
diff --git a/source/texk/web2c/luatexdir/tex/texfileio.c b/source/texk/web2c/luatexdir/tex/texfileio.c
index 8d8cdc043..83a76a21f 100644
--- a/source/texk/web2c/luatexdir/tex/texfileio.c
+++ b/source/texk/web2c/luatexdir/tex/texfileio.c
@@ -92,17 +92,12 @@ int read_file_callback_id[17];
 static char *find_in_output_directory(const char *s)
 {
     if (output_directory && !kpse_absolute_p(s, false)) {
-        FILE *f_ptr;
         char *ftemp = concat3(output_directory, DIR_SEP_STRING, s);
+	char *ret_val = NULL ;
         /*tex This code is used for input files only. */
-        f_ptr = fopen(ftemp, "rb");
-        if (f_ptr) {
-            fclose(f_ptr);
-            return ftemp;
-        } else {
-            free(ftemp);
-
-        }
+	ret_val = kpse_find_file(ftemp, kpse_tex_format, 1);
+	free(ftemp);
+	return ret_val;
     }
     return NULL;
 }
-- 
GitLab