[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-120-g7505c
From: |
Mark H Weaver |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-120-g7505c6e |
Date: |
Thu, 16 Jun 2011 19:09:28 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=7505c6e024369f2ef381512cbc4a790cc6503428
The branch, stable-2.0 has been updated
via 7505c6e024369f2ef381512cbc4a790cc6503428 (commit)
from 32f94bf258bd032fa6f96fc76e4153086bc001f5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 7505c6e024369f2ef381512cbc4a790cc6503428
Author: Mark H Weaver <address@hidden>
Date: Thu Jun 16 15:07:30 2011 -0400
Fix several POSIX functions to use the locale encoding
* libguile/strings.c (scm_i_allocate_string_pointers): Encode strings
using the current locale. Previously, Latin-1 was used. Indirectly,
this affects the encoding of strings in `system*', `execl', `execlp',
`execle', `environ', and `dynamic-args-call'.
(scm_makfromstrs): In header comment, clarify that the C strings are
interpreted according to the current locale encoding.
* NEWS: Add NEWS entry.
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
libguile/strings.c | 41 ++++++++++++++++++++++++-----------------
2 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/NEWS b/NEWS
index 7ae9c11..2ca0272 100644
--- a/NEWS
+++ b/NEWS
@@ -166,6 +166,7 @@ ports)' documentation from the R6RS documentation. Thanks
Andreas!
** Fix multithreaded access to internal hash tables
** Emit a 1-based line number in error messages
** Fix define-module ordering
+** Fix several POSIX functions to use the locale encoding
Changes in 2.0.1 (since 2.0.0):
diff --git a/libguile/strings.c b/libguile/strings.c
index 0d379ff..24c82fc 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -2052,8 +2052,9 @@ SCM_DEFINE (scm_string_normalize_nfkd,
"string-normalize-nfkd", 1, 0, 0,
}
#undef FUNC_NAME
-/* converts C scm_array of strings to SCM scm_list of strings. */
-/* If argc < 0, a null terminated scm_array is assumed. */
+/* converts C scm_array of strings to SCM scm_list of strings.
+ If argc < 0, a null terminated scm_array is assumed.
+ The current locale encoding is assumed */
SCM
scm_makfromstrs (int argc, char **argv)
{
@@ -2067,37 +2068,43 @@ scm_makfromstrs (int argc, char **argv)
}
/* Return a newly allocated array of char pointers to each of the strings
- in args, with a terminating NULL pointer. */
+ in args, with a terminating NULL pointer. The strings are encoded using
+ the current locale. */
char **
scm_i_allocate_string_pointers (SCM list)
#define FUNC_NAME "scm_i_allocate_string_pointers"
{
char **result;
- int len = scm_ilength (list);
+ int list_len = scm_ilength (list);
int i;
- if (len < 0)
+ if (list_len < 0)
scm_wrong_type_arg_msg (NULL, 0, list, "proper list");
- result = scm_gc_malloc ((len + 1) * sizeof (char *),
+ result = scm_gc_malloc ((list_len + 1) * sizeof (char *),
"string pointers");
- result[len] = NULL;
+ result[list_len] = NULL;
- /* The list might be have been modified in another thread, so
+ /* The list might have been modified in another thread, so
we check LIST before each access.
*/
- for (i = 0; i < len && scm_is_pair (list); i++)
+ for (i = 0; i < list_len && scm_is_pair (list); i++)
{
- SCM str;
- size_t len;
-
- str = SCM_CAR (list);
- len = scm_c_string_length (str);
-
- result[i] = scm_gc_malloc_pointerless (len + 1, "string pointers");
- memcpy (result[i], scm_i_string_chars (str), len);
+ SCM str = SCM_CAR (list);
+ size_t len; /* String length in bytes */
+ char *c_str = scm_to_locale_stringn (str, &len);
+
+ /* OPTIMIZE-ME: Right now, scm_to_locale_stringn always uses
+ scm_malloc to allocate the returned string, which must be
+ explicitly deallocated. This forces us to copy the string a
+ second time into a new buffer. Ideally there would be variants
+ of scm_to_*_stringn that can return garbage-collected buffers. */
+
+ result[i] = scm_gc_malloc_pointerless (len + 1, "string");
+ memcpy (result[i], c_str, len);
result[i][len] = '\0';
+ free (c_str);
list = SCM_CDR (list);
}
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-120-g7505c6e,
Mark H Weaver <=