summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gran <spk121@yahoo.com>2009-08-12 08:30:59 -0700
committerMichael Gran <spk121@yahoo.com>2009-08-12 09:21:55 -0700
commiteca29b020267c477bddc3f9df6f087f461f7c8b9 (patch)
tree5ffcc678cd24cccc096fe5ae329d5302cc37413f
parent3c7cf7f5c04bf93222c133d5939badd75e627f6e (diff)
downloadguile-eca29b020267c477bddc3f9df6f087f461f7c8b9.tar.gz
Don't include libunistring headers in Guile public headers
This requres the creation of a new type scm_t_string_failed_conversion_handler to replace libunistring's enum iconveh_ilseq_handler. * libguile/strings.h: don't include <uniconv.h> (scm_t_string_failed_conversion_handler): new enum type (SCM_FAILED_CONVERSION_ERROR, SCM_FAILED_CONVERSION_QUESTION_MARK): (SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE): new enum type values * libguile/strings.c (scm_to_stringn): now takes type scm_t_string_failed_conversion_handler. All callers changed. * libguile/print.c: include <uniconv.h> * libguile/ports.c (scm_lfwrite_substr): use scm_t_string_conversion_handler's constants * libguile/gen-scmconfig.c (SCM_ICONVEH_ERROR): (SCM_ICONVEH_QUESTION_MARK, SCM_ICONVEH_ESCAPE_SEQUENCE): store iconveh_ilseq_hander constants as #define's
-rw-r--r--libguile/gen-scmconfig.c9
-rw-r--r--libguile/ports.c2
-rw-r--r--libguile/print.c1
-rw-r--r--libguile/strings.c10
-rw-r--r--libguile/strings.h15
5 files changed, 29 insertions, 8 deletions
diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c
index d5696381b..0e897ca8c 100644
--- a/libguile/gen-scmconfig.c
+++ b/libguile/gen-scmconfig.c
@@ -125,6 +125,7 @@
#include <stdio.h>
#include <string.h>
+#include <uniconv.h>
#define pf printf
@@ -424,6 +425,14 @@ main (int argc, char *argv[])
pf ("#define SCM_HAVE_ARRAYS 1 /* always true now */\n");
+ pf ("\n");
+ pf ("/* Constants from uniconv.h. */\n");
+ pf ("#define SCM_ICONVEH_ERROR %d\n", (int) iconveh_error);
+ pf ("#define SCM_ICONVEH_QUESTION_MARK %d\n",
+ (int) iconveh_question_mark);
+ pf ("#define SCM_ICONVEH_ESCAPE_SEQUENCE %d\n",
+ (int) iconveh_escape_sequence);
+
printf ("#endif\n");
return 0;
diff --git a/libguile/ports.c b/libguile/ports.c
index f51ab0032..60b21dd41 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -1024,7 +1024,7 @@ scm_lfwrite_substr (SCM str, size_t start, size_t end, SCM port)
size = end - start;
buf = scm_to_stringn (scm_c_substring (str, start, end), &len,
- NULL, iconveh_escape_sequence);
+ NULL, SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE);
ptob->write (port, buf, len);
free (buf);
diff --git a/libguile/print.c b/libguile/print.c
index 85f030e36..c398572ab 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -23,6 +23,7 @@
#endif
#include <errno.h>
+#include <uniconv.h>
#include <unictype.h>
#include "libguile/_scm.h"
diff --git a/libguile/strings.c b/libguile/strings.c
index 7bb277daf..03fb4b4b8 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <ctype.h>
#include <unistr.h>
+#include <uniconv.h>
#include "libguile/_scm.h"
#include "libguile/chars.h"
@@ -1473,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;
@@ -1527,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)
diff --git a/libguile/strings.h b/libguile/strings.h
index 8c06e4725..fe9162d25 100644
--- a/libguile/strings.h
+++ b/libguile/strings.h
@@ -3,7 +3,7 @@
#ifndef SCM_STRINGS_H
#define SCM_STRINGS_H
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2004, 2005, 2006, 2008, 2009 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 License
@@ -23,7 +23,6 @@
-#include <uniconv.h>
#include "libguile/__scm.h"
@@ -90,6 +89,15 @@
no wide version of this interface.
*/
+/* A type indicating what strategy to take when string locale
+ conversion is unsuccessful. */
+typedef enum
+{
+ SCM_FAILED_CONVERSION_ERROR = SCM_ICONVEH_ERROR,
+ SCM_FAILED_CONVERSION_QUESTION_MARK = SCM_ICONVEH_QUESTION_MARK,
+ SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE = SCM_ICONVEH_ESCAPE_SEQUENCE
+} scm_t_string_failed_conversion_handler;
+
SCM_API SCM scm_string_p (SCM x);
SCM_API SCM scm_string (SCM chrs);
SCM_API SCM scm_make_string (SCM k, SCM chr);
@@ -122,7 +130,8 @@ SCM_API char *scm_to_locale_string (SCM str);
SCM_API char *scm_to_locale_stringn (SCM str, size_t *lenp);
SCM_INTERNAL char *scm_to_stringn (SCM str, size_t *lenp,
const char *encoding,
- enum iconv_ilseq_handler handler);
+ scm_t_string_failed_conversion_handler
+ handler);
SCM_API size_t scm_to_locale_stringbuf (SCM str, char *buf, size_t max_len);
SCM_API SCM scm_makfromstrs (int argc, char **argv);