summaryrefslogtreecommitdiff
path: root/source/luametatex/source/lua/lmttokenlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/luametatex/source/lua/lmttokenlib.c')
-rw-r--r--source/luametatex/source/lua/lmttokenlib.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/source/luametatex/source/lua/lmttokenlib.c b/source/luametatex/source/lua/lmttokenlib.c
index c591bd7f6..dcd17b53e 100644
--- a/source/luametatex/source/lua/lmttokenlib.c
+++ b/source/luametatex/source/lua/lmttokenlib.c
@@ -856,7 +856,7 @@ static int tokenlib_scan_csname(lua_State *L)
int t;
saved_tex_scanner texstate = tokenlib_aux_save_tex_scanner();
if (lua_toboolean(L, 1)) {
- /*tex unchecked (maybe backport this option to luatex) */
+ /*tex Not here: |tex_get_next_non_spacer()| unless we adapt more later on. */
do {
tex_get_token();
} while (cur_tok == space_token);
@@ -864,7 +864,7 @@ static int tokenlib_scan_csname(lua_State *L)
/*tex checked */
tex_get_next();
}
- t = cur_cs ? cs_token_flag + cur_cs : token_val (cur_cmd, cur_chr);
+ t = cur_cs ? cs_token_flag + cur_cs : token_val(cur_cmd, cur_chr);
if (t >= cs_token_flag) {
int allocated = 0;
unsigned char *s = tokenlib_aux_get_cs_text(t - cs_token_flag, &allocated);
@@ -1853,10 +1853,27 @@ static int tokenlib_scan_char(lua_State *L)
return 1;
}
+static const char *token_cmd_to_string[15] = {
+ "\\", /* 0 escape_cmd */
+ "{", /* 1 left_brace_cmd */
+ "}", /* 2 right_brace_cmd */
+ "$", /* 3 math_shift_cmd */
+ "&", /* 4 alignment_tab_cmd */
+ "\n", /* 5 end_line_cmd */
+ "#", /* 6 parameter_cmd */
+ "^", /* 7 superscript_cmd */
+ "_", /* 8 subscript_cmd */
+ "", /* 9 ignore_cmd */
+ " ", /* 10 spacer_cmd */
+ "", /* 11 letter_cmd */
+ "", /* 12 other_char_cmd */
+ "", /* 13 active_char_cmd */
+ "%" /* 14 comment_cmd */
+};
+
static int tokenlib_scan_next_char(lua_State *L)
{
saved_tex_scanner texstate = tokenlib_aux_save_tex_scanner();
- const char mapping[14][2] = { "\\", "{", "}", "$", "&", "\n", "#", "^", "_", " ", "", "", "", "%" };
tex_get_token();
switch (cur_cmd) {
case escape_cmd:
@@ -1871,7 +1888,7 @@ static int tokenlib_scan_next_char(lua_State *L)
case ignore_cmd:
case spacer_cmd:
case comment_cmd:
- lua_pushstring(L, mapping[cur_cmd]);
+ lua_pushstring(L, token_cmd_to_string[cur_cmd]);
break;
case letter_cmd:
case other_char_cmd: