From 453036dff9bee23d260e5eac25d31495b3f0976f Mon Sep 17 00:00:00 2001 From: djcb Date: Fri, 13 Jan 2012 00:43:44 +0200 Subject: [PATCH] * mu-guile: make the string functions save against b0rked utf-8 --- guile/mu-guile.c | 13 +++++++------ guile/mu-guile.h | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/guile/mu-guile.c b/guile/mu-guile.c index 74e01b30..2221819f 100644 --- a/guile/mu-guile.c +++ b/guile/mu-guile.c @@ -37,13 +37,13 @@ SCM -scm_from_str_or_null (const char *str) +mu_guile_scm_from_str (const char *str) { if (!str) return SCM_BOOL_F; - - return scm_from_stringn (str, strlen(str), "UTF-8", - SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE); + else + return scm_from_stringn (str, strlen(str), "UTF-8", + SCM_FAILED_CONVERSION_QUESTION_MARK); } @@ -56,7 +56,7 @@ mu_guile_error (const char *func_name, int status, scm_from_utf8_string (fmt), args, scm_list_1 (scm_from_int (status))); - return SCM_BOOL_F; + return SCM_UNSPECIFIED; } SCM @@ -67,12 +67,13 @@ mu_guile_g_error (const char *func_name, GError *err) scm_from_utf8_string (err ? err->message : "error"), SCM_UNDEFINED, SCM_UNDEFINED); - return SCM_BOOL_F; + return SCM_UNSPECIFIED; } /* there can be only one */ + static MuGuile *_singleton = NULL; static gboolean diff --git a/guile/mu-guile.h b/guile/mu-guile.h index 3857d4d4..588fc3a8 100644 --- a/guile/mu-guile.h +++ b/guile/mu-guile.h @@ -74,13 +74,14 @@ SCM mu_guile_error (const char *func_name, int status, /** * convert a const char* into an SCM -- either a string or, if str == - * NULL, #f + * NULL, #f. It assumes str is in UTF8 encoding, and replace + * characters with '?' if needed. * * @param str a string or NULL * * @return a guile string or #f */ -SCM scm_from_str_or_null (const char *str); +SCM mu_guile_scm_from_str (const char *str); /**