mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
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
This commit is contained in:
parent
3c7cf7f5c0
commit
eca29b0202
5 changed files with 29 additions and 8 deletions
|
@ -125,6 +125,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <uniconv.h>
|
||||||
|
|
||||||
#define pf printf
|
#define pf printf
|
||||||
|
|
||||||
|
@ -424,6 +425,14 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
pf ("#define SCM_HAVE_ARRAYS 1 /* always true now */\n");
|
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");
|
printf ("#endif\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ scm_lfwrite_substr (SCM str, size_t start, size_t end, SCM port)
|
||||||
size = end - start;
|
size = end - start;
|
||||||
|
|
||||||
buf = scm_to_stringn (scm_c_substring (str, start, end), &len,
|
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);
|
ptob->write (port, buf, len);
|
||||||
free (buf);
|
free (buf);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <uniconv.h>
|
||||||
#include <unictype.h>
|
#include <unictype.h>
|
||||||
|
|
||||||
#include "libguile/_scm.h"
|
#include "libguile/_scm.h"
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistr.h>
|
#include <unistr.h>
|
||||||
|
#include <uniconv.h>
|
||||||
|
|
||||||
#include "libguile/_scm.h"
|
#include "libguile/_scm.h"
|
||||||
#include "libguile/chars.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. */
|
/* In the future, enc will hold the port's encoding. */
|
||||||
enc = NULL;
|
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. */
|
/* Low-level scheme to C string conversion function. */
|
||||||
char *
|
char *
|
||||||
scm_to_stringn (SCM str, size_t * lenp, const char *encoding,
|
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";
|
static const char iso[11] = "ISO-8859-1";
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -1527,14 +1529,14 @@ scm_to_stringn (SCM str, size_t * lenp, const char *encoding,
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
buf = u32_conv_to_encoding (iso,
|
buf = u32_conv_to_encoding (iso,
|
||||||
handler,
|
(enum iconv_ilseq_handler) handler,
|
||||||
(scm_t_uint32 *) scm_i_string_wide_chars (str),
|
(scm_t_uint32 *) scm_i_string_wide_chars (str),
|
||||||
ilen, NULL, NULL, &len);
|
ilen, NULL, NULL, &len);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
scm_misc_error (NULL, "cannot convert to output locale ~s: \"~s\"",
|
scm_misc_error (NULL, "cannot convert to output locale ~s: \"~s\"",
|
||||||
scm_list_2 (scm_from_locale_string (iso), str));
|
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);
|
unistring_escapes_to_guile_escapes (&buf, &len);
|
||||||
|
|
||||||
if (lenp)
|
if (lenp)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#ifndef SCM_STRINGS_H
|
#ifndef SCM_STRINGS_H
|
||||||
#define 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <uniconv.h>
|
|
||||||
#include "libguile/__scm.h"
|
#include "libguile/__scm.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,6 +89,15 @@
|
||||||
no wide version of this interface.
|
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_p (SCM x);
|
||||||
SCM_API SCM scm_string (SCM chrs);
|
SCM_API SCM scm_string (SCM chrs);
|
||||||
SCM_API SCM scm_make_string (SCM k, SCM chr);
|
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_API char *scm_to_locale_stringn (SCM str, size_t *lenp);
|
||||||
SCM_INTERNAL char *scm_to_stringn (SCM str, size_t *lenp,
|
SCM_INTERNAL char *scm_to_stringn (SCM str, size_t *lenp,
|
||||||
const char *encoding,
|
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 size_t scm_to_locale_stringbuf (SCM str, char *buf, size_t max_len);
|
||||||
|
|
||||||
SCM_API SCM scm_makfromstrs (int argc, char **argv);
|
SCM_API SCM scm_makfromstrs (int argc, char **argv);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue