Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with SMTP id o8GCosZW011810 for ; Thu, 16 Sep 2010 14:50:55 +0200 Received: (qmail 23466 invoked by alias); 16 Sep 2010 12:50:48 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 16 Sep 2010 12:50:47 -0000 Received: from relay2.uni-heidelberg.de (EHLO relay2.uni-heidelberg.de) [129.206.210.211] by mx0.gmx.net (mx044) with SMTP; 16 Sep 2010 14:50:47 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id o8GCmm5v027457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 16 Sep 2010 14:48:48 +0200 Received: from listserv.uni-heidelberg.de (localhost.localdomain [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id o8GClh1T028362; Thu, 16 Sep 2010 14:49:04 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 486100 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 16 Sep 2010 14:40:58 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id o8GCewf5021013 for ; Thu, 16 Sep 2010 14:40:58 +0200 Received: from mail-bw0-f49.google.com (mail-bw0-f49.google.com [209.85.214.49]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id o8GCdpoY009792 for ; Thu, 16 Sep 2010 14:39:55 +0200 Received: by bwz19 with SMTP id 19so1771712bwz.22 for ; Thu, 16 Sep 2010 05:40:20 -0700 (PDT) Received: by 10.204.53.142 with SMTP id m14mr2439421bkg.147.1284640820852; Thu, 16 Sep 2010 05:40:20 -0700 (PDT) Received: from irwin.vpn.uni-freiburg.de (p54A2BE57.dip.t-dialin.net [84.162.190.87]) by mx.google.com with ESMTPS id 24sm2443174bkr.7.2010.09.16.05.40.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 16 Sep 2010 05:40:19 -0700 (PDT) Received: by irwin.vpn.uni-freiburg.de (Postfix, from userid 500) id 712B778AA; Thu, 16 Sep 2010 14:42:17 +0200 (CEST) Mail-Followup-To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE References: <19109.1284579373@cl.cam.ac.uk> <4C9122A1.4060008@morningstar2.co.uk> <4C91239B.2040301@morningstar2.co.uk> <4C912F95.70503@morningstar2.co.uk> <20100916030501.GA32514@oberdiek.my-fqdn.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Message-ID: <20100916124216.GA1110@oberdiek.my-fqdn.de> Date: Thu, 16 Sep 2010 14:42:17 +0200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Heiko Oberdiek Subject: Re: e-TeX low-level expertise needed Re: Allocation of registers To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p6i75npGen84eVAEFK/syJmFuaL1OLtauwJ5R/kaZ9HAe8peGX1DeqJL7BW4 1X28hmBsSaikXt0ebYfUaHmtXkk7HChP+4IT8tI+yodefY66PMpp/kPudTSzX7BVqDxUGU4uAf/y ckanA==V1; X-Resent-By: Forwarder X-Resent-For: rainer.schoepf@gmx.net X-Resent-To: rainer@rainer-schoepf.de Status: R X-Status: X-Keywords: X-UID: 6391 On Thu, Sep 16, 2010 at 11:05:03AM +0100, Chris Rowley wrote: > Thanks for this, Heiko. Note there is no upper range check in the code > here: > > >> \reserveinserts is a macro of etex.sty: > > | %% And we define \reserveinserts, so that you can say \reserveinserts{17} > | %% in order to reserve room for up to 17 additional insertion classes, that > | %% will not be taken away by \newcount, \newdimen, \newskip, or \newbox. > | > | \outer\def \reserveinserts#1% > |  {\global\insc@unt\numexpr \et@xins \ifnum#1>\z@ -#1\fi \relax} AFAIK there is no need: latex.ltx defines: \def\newcount{\alloc@0\count\countdef\insc@unt} \def\newdimen{\alloc@1\dimen\dimendef\insc@unt} etex.sty defines: \def\alloc@#1#2#3#4#5% {\ifnum\count1#1<#4% make sure there's still room \allocationnumber\count1#1 \global\advance\count1#1\@ne \global#3#5\allocationnumber \wlog{\string#5=\string#2\the\allocationnumber}% \else\ifnum#1<6 \begingroup \escapechar\m@ne \expandafter\alloc@@\expandafter{\string#2}#5% \else\errmessage{No room for a new #2}\fi\fi } * \insc@unt is the upper range for the register allocation numbers of \count, \dimen, ... in the lower area. * \insc@unt is used in macro \alloc in the comparison: \ifnum\count1#1<#4 (#4=\insc@unt). If \insc@unt is negative then the \ifnum is always false, because \count1#1 are the current allocation numbers of \count, \dimen, ... that are growing only and thus have positive values. Failing the test means etex.sty switches to the extended pool immediately. If you say \reserveinserts{300} then there isn't an error, but if you try to allocate 300 insertion registers, then this will fail sooner or later. Test file: \RequirePackage{etex} \reserveinserts{300} \count@=\z@ \@whilenum\count@<300\do{% \advance\count@ by\@ne \newinsert\foobar \message{<\the\count@>}% } \@@end Result: 132 \newinserts are possible, then ! No room for a new \dimen. Also \reserveinserts ignores previous calls of \reserveinsert. Thus the second call of \reserveinserts in \RequirePackage{etex} \reserveinserts{20} \reserveinserts{10} actually decreases the reserved number of inserts from 20 to 10, leaving more room for the other registers in the lower area. I tried a more elaborate version of \reserveinserts: \RequirePackage{etex} \makeatletter \outer\def \reserveinserts#1{% \begingroup \@tempcnta=\numexpr#1\relax \ifnum\@tempcnta<\z@ \PackageWarning{etex}{% Negative number (\the\@tempcnta) for % \@backslashchar reserveinserts,\MessageBreak assuming 0% }% \@tempcnta=\z@ \fi \count@\count10 % count \ifnum\count11>\count@ \count@\count11 \fi % dimen \ifnum\count12>\count@ \count@\count12 \fi % skip \ifnum\count14>\count@ \count@\count14 \fi % box \count@=\numexpr\et@xins-\count@\relax \PackageInfo{etex}{% Maximum for \@backslashchar reserveinserts is \the\count@ }% \ifnum\@tempcnta>\count@ \PackageError{etex}{% \the\@tempcnta\space insertion register% \ifnum\@tempcnta=\@ne \space is \else s are \fi requested,\MessageBreak \ifnum\count@<\@ne but no more registers can be reserved% \else but only \the\count@\space register% \ifnum\count@=\@ne\else s\fi\space can be reserved% \fi }\@ehc \@tempcnta=\count@ \fi \global\insc@unt\numexpr\et@xins-\@tempcnta\relax \endgroup } % some rudimentary testing \reserveinserts{-1} \reserveinserts{0} \reserveinserts{131} \reserveinserts{132} \reserveinserts{133} \count@=\z@ \@whilenum\count@<134\do{% \advance\count@ by\@ne \newinsert\foobar \message{<\the\count@>}% } \@@end Yours sincerely Heiko