Thanks, Mike.
[bpt/guile.git] / libguile / strings.c
index 2e766c2..03fb4b4 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <unistr.h>
+#include <uniconv.h>
 
 #include "libguile/_scm.h"
 #include "libguile/chars.h"
@@ -1015,10 +1016,11 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
 
   /* Verify that this is a list of chars.  */
   i = scm_ilength (chrs);
+  SCM_ASSERT (i >= 0, chrs, SCM_ARG1, FUNC_NAME);
+
   len = (size_t) i;
   rest = chrs;
 
-  SCM_ASSERT (len >= 0, chrs, SCM_ARG1, FUNC_NAME);
   while (len > 0 && scm_is_pair (rest))
     {
       SCM elt = SCM_CAR (rest);
@@ -1472,13 +1474,14 @@ scm_to_locale_stringn (SCM str, size_t * lenp)
   /* In the future, enc will hold the port's encoding.  */
   enc = NULL;
 
-  return scm_to_stringn (str, lenp, enc, iconveh_escape_sequence);
+  return scm_to_stringn (str, lenp, enc, 
+                         SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE);
 }
 
 /* Low-level scheme to C string conversion function.  */
 char *
 scm_to_stringn (SCM str, size_t * lenp, const char *encoding,
-                enum iconv_ilseq_handler handler)
+                scm_t_string_failed_conversion_handler handler)
 {
   static const char iso[11] = "ISO-8859-1";
   char *buf;
@@ -1526,14 +1529,14 @@ scm_to_stringn (SCM str, size_t * lenp, const char *encoding,
   buf = NULL;
   len = 0;
   buf = u32_conv_to_encoding (iso,
-                              handler,
+                              (enum iconv_ilseq_handler) handler,
                               (scm_t_uint32 *) scm_i_string_wide_chars (str),
                               ilen, NULL, NULL, &len);
   if (buf == NULL)
     scm_misc_error (NULL, "cannot convert to output locale ~s: \"~s\"",
                     scm_list_2 (scm_from_locale_string (iso), str));
 
-  if (handler == iconveh_escape_sequence)
+  if (handler == SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE)
     unistring_escapes_to_guile_escapes (&buf, &len);
 
   if (lenp)