[latex3-commits] [git/LaTeX3-latex3-latex3] master: Fix LuaTeX's strcmp after \endinput (014272041)

Marcel Fabian Krüger tex at 2krueger.de
Sun Oct 4 20:44:27 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/014272041f0b2719cc5c8b6c60363fa04e7435dc

>---------------------------------------------------------------

commit 014272041f0b2719cc5c8b6c60363fa04e7435dc
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sun Oct 4 20:38:14 2020 +0200

    Fix LuaTeX's strcmp after \endinput
    
    (fixes #813)


>---------------------------------------------------------------

014272041f0b2719cc5c8b6c60363fa04e7435dc
 l3kernel/CHANGELOG.md |  3 +++
 l3kernel/l3names.dtx  | 11 ++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index b3ccf0b77..f4485b77c 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Fixed
+- Lua emulation of \strcmp (issue #813)
+
 ## [2020-09-24]
 
 ### Changed
diff --git a/l3kernel/l3names.dtx b/l3kernel/l3names.dtx
index e7b7a0e50..579840ba5 100644
--- a/l3kernel/l3names.dtx
+++ b/l3kernel/l3names.dtx
@@ -1464,12 +1464,17 @@
 %   Here \enquote{smaller} refers to codepoint order which does not correspond to
 %   the user expected order for most non-ASCII strings.
 %    \begin{macrocode}
+local minus_tok = token.new(string.byte'-', 12)
+local zero_tok = token.new(string.byte'0', 12)
+local one_tok = token.new(string.byte'1', 12)
 luacmd('tex_strcmp:D', function()
   local first = scan_string()
   local second = scan_string()
-  write(first == second and '0'
-     or first < second and '-1'
-     or '1')
+  if first < second then
+    put_next(minus_tok, one_tok)
+  else
+    put_next(first == second and zero_tok or one_tok)
+  end
 end, 'global')
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list.