Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id s476hdwU020616 for ; Wed, 7 May 2014 08:43:40 +0200 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx107) with ESMTPS (Nemesis) id 0M0K9p-1Wxx3g2Ilp-00uWWg for ; Wed, 07 May 2014 08:43:34 +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 s476eRZ5006282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 7 May 2014 08:40:27 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id s46M13uq001573; Wed, 7 May 2014 08:40:25 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 10865571 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 7 May 2014 08:40:25 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id s476ePw8012561 for ; Wed, 7 May 2014 08:40:25 +0200 Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id s476eHBa012323 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Wed, 7 May 2014 08:40:20 +0200 Received: by mail-ee0-f42.google.com with SMTP id d49so344116eek.29 for ; Tue, 06 May 2014 23:40:17 -0700 (PDT) X-Received: by 10.14.176.193 with SMTP id b41mr14552961eem.55.1399444817815; Tue, 06 May 2014 23:40:17 -0700 (PDT) Received: from mellon.site (p54804B89.dip0.t-ipconnect.de. [84.128.75.137]) by mx.google.com with ESMTPSA id x43sm44182338eeo.26.2014.05.06.23.40.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 May 2014 23:40:17 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 References: <5366C875.9040709@googlemail.com> <5367453E.3030906@morningstar2.co.uk> <5369962B.2020905@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Message-ID: <5369D54F.10503@googlemail.com> Date: Wed, 7 May 2014 08:40:15 +0200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Heiko Oberdiek Subject: Re: \__dim_strip_bp:n To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <5369962B.2020905@gmail.com> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:Qpoy4ymkd8M=:rR3Oy3BcWW3ckrLyqC27alNl/F OtYOZ4tyQiwGJXqn5iJYzfz8TMMdNgWROzmrhsSONNcmojG118VGqEP+IP4zgwRzhoCpFzMsy r4VDrmXcCDeExfgrmGXQtbOL6jQHcKyFf7WCDDz7oxx1Q+k4dkOkTTKV+qqTOuYDaPX+OdldO zLI3TKgv6EenId9h82mYv6fzLdCsMM6NSsnWOx8gNACJ6B9qKonRqCkwU8gCjMEfJhWx3XOez 7OpmeQic+N5/I6+T4a58YTaee84eOJ1EB9vjQy+Uj3ZuYZjgRUn1lVsgVQSTjx4AevpGSP0Ha FBfHhF9VpTuEpXBJsNSRp7SExEu6OKDl4+jv1T+aMiHJqt1SizA7LKPWJOUgojXGXl78zL/gc w9U/54Q6sDJ3NbU0m0DSPJs+AUzgUtQrxAKXhrbQXbmrjudIOYms3ILc5apLsXmNOVLbI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xPZs/JNixTD1ZG69SPrGqcmxWGWF2flhT6ClgT7WpQ= Status: R X-Status: X-Keywords: X-UID: 7398 On 07.05.2014 04:10, Qing Lee wrote: > On 2014-05-05 at 16:01:02 +0800 GMT, Joseph Wright wrote: >> On 05/05/2014 00:08, Heiko Oberdiek wrote: >>> \cs_new:Npn \__dim_strip_bp:n #1 >>> { \__dim_strip_pt:n { 0.996 26 \__dim_eval:w #1 \__dim_eval_end: >>> } } >>> \dimexpr 0.99626\dimexpr #1\relax\relax >>> Improved version with higher precision: >>> >>> \cs_new:Npn \__dim_strip_bp:n #1 >>> { >>> \__dim_strip_pt:n >>> { >>> \__dim_eval:w ( #1 ) * 800 / 803 \__dim_eval_end: >>> } >>> } > The new definition will be broken if its argument contains additional > units. E.g., > > \__dim_strip_bp:n { 1 bp pt } The second "unit" is just additional text that serves no purpose other than invalidating the argument. In the old version, the argument is put into: \dimexpr 1bp pt \relax A better syntax for e-TeX's \dimexpr would have been: \dimexpr{...} or at least ending the expression with a *mandatory* \relax: \dimexpr ...\relax With an optionally \relax, the dimen expression ends with the first token that does not belong to the expression, in this case it is the letter "p". However the additional text will *not* go away and will very likely causing trouble some time later, a more mysterious error message or even worse, the text could go silently into the output. Adding parentheses around "#1" gets an input validation check for free. I seriously doubt that \__dim_strip_bp:n should accept something like \__dim_strip_bp:n { 1 bp Lorem ipsum dolor sit ... } Also look at the names: \__dim_eval:w #1 \__dim_eval_end: The intention is very clear, that \__dim_eval_end: is meant to *end* the dimen expression, not to add an additional \relax in the input token list. Therefore I think, that the new version is also an improvement for invalid arguments, because most cases of illegal input are detected and this happens at an earlier stage, that makes debugging and hunting the bug easier, that had introduced the additional text. Best regards Heiko Oberdiek