Skip to content

Commit

Permalink
Define \lx@alloc@ as safe version of plain's \alloc@, latex's \e@allo…
Browse files Browse the repository at this point in the history
…c; defines internal \lx@counter@arabic
  • Loading branch information
brucemiller committed Dec 28, 2024
1 parent caf5e13 commit ddb4571
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/LaTeXML/Engine/TeX_Registers.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ DefPrimitive('\muskipdef SkipSpaces Token SkipSpaces SkipMatch:=', sub {
DefPrimitive('\toksdef SkipSpaces Token SkipSpaces SkipMatch:=', sub {
shorthandDef($_[0], $_[1], '\toks', Tokens()); });

# Candidate for use defining plain's \alloc@ and latex's \e@alloc
our %stored_registers = (
'\countdef' => 1, '\dimendef' => 1, '\skipdef' => 1, '\muskipdef' => 1, '\toksdef' => 1);
DefMacro('\lx@alloc@ DefToken {} {} DefToken', sub {
my ($gullet, $type, $tracker, $allocator, $cs) = @_;
$type = ToString($type);
$tracker = ToString($tracker);
my $next;
if ($stored_registers{ ToString($allocator) }) {
$next = LaTeXML::Package::allocateRegister($type);
$next =~ s/^\Q$type\E//; }
else {
my $xnext = $STATE->lookupValue($tracker) || Number(0);
$next = $xnext->valueOf + 1; }
my $value = Number($next);
$STATE->assignValue($tracker => Number($next), 'global');
return Tokens(T_CS('\allocationnumber'), Explode($next), T_CS('\relax'),
T_CS('\global'), $allocator, $cs, T_OTHER('='), T_CS('\allocationnumber')); });

# Out of place, but utility for LaTeX-style \the<ctr>; used by Package's NewCounter
DefMacro('\lx@counter@arabic{}', sub {
ExplodeText(CounterValue(ToString(Expand($_[1])))->valueOf); });

#======================================================================
# Numeric Registers
#----------------------------------------------------------------------
Expand Down

0 comments on commit ddb4571

Please sign in to comment.