diff options
author | Michael Gran <spk121@yahoo.com> | 2009-08-23 08:38:10 -0700 |
---|---|---|
committer | Michael Gran <spk121@yahoo.com> | 2009-08-23 08:38:10 -0700 |
commit | 7a219ac272d77f480ec92881ebbaafa33eb88f77 (patch) | |
tree | 01c43eb6f27e5505817f399d21b1369ab288433e /libguile/socket.c | |
parent | 67dd49f3a56c489affa11de837c53009b6ba3bf8 (diff) | |
download | guile-string_abstraction2.tar.gz |
Rollup minor diffs between string_abstraction2 and master branchesstring_abstraction2
* libguile/Makefile.am: don't need to include chars.c
* libguile/deprecated.c: whitespace
* libguile/deprecated.h: scm_i_intern_obarray_soft doesn't exist
* libguile/filesys.c (scm_init_filesys): copy paste error
* libguile/gc-mark.c: unneeded include
* libguile/numbers.c: whitespace
* libguile/socket.c (scm_recv): remember msg
(scm_send): try to narrow the string before testing it for 8-bitness,
don't locale convert
* libguile/srfi-13.c (scm_string_map): double call of
scm_i_string_start_writing
* libguile/stime.c (scm_strftime, scm_strptime): whitespace and
scm_remember_upto_here calls
* libguile/strings.c: whitespace
(scm_i_string_set_x): remove pointless double-cast
* libguile/struct.c: whitespace
(scm_struct_ref): no need to re-call scm_i_symbol_ref
* libguile/symbols.c: unneeded include
* libguile/vm-i-system.c: whitespace
* doc/ref/vm.texi: copy/paste error
* libguile/strings.c (narrow_stringbuf): new function
(scm_i_is_narrow_string): new function
* libguile/strings.h: new declaration for scm_i_try_narrow_string
Diffstat (limited to 'libguile/socket.c')
-rw-r--r-- | libguile/socket.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libguile/socket.c b/libguile/socket.c index 18750a35f..e9523743c 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -34,6 +34,7 @@ #include "libguile/vectors.h" #include "libguile/dynwind.h" #include "libguile/srfi-13.h" +#include "libguile/strings.h" #include "libguile/validate.h" #include "libguile/socket.h" @@ -1450,7 +1451,7 @@ SCM_DEFINE (scm_recv, "recv!", 2, 1, 0, if (rv == -1) SCM_SYSERROR; - scm_remember_upto_here_1 (buf); + scm_remember_upto_here_2 (buf, msg); return scm_from_int (rv); } #undef FUNC_NAME @@ -1482,9 +1483,13 @@ SCM_DEFINE (scm_send, "send", 2, 1, 0, sock = SCM_COERCE_OUTPORT (sock); SCM_VALIDATE_OPFPORT (1, sock); SCM_VALIDATE_STRING (2, message); - if (!scm_i_is_narrow_string (message)) + + /* If the string is wide, see if it can be coerced into + a narrow string. */ + if (!scm_i_is_narrow_string (message) + || scm_i_try_narrow_string (message)) SCM_MISC_ERROR ("the message string is not 8-bit: ~s", - scm_list_1 (message)); + scm_list_1 (message)); if (SCM_UNBNDP (flags)) flg = 0; @@ -1492,9 +1497,11 @@ SCM_DEFINE (scm_send, "send", 2, 1, 0, flg = scm_to_int (flags); fd = SCM_FPORT_FDES (sock); - src = scm_to_locale_stringn (message, &len); + len = scm_i_string_length (message); + message = scm_i_string_start_writing (message); + src = scm_i_string_writable_chars (message); SCM_SYSCALL (rv = send (fd, src, len, flg)); - free (src); + scm_i_string_stop_writing (); if (rv == -1) SCM_SYSERROR; |