*** empty log message ***
[bpt/guile.git] / libguile / gh_data.c
index 9c21042..39d467c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998, 1999, 2000 Free Software Foundation, Inc.
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
 #include <stdio.h>
 
 #include <gh.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
 
 /* data conversion C->scheme */
 SCM 
 gh_int2scmb (int x)            /* this is being phased out */
 {
-  return (x ? SCM_BOOL_T : SCM_BOOL_F);
+  return SCM_BOOL(x);
 }
 SCM 
 gh_bool2scm (int x)
 {
-  return (x ? SCM_BOOL_T : SCM_BOOL_F);
+  return SCM_BOOL(x);
 }
 SCM 
 gh_int2scm (int x)
@@ -79,15 +82,15 @@ gh_double2scm (double x)
 SCM 
 gh_char2scm (char c)
 {
- return SCM_MAKICHR (c);
+ return SCM_MAKE_CHAR (c);
 }
 SCM 
-gh_str2scm (char *s, int len)
+gh_str2scm (const char *s, int len)
 {
   return scm_makfromstr (s, len, 0);
 }
 SCM 
-gh_str02scm (char *s)
+gh_str02scm (const char *s)
 {
   return scm_makfrom0str (s);
 }
@@ -104,7 +107,7 @@ gh_set_substr (char *src, SCM dst, int start, int len)
   unsigned long dst_len;
   unsigned long effective_length;
 
-  SCM_ASSERT (SCM_NIMP (dst) && SCM_STRINGP (dst), dst, SCM_ARG3,
+  SCM_ASSERT (SCM_STRINGP (dst), dst, SCM_ARG3,
              "gh_set_substr");
 
   dst_ptr = SCM_CHARS (dst);
@@ -200,8 +203,6 @@ gh_ulongs2uvect (unsigned long *d, int n)
   return makvect (m, n, scm_tc7_uvect);
 }
 
-#ifdef SCM_FLOATS
-#ifdef SCM_SINGLES
 SCM
 gh_floats2fvect (float *d, int n)
 {
@@ -209,7 +210,6 @@ gh_floats2fvect (float *d, int n)
   memcpy (m, d, n * sizeof (float));
   return makvect (m, n, scm_tc7_fvect);
 }
-#endif
 
 SCM
 gh_doubles2dvect (double *d, int n)
@@ -219,7 +219,6 @@ gh_doubles2dvect (double *d, int n)
   return makvect (m, n, scm_tc7_dvect);
 }
 #endif
-#endif
 
 /* data conversion scheme->C */
 int 
@@ -251,7 +250,7 @@ gh_scm2double (SCM obj)
 char 
 gh_scm2char (SCM obj)
 {
-  return SCM_ICHR (obj);
+  return SCM_CHAR (obj);
 }
 
 /* Convert a vector, weak vector, string, substring or uniform vector
@@ -366,7 +365,7 @@ gh_scm2longs (SCM obj, long *m)
       for (i = 0; i < n; ++i)
        {
          val = SCM_VELTS (obj)[i];
-         if (!SCM_INUMP (val) && !(SCM_NIMP (val) && SCM_BIGP (val)))
+         if (!SCM_INUMP (val) && !SCM_BIGP (val))
            scm_wrong_type_arg (0, 0, obj);
        }
       if (m == 0)
@@ -410,7 +409,7 @@ gh_scm2floats (SCM obj, float *m)
        {
          val = SCM_VELTS (obj)[i];
          if (!SCM_INUMP (val)
-             && !(SCM_NIMP (val) && (SCM_BIGP (val) || SCM_REALP (val))))
+             && !(SCM_BIGP (val) || SCM_REALP (val)))
            scm_wrong_type_arg (0, 0, val);
        }
       if (m == 0)
@@ -427,15 +426,13 @@ gh_scm2floats (SCM obj, float *m)
        }
       break;
 #ifdef HAVE_ARRAYS
-#ifdef SCM_FLOATS
-#ifdef SCM_SINGLES
     case scm_tc7_fvect:
       n = SCM_LENGTH (obj);
       if (m == 0)
        m = (float *) malloc (n * sizeof (float));
       memcpy (m, (float *) SCM_VELTS (obj), n * sizeof (float));
       break;
-#endif
+
     case scm_tc7_dvect:
       n = SCM_LENGTH (obj);
       if (m == 0)
@@ -443,7 +440,6 @@ gh_scm2floats (SCM obj, float *m)
       for (i = 0; i < n; ++i)
        m[i] = ((double *) SCM_VELTS (obj))[i];
       break;
-#endif
 #endif
     default:
       scm_wrong_type_arg (0, 0, obj);
@@ -469,7 +465,7 @@ gh_scm2doubles (SCM obj, double *m)
        {
          val = SCM_VELTS (obj)[i];
          if (!SCM_INUMP (val)
-             && !(SCM_NIMP (val) && (SCM_BIGP (val) || SCM_REALP (val))))
+             && !(SCM_BIGP (val) || SCM_REALP (val)))
            scm_wrong_type_arg (0, 0, val);
        }
       if (m == 0)
@@ -486,8 +482,6 @@ gh_scm2doubles (SCM obj, double *m)
        }
       break;
 #ifdef HAVE_ARRAYS
-#ifdef SCM_FLOATS
-#ifdef SCM_SINGLES
     case scm_tc7_fvect:
       n = SCM_LENGTH (obj);
       if (m == 0)
@@ -495,14 +489,13 @@ gh_scm2doubles (SCM obj, double *m)
       for (i = 0; i < n; ++i)
        m[i] = ((float *) SCM_VELTS (obj))[i];
       break;
-#endif
+
     case scm_tc7_dvect:
       n = SCM_LENGTH (obj);
       if (m == 0)
        m = (double*) malloc (n * sizeof (double));
       memcpy (m, SCM_VELTS (obj), n * sizeof (double));
       break;
-#endif
 #endif
     default:
       scm_wrong_type_arg (0, 0, obj);
@@ -530,7 +523,7 @@ gh_scm2newstr (SCM str, int *lenp)
   char *ret_str;
   int len;
 
-  SCM_ASSERT (SCM_NIMP (str) && SCM_ROSTRINGP (str), str, SCM_ARG3,
+  SCM_ASSERT (SCM_ROSTRINGP (str), str, SCM_ARG3,
              "gh_scm2newstr");
 
   /* protect str from GC while we copy off its data */
@@ -567,7 +560,7 @@ void
 gh_get_substr (SCM src, char *dst, int start, int len)
 {
   int src_len, effective_length;
-  SCM_ASSERT (SCM_NIMP (src) && SCM_ROSTRINGP (src), src, SCM_ARG3,
+  SCM_ASSERT (SCM_ROSTRINGP (src), src, SCM_ARG3,
              "gh_get_substr");
 
   scm_protect_object (src);
@@ -592,7 +585,7 @@ gh_symbol2newstr (SCM sym, int *lenp)
   char *ret_str;
   int len;
 
-  SCM_ASSERT (SCM_NIMP (sym) && SCM_SYMBOLP (sym), sym, SCM_ARG3,
+  SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG3,
              "gh_scm2newsymbol");
 
   /* protect str from GC while we copy off its data */