Commit Graph
5 Commits
Author SHA1 Message Date
gloamxun 53a299bd58 Honour protect in edef but expand it normally
\protect was just a no-op token, so \edef\b{\protect\a} expanded \a at
definition time. In an edef-style pass the expander now copies \protect and the
following token unchanged (so the stored body keeps the protected command); in
the ordinary document pass it drops \protect and lets the token expand as
LaTeX does when the text is typeset.

A test defines a=A, \edef b={\protect\a}, redefines a=C, and checks both \b and
a literal \protect\a print C with no warnings.
2026-10-27 01:54:13 +08:00
gloamxun c3ae52452d Resolve csname targets with arguments
\csname foo\endcsname stopped after looking up a zero-argument macro; a
parameterised target was left unresolved. After the zero-argument fast path,
build a synthetic command from the resolved name plus the text following
\endcsname and run the normal macro lookup, so arguments/defaults/delimited
parameter text are consumed exactly as for a literal \foo, and only the bytes
belonging to the csname construct are charged to the caller.

A test defines \foo#1{[#1]} and prints both \csname foo\endcsname{x} and
\csname foo\endcsname{y} as "[x] and [y]" with no warnings.
2026-10-27 01:51:29 +08:00
gloamxun c3e02f0586 Make global definitions override group shadows
A group-local \def stayed visible after a later \gdef of the same name because
scoped lookup preferred the newest scope entry, and an inline \global\def was
unsupported. Route \gdef/\xdef and \global\def/\global\let/\global\chardef
through an upsert that removes same-name entries from every live scope before
updating the global table, so the global meaning wins inside the group and
after it.

A test defines a group-local L, replaces it with G via \gdef inside the group,
and checks the group prints G and the following \a prints G; an
inline \global\def also expands.
2026-10-27 01:49:17 +08:00
gloamxun 16b61cd368 Freeze unexpanded tokens through an edef
\unexpanded passed its text straight through, so \edef\b{\unexpanded{\a}}
expanded \a at definition time. Split the expander into an inner pass with a
freeze flag: the edef-style wrapper protects each backslash in \unexpanded's
argument with the existing no-expand marker, which the pass restores on the way
out, while the normal document pass still writes the text through so it expands
at use time.

A test defines a=A, \edef b={\unexpanded{\a}}, redefines a=C, and checks \b
prints C with no warnings; the earlier \expanded/\unexpanded/\detokenize test
still passes.
2026-10-27 01:47:08 +08:00
gloamxun 4024fa7435 Add the route-D status handoff and fix README defaults 2026-10-27 01:43:17 +08:00