latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
126 stars 34 forks source link

save size overflow because of global/local assigments #109

Closed u-fischer closed 3 years ago

u-fischer commented 3 years ago

babel assigns \bbl@hymapsel globally in \bbl@switch and locallly in various other places. This can lead to a save size overflow if too many \babel@toc command are made:

\documentclass{article}
\usepackage[german]{babel}
\usepackage{etoolbox}
\makeatletter
% this patch avoids the overflow:
%\patchcmd\bbl@switch{\global\let\bbl@hymapsel\@cclv}{\let\bbl@hymapsel\@cclv}{}{\fail}
\makeatother
\begin{document}
\begingroup
\ExplSyntaxOn\makeatletter
\int_step_inline:nn{40000}{\babel@toc {german}{}}
\ExplSyntaxOff
\endgroup
blub
\end{document}

gives

! TeX capacity exceeded, sorry [save size=80000].
\bbl@exp ...fter \noexpand \csname ##1\endcsname }
                                                  \edef \bbl@exp@aux {\endgr...
l.26 ...ep_inline:nn{40000}{\babel@toc {german}{}}

(This was discovered while discussing the redledpar issue mentioned in issue #108 )

jbezos commented 3 years ago

Your fix looks reasonable. I'll study it.