]> git.donarmstrong.com Git - lilypond.git/commitdiff
Create ly_is_rational predicate that allows exact rationals and infinities
authorDavid Kastrup <dak@gnu.org>
Mon, 23 Jul 2012 09:39:39 +0000 (11:39 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 27 Jul 2012 05:28:12 +0000 (07:28 +0200)
lily/include/lily-guile.hh
lily/lily-guile.cc

index 059e5aa0cc49ba4f1d8bf49a1019f8455758b494..f2b8f08ba17bfa00fcae3aacf13035d68a30aa17 100644 (file)
@@ -103,6 +103,7 @@ inline bool ly_cheap_is_list (SCM x) { return scm_is_pair (x) || x == SCM_EOL; }
 inline bool ly_is_procedure (SCM x) { return scm_is_true (scm_procedure_p (x)); }
 inline bool ly_is_port (SCM x) { return scm_is_true (scm_port_p (x)); }
 
+bool ly_is_rational (SCM);
 /*
   want to take the address of this function; scm_is_symbol() is a
   macro.
index 9806f14d24f77fab36a921ac265ef044521f3e6b..96097e4cf0058bb8205ad83d9159ba88ce6d5a7e 100644 (file)
@@ -618,14 +618,20 @@ ly_scm2rational (SCM r)
 Rational
 robust_scm2rational (SCM n, Rational rat)
 {
-  if (scm_is_real (n)
-      && (scm_is_true (scm_exact_p (n))
-         || scm_is_true (scm_inf_p (n))))
+  if (ly_is_rational (n))
     return ly_scm2rational (n);
   else
     return rat;
 }
 
+bool
+ly_is_rational (SCM n)
+{
+  return (scm_is_real (n)
+         && (scm_is_true (scm_exact_p (n))
+             || scm_is_true (scm_inf_p (n))));
+}
+
 SCM
 alist_to_hashq (SCM alist)
 {