Merge commit 'cbee5075d69cb057c4af4c5e24319da90367897f' into vm-check
[bpt/guile.git] / srfi / srfi-60.c
index 48d1a3e..7d89ca0 100644 (file)
@@ -1,6 +1,6 @@
 /* srfi-60.c --- Integers as Bits
  *
- * Copyright (C) 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2006, 2008 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
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <libguile.h>
-#include "libguile/private-gc.h"  /* for SCM_MIN */
-#include "srfi-60.h"
+#include <srfi/srfi-60.h>
 
 
 SCM_DEFINE (scm_srfi60_log2_binary_factors, "log2-binary-factors", 1, 0, 0,
@@ -86,7 +89,7 @@ SCM_DEFINE (scm_srfi60_copy_bit, "copy-bit", 3, 0, 0,
       if (ii < SCM_LONG_BIT-1)
         {
           nn &= ~(1L << ii);  /* zap bit at index */
-          nn |= (bb << ii);   /* insert desired bit */
+          nn |= ((long) bb << ii);   /* insert desired bit */
           return scm_from_long (nn);
         }
       else
@@ -332,7 +335,9 @@ SCM_DEFINE (scm_srfi60_integer_to_list, "integer->list", 1, 1, 0,
       long nn = SCM_I_INUM (n);
       for (i = 0; i < ll; i++)
         {
-          unsigned long shift = SCM_MIN (i, (unsigned long) SCM_LONG_BIT-1);
+          unsigned long shift =
+           (i < ((unsigned long) SCM_LONG_BIT-1)) 
+           ? i : ((unsigned long) SCM_LONG_BIT-1);
           int bit = (nn >> shift) & 1;
           ret = scm_cons (scm_from_bool (bit), ret);
         }
@@ -403,8 +408,9 @@ SCM_DEFINE (scm_srfi60_list_to_integer, "list->integer", 1, 0, 0,
 #undef FUNC_NAME
 
 
-SCM_REGISTER_PROC (s_srfi60_booleans_to_integer, "booleans->integer", 0, 0, 1,
-                   scm_srfi60_list_to_integer);
+/* note: don't put "scm_srfi60_list_to_integer" arg on its own line, a
+   newline breaks the snarfer */
+SCM_REGISTER_PROC (s_srfi60_booleans_to_integer, "booleans->integer", 0, 0, 1, scm_srfi60_list_to_integer);
 
 
 void