1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

Do not apply inf?' or nan?' to strings

* module/ice-9/format.scm (format): Test to make sure an argument is a
  number before applying `inf?' and `nan?' to it.  Formerly, format
  would call `inf?' and `nan?' on arguments that might be either a
  number or a string, although those predicates should ideally throw an
  exception when applied to non-number objects.
This commit is contained in:
Mark H Weaver 2011-01-25 18:35:22 -05:00 committed by Andy Wingo
parent b56c252b52
commit 6a07a06118

View file

@ -1,5 +1,5 @@
;;;; "format.scm" Common LISP text output formatter for SLIB
;;; Copyright (C) 2010 Free Software Foundation, Inc.
;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
;;;
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public
@ -1079,7 +1079,8 @@
(padch (format:par pars l 4 format:space-ch #f)))
(cond
((or (inf? number) (nan? number))
((and (number? number)
(or (inf? number) (nan? number)))
(format:out-inf-nan number width digits #f overch padch))
(digits
@ -1140,7 +1141,8 @@
(expch (format:par pars l 6 #f #f)))
(cond
((or (inf? number) (nan? number))
((and (number? number)
(or (inf? number) (nan? number)))
(format:out-inf-nan number width digits edigits overch padch))
(digits ; fixed precision
@ -1231,7 +1233,8 @@
(overch (if (> l 4) (list-ref pars 4) #f))
(padch (if (> l 5) (list-ref pars 5) #f)))
(cond
((or (inf? number) (nan? number))
((and (number? number)
(or (inf? number) (nan? number)))
;; FIXME: this isn't right.
(format:out-inf-nan number width digits edigits overch padch))
(else
@ -1265,7 +1268,8 @@
(padch (format:par pars l 3 format:space-ch #f)))
(cond
((or (inf? number) (nan? number))
((and (number? number)
(or (inf? number) (nan? number)))
(format:out-inf-nan number width digits #f #f padch))
(else