From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/43623 Path: news.gmane.org!not-for-mail From: Khaled Hosny Newsgroups: gmane.comp.tex.context Subject: Re: bug with numeral conversion function Date: Tue, 2 Sep 2008 12:33:04 +0200 Message-ID: <20080902103304.GA23383@khaled-laptop> References: <20080822214647.GB25071@khaled-laptop> <20080901172643.GA32000@khaled-laptop> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1299748112==" X-Trace: ger.gmane.org 1220351707 5824 80.91.229.12 (2 Sep 2008 10:35:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Sep 2008 10:35:07 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Sep 02 12:35:59 2008 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1KaTEs-0006Pq-Ez for gctc-ntg-context-518@m.gmane.org; Tue, 02 Sep 2008 12:35:58 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 03B071FC5A; Tue, 2 Sep 2008 12:34:56 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25496-01-48; Tue, 2 Sep 2008 12:34:08 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id A884F1FD37; Tue, 2 Sep 2008 12:34:08 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 174701FD37 for ; Tue, 2 Sep 2008 12:34:04 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25496-01-47 for ; Tue, 2 Sep 2008 12:33:27 +0200 (CEST) Original-Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.186]) by ronja.ntg.nl (Postfix) with ESMTP id D74151FBCC for ; Tue, 2 Sep 2008 12:33:26 +0200 (CEST) Original-Received: by mu-out-0910.google.com with SMTP id w9so2104690mue.4 for ; Tue, 02 Sep 2008 03:33:26 -0700 (PDT) Original-Received: by 10.103.169.1 with SMTP id w1mr5156217muo.107.1220351606220; Tue, 02 Sep 2008 03:33:26 -0700 (PDT) Original-Received: from localhost ( [41.234.93.231]) by mx.google.com with ESMTPS id y6sm36587827mug.7.2008.09.02.03.33.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 02 Sep 2008 03:33:24 -0700 (PDT) In-Reply-To: <20080901172643.GA32000@khaled-laptop> User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:43623 Archived-At: --===============1299748112== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4bRzO86E/ozDv8r1" Content-Disposition: inline --4bRzO86E/ozDv8r1 Content-Type: multipart/mixed; boundary="C7zPtVaVf+AK4Oqc" Content-Disposition: inline --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 01, 2008 at 07:26:43PM +0200, Khaled Hosny wrote: > Now, I think I discovered another bug (or feature?), the function will > ignore any zeros at the left which isn't what one expects. This happen to be some thing in Lua itself: s =3D 000123 print(s) will give 123, so it have to be a string to keep the to the left zeros. I rewrote the converters.alphabetic() and converters.Alphabetic() so that it will not expect a number and will just iterate through the given string, and now \arabicnumerals and its brothers will pass strings to it. Also I found that \abjadnumerals were referring to converters.arabicnumerals witch doesn't exist, I changed it to=20 converters.abjadnumerals but there is no converters.abjadnaivenumerals and I've no idea what it is supposed to do. See the attached patch and tell me what you think. --=20 Khaled Hosny Arabic localizer and member of Arabeyes.org team --C7zPtVaVf+AK4Oqc Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="numerals.diff" Content-Transfer-Encoding: quoted-printable diff -Naur cont-tmf/tex/context/base/core-con.lua cont-tmf.local/tex/contex= t/base/core-con.lua --- cont-tmf/tex/context/base/core-con.lua 2008-06-24 23:02:50.000000000 +0= 300 +++ cont-tmf.local/tex/context/base/core-con.lua 2008-09-02 12:01:17.000000= 000 +0200 @@ -102,22 +102,22 @@ texsprint(utfchar(n+m)) end =20 -local function do_alphabetic(n,max,chr) - if n > max then - do_alphabetic(floor((n-1)/max),max,chr) - n =3D (n-1)%max+1 - end - characters.flush(chr(n)) -end - function converters.alphabetic(n,code) local code =3D counters[code] or counters['**'] - do_alphabetic(n,#code,function(n) return code[n] or fallback end) + for c in string.characters(n) do + local c =3D c + 1 + local chr =3D function(n) return code[n] or fallback end + characters.flush(chr(c)) + end end =20 function converters.Alphabetic(n,code) local code =3D counters[code] or counters['**'] - do_alphabetic(n,#code,function(n) return characters.uccode(code[n] or = fallback) end) + for c in string.characters(n) do + local c =3D c + 1 + local chr =3D function(n) return characters.uccode(code[n] or fallback) e= nd + characters.flush(chr(c)) + end end =20 function converters.character(n) converters.chr (n,96) end diff -Naur cont-tmf/tex/context/base/core-con.mkiv cont-tmf.local/tex/conte= xt/base/core-con.mkiv --- cont-tmf/tex/context/base/core-con.mkiv 2008-06-24 22:55:44.000000000 += 0300 +++ cont-tmf.local/tex/context/base/core-con.mkiv 2008-09-02 12:17:49.00000= 0000 +0200 @@ -17,8 +17,8 @@ =20 \def\romannumerals #1{\ctxlua{converters.romannumerals(\number#1)}} \def\Romannumerals #1{\ctxlua{converters.Romannumerals(\number#1)}} -\def\abjadnumerals #1{\ctxlua{converters.arabicnumerals(\number#1)}} -\def\abjadnodotnumerals #1{\ctxlua{converters.arabicnodotnumerals(\number#= 1)}} +\def\abjadnumerals #1{\ctxlua{converters.abjadnumerals(\number#1)}} +\def\abjadnodotnumerals #1{\ctxlua{converters.abjadnodotnumerals(\number#1= )}} \def\abjadnaivenumerals #1{\ctxlua{converters.arabicnaivenumerals(\number#= 1)}} =20 \defineconversion [romannumerals] [\romannumerals] @@ -32,8 +32,8 @@ \def\characters#1{\ctxlua{converters.characters(\number#1)}} \def\Characters#1{\ctxlua{converters.Characters(\number#1)}} =20 -\def\languagecharacters#1{\ctxlua{converters.alphabetic(\number#1,"\curren= tlanguage")}} % new -\def\languageCharacters#1{\ctxlua{converters.Alphabetic(\number#1,"\curren= tlanguage")}} % new +\def\languagecharacters#1{\ctxlua{converters.alphabetic("#1","\currentlang= uage")}} % new +\def\languageCharacters#1{\ctxlua{converters.Alphabetic("#1","\currentlang= uage")}} % new =20 \def\getdayoftheweek#1#2#3{\normalweekday\ctxlua{converters.weekday(\numbe= r#1,\number#2,\number#3)}} \def\dayoftheweek #1#2#3{\doconvertday{\ctxlua{converters.weekday(\numbe= r#1,\number#2,\number#3)}}} @@ -73,19 +73,19 @@ =20 % we could use an auxiliary macro to save some bytes in the format % -% \def\dolanguagecharacters#1#2{\ctxlua{converters.alphabetic(\number#2,"#= 1")}} +% \def\dolanguagecharacters#1#2{\ctxlua{converters.alphabetic("#2","#1")}} =20 % this does not belong here, but in a lang-module =20 -\def\thainumerals #1{\ctxlua{converters.alphabetic(\number#1,"thai")}} -\def\devanagarinumerals#1{\ctxlua{converters.alphabetic(\number#1,"devanag= ari")}} -\def\gurmurkhinumerals #1{\ctxlua{converters.alphabetic(\number#1,"gurmurk= hi")}} -\def\gujaratinumerals #1{\ctxlua{converters.alphabetic(\number#1,"gujarat= i")}} -\def\tibetannumerals #1{\ctxlua{converters.alphabetic(\number#1,"tibetan= ")}} -\def\greeknumerals #1{\ctxlua{converters.alphabetic(\number#1,"greek")= }} -\def\Greeknumerals #1{\ctxlua{converters.Alphabetic(\number#1,"greek")= }} -\def\arabicnumerals #1{\ctxlua{converters.alphabetic(\number#1,"arabic"= )}} -\def\persiannumerals #1{\ctxlua{converters.alphabetic(\number#1,"persian= ")}} +\def\thainumerals #1{\ctxlua{converters.alphabetic("#1","thai")}} +\def\devanagarinumerals#1{\ctxlua{converters.alphabetic("#1","devanagari")= }} +\def\gurmurkhinumerals #1{\ctxlua{converters.alphabetic("#1","gurmurkhi")}} +\def\gujaratinumerals #1{\ctxlua{converters.alphabetic("#1","gujarati")}} +\def\tibetannumerals #1{\ctxlua{converters.alphabetic("#1","tibetan")}} +\def\greeknumerals #1{\ctxlua{converters.alphabetic("#1","greek")}} +\def\Greeknumerals #1{\ctxlua{converters.Alphabetic("#1","greek")}} +\def\arabicnumerals #1{\ctxlua{converters.alphabetic("#1","arabic")}} +\def\persiannumerals #1{\ctxlua{converters.alphabetic("#1","persian")}} =20 \let\arabicexnumerals \persiannumerals =20 diff -Naur cont-tmf/tex/context/base/lang-sla.mkiv cont-tmf.local/tex/conte= xt/base/lang-sla.mkiv --- cont-tmf/tex/context/base/lang-sla.mkiv 2007-08-15 20:38:03.000000000 += 0300 +++ cont-tmf.local/tex/context/base/lang-sla.mkiv 2008-09-02 12:07:45.00000= 0000 +0200 @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. =20 -\def\sloveniancharacters#1{\ctxlua{converters.alphabetic(\number#1,"sl")}} -\def\slovenianCharacters#1{\ctxlua{converters.Alphabetic(\number#1,"sl")}} +\def\sloveniancharacters#1{\ctxlua{converters.alphabetic("#1","sl")}} +\def\slovenianCharacters#1{\ctxlua{converters.Alphabetic("#1","sl")}} =20 \endinput --C7zPtVaVf+AK4Oqc-- --4bRzO86E/ozDv8r1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAki9FmAACgkQRoqITGOuyPJTiQCeM/CMZNcOBxIcPcP/a573VJDw ExAAnjVbClq9w0OJrFkGGbC8T27EdCzw =uAAP -----END PGP SIGNATURE----- --4bRzO86E/ozDv8r1-- --===============1299748112== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============1299748112==--