From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#11887: string->number edge cases Date: Tue, 05 Mar 2013 14:04:55 -0500 Message-ID: <878v61ekh4.fsf@tines.lan> References: <87sjd1qfs3.fsf@Kagami.home> <87txopyk9i.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1362510350 5252 80.91.229.3 (5 Mar 2013 19:05:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Mar 2013 19:05:50 +0000 (UTC) Cc: Ian Price , Peter.Bex@xs4all.nl, 11887@debbugs.gnu.org To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Mar 05 20:06:13 2013 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UCxBh-00073x-PN for guile-bugs@m.gmane.org; Tue, 05 Mar 2013 20:06:09 +0100 Original-Received: from localhost ([::1]:46094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCxBM-0007Dq-3Y for guile-bugs@m.gmane.org; Tue, 05 Mar 2013 14:05:48 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCxBG-0007DU-VD for bug-guile@gnu.org; Tue, 05 Mar 2013 14:05:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCxBE-0007JZ-Te for bug-guile@gnu.org; Tue, 05 Mar 2013 14:05:42 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCxBE-0007JV-QG for bug-guile@gnu.org; Tue, 05 Mar 2013 14:05:40 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UCxBa-0000rs-B4 for bug-guile@gnu.org; Tue, 05 Mar 2013 14:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 05 Mar 2013 19:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11887 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 11887-submit@debbugs.gnu.org id=B11887.13625103363300 (code B ref 11887); Tue, 05 Mar 2013 19:06:02 +0000 Original-Received: (at 11887) by debbugs.gnu.org; 5 Mar 2013 19:05:36 +0000 Original-Received: from localhost ([127.0.0.1]:32891 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UCxB9-0000rB-PO for submit@debbugs.gnu.org; Tue, 05 Mar 2013 14:05:36 -0500 Original-Received: from world.peace.net ([96.39.62.75]:49223 ident=hope5) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UCxB7-0000r3-11 for 11887@debbugs.gnu.org; Tue, 05 Mar 2013 14:05:34 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UCxAe-0003Ev-92; Tue, 05 Mar 2013 14:05:04 -0500 In-Reply-To: <87txopyk9i.fsf@pobox.com> (Andy Wingo's message of "Tue, 05 Mar 2013 15:49:13 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6849 Archived-At: Andy Wingo writes: > On Mon 09 Jul 2012 14:29, Ian Price writes: > >> If the number contains a division by zero, we get a numerical overflow >> error. >> >> scheme@(guile=E2=88=92user)> (string->number "3/0") >> ERROR: In procedure string=E2=88=92>number: >> ERROR: Throw to key `numerical=E2=88=92overflow' with args `("make=E2=88= =92ratio" "Numerical overflow" #f #f)'. > > This is also an error. We should plumb through some extra arg to > mem2ureal, I guess, to check for a zero denominator. FYI, I produced a simple patch a while back to fix this (see below), but it had an interesting side effect: it caused the reader to read things like "3/0" and "4+3/0i" as symbols. More generally, anything for which 'scm_string_to_number' returns false is treated as a symbol by 'read'. I'm not sure how I feel about this. What do you think? Mark diff --git a/libguile/numbers.c b/libguile/numbers.c index 66c95db..9013f0c 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -5809,7 +5809,7 @@ mem2ureal (SCM mem, unsigned int *p_idx, return SCM_BOOL_F; =20 divisor =3D mem2uinteger (mem, &idx, radix, &implicit_x); - if (scm_is_false (divisor)) + if (scm_is_false (divisor) || scm_is_eq (divisor, SCM_INUM0)) return SCM_BOOL_F; =20 /* both are int/big here, I assume */