summaryrefslogtreecommitdiff
path: root/source/luametatex/source/tex/textoken.c
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2023-05-27 12:37:50 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2023-05-27 12:37:50 +0200
commit32381f97e98465953bfde24b4436093e70fbe70f (patch)
tree1f585cf7af509e76c64aca108cecd23acd6fb437 /source/luametatex/source/tex/textoken.c
parentbb8ae12f4f94189fd1540b201e2aea78f485de97 (diff)
downloadcontext-32381f97e98465953bfde24b4436093e70fbe70f.tar.gz
2023-05-27 12:16:00
Diffstat (limited to 'source/luametatex/source/tex/textoken.c')
-rw-r--r--source/luametatex/source/tex/textoken.c68
1 files changed, 57 insertions, 11 deletions
diff --git a/source/luametatex/source/tex/textoken.c b/source/luametatex/source/tex/textoken.c
index e3aa90c0f..7580d72d3 100644
--- a/source/luametatex/source/tex/textoken.c
+++ b/source/luametatex/source/tex/textoken.c
@@ -2942,6 +2942,7 @@ void tex_run_convert_tokens(halfword code)
break;
*/
case detokenized_code:
+ /*tex Sort of like |\meaningles| but without the explanationart text. */
{
int saved_selector;
int saved_scanner_status = lmt_input_state.scanner_status;
@@ -2956,6 +2957,60 @@ void tex_run_convert_tokens(halfword code)
pop_selector;
break;
}
+ case detokened_code:
+ /*tex Takes a control sequence or token list. Probably a bad name but so be it. */
+ {
+ int saved_selector;
+ int saved_scanner_status = lmt_input_state.scanner_status;
+ halfword list = null;
+ lmt_input_state.scanner_status = scanner_is_normal;
+ tex_get_token();
+ lmt_input_state.scanner_status = saved_scanner_status;
+ switch (cur_cmd) {
+ case call_cmd:
+ case protected_call_cmd:
+ case semi_protected_call_cmd:
+ case tolerant_call_cmd:
+ case tolerant_protected_call_cmd:
+ case tolerant_semi_protected_call_cmd:
+ if (cur_chr) {
+ /* We only serialize macros with no arguments. */
+ list = token_link(cur_chr);
+ break;
+ } else {
+ goto WHATEVER;
+ }
+ case internal_toks_cmd:
+ case register_toks_cmd:
+ list = token_link(eq_value(cur_chr));
+ break;
+ case register_cmd:
+ if (cur_chr == tok_val_level) {
+ halfword n = tex_scan_toks_register_number();
+ list = token_link(toks_register(n));
+ break;
+ } else {
+ goto WHATEVER;
+ }
+ break;
+ default:
+ WHATEVER:
+ {
+ halfword t = tex_get_available_token(cur_tok);
+ push_selector;
+ tex_show_token_list(t, 0);
+ pop_selector;
+ tex_put_available_token(t);
+ }
+ break;
+ }
+ if (list) {
+ push_selector;
+ tex_show_token_list(list, 2);
+ pop_selector;
+ }
+ break;
+ }
case roman_numeral_code:
{
int saved_selector;
@@ -3304,7 +3359,7 @@ char *tex_tokenlist_to_tstring(int pp, int inhibit_par, int *siz, int skippreamb
} else {
int infop = token_info(p);
if (infop < 0) {
- /* unlikely, will go after checking */
+ /*tex Unlikely, will go after checking (maybe \LUA\ user mess up). */
tex_aux_append_str_to_buffer(error_string_bad(32));
} else if (infop < cs_token_flag) {
/*tex We nearly always end up here because otherwise we have an error. */
@@ -3370,7 +3425,7 @@ char *tex_tokenlist_to_tstring(int pp, int inhibit_par, int *siz, int skippreamb
}
break;
case end_match_cmd:
- if (skippreamble ==2) {
+ if (skippreamble == 2) {
goto EXIT;
} else if (chr == 0) {
if (! skip) {
@@ -3380,15 +3435,6 @@ char *tex_tokenlist_to_tstring(int pp, int inhibit_par, int *siz, int skippreamb
skip = 0 ;
}
break;
- /*
- case string_cmd:
- c = c + cs_offset_value;
- do_make_room((int) str_length(c));
- for (int i = 0; i < str_length(c); i++) {
- token_state.buffer[token_state.bufloc++] = str_string(c)[i];
- }
- break;
- */
case end_paragraph_cmd:
if (! inhibit_par && (auto_paragraph_mode(auto_paragraph_text))) {
tex_aux_append_esc_to_buffer("par");