From 2f16e9359063cc29898cc7fed61a9c2d0b8fd617 Mon Sep 17 00:00:00 2001
From: Luigi Scarso <luigi.scarso@gmail.com>
Date: Mon, 22 Aug 2022 23:11:58 +0000
Subject: [PATCH] Fixed a bug with \expandafter\font\csname\endcsname (thanks
 to H. Kitagawa)

[[Split portion of a mixed commit.]]
---
 source/texk/web2c/luatexdir/luatex_svnversion.h | 2 +-
 source/texk/web2c/luatexdir/tex/texdeffont.c    | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/source/texk/web2c/luatexdir/luatex_svnversion.h b/source/texk/web2c/luatexdir/luatex_svnversion.h
index d51386532..6809e8b9c 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 7538
+#define luatex_svn_revision 7539
 #endif
diff --git a/source/texk/web2c/luatexdir/tex/texdeffont.c b/source/texk/web2c/luatexdir/tex/texdeffont.c
index 1ec4b12bf..5adc8f518 100644
--- a/source/texk/web2c/luatexdir/tex/texdeffont.c
+++ b/source/texk/web2c/luatexdir/tex/texdeffont.c
@@ -218,11 +218,13 @@ void tex_def_font(small_number a)
 
         This is tricky: when we redefine a string we loose the old one. So this
         will change as it's only used to display the |\fontname| so we can store
-        that with the font.
+        that with the font. To be consistent with the rest of the code, unlike 
+        |pdftex| the text of |null_cs| (i.e. |\csname\endcsname|) is the empty 
+        string |""|.
 
     */
     d = cs_text(font_id_base + f);
-    t = (u >= null_cs) ? cs_text(u) : maketexstring("FONT");
+    t = (u >= null_cs) ? ((u==null_cs) ? get_nullstr() : cs_text(u)) : maketexstring("FONT");
     if (!d) {
         /*tex We have a new string. */
         cs_text(font_id_base + f) = t;
@@ -230,7 +232,7 @@ void tex_def_font(small_number a)
         /*tex We have a duplicate string. */
         flush_str(t);
     } else if (d!=t){
-        d = search_string(t);
+        d = search_string(t) ;
         if (d) {
             /*tex We have already such a string. */
             cs_text(font_id_base + f) = d;
-- 
GitLab