[gimp] R5RS compatability fixes for integer? and round (SourceForge bug #3400284)



commit 01a24fb4f75ecd22a3fc8ba7ef15053c5472fc65
Author: Kevin Cozens <kcozens svn gnome org>
Date:   Tue Aug 30 16:53:17 2011 -0400

    R5RS compatability fixes for integer? and round (SourceForge bug #3400284)

 plug-ins/script-fu/tinyscheme/scheme.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/script-fu/tinyscheme/scheme.c b/plug-ins/script-fu/tinyscheme/scheme.c
index 8f88647..6f8273a 100644
--- a/plug-ins/script-fu/tinyscheme/scheme.c
+++ b/plug-ins/script-fu/tinyscheme/scheme.c
@@ -216,7 +216,11 @@ INTERFACE static pointer vector_elem(pointer vec, int ielem);
 INTERFACE static pointer set_vector_elem(pointer vec, int ielem, pointer a);
 INTERFACE INLINE int is_number(pointer p)    { return (type(p)==T_NUMBER); }
 INTERFACE INLINE int is_integer(pointer p) {
-  return is_number(p) && ((p)->_object._number.is_fixnum);
+  if (!is_number(p))
+      return 0;
+  if (num_is_integer(p) || rvalue(p) == round_per_R5RS(rvalue(p)))
+      return 1;
+  return 0;
 }
 
 INTERFACE INLINE int is_real(pointer p) {
@@ -3379,8 +3383,11 @@ static pointer opexe_2(scheme *sc, enum scheme_opcodes op) {
      }
 
      case OP_ROUND:
-       x=car(sc->args);
-       s_return(sc, mk_real(sc, round_per_R5RS(rvalue(x))));
+        x=car(sc->args);
+        if (num_is_integer(x))
+            s_return(sc, mk_integer(sc, round_per_R5RS(rvalue(x))));
+        else
+            s_return(sc, mk_real(sc, round_per_R5RS(rvalue(x))));
 #endif
 
      case OP_ADD:        /* + */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]