1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

(scm_read_string_x_partial): Bugfix, apply offset to dest

only after dest has been set.  Thanks to Hyper Division!
This commit is contained in:
Marius Vollmer 2004-11-04 14:01:18 +00:00
parent 6697f945b9
commit a9d13d445b

View file

@ -102,18 +102,17 @@ SCM_DEFINE (scm_read_string_x_partial, "read-string!/partial", 1, 3, 0,
#define FUNC_NAME s_scm_read_string_x_partial #define FUNC_NAME s_scm_read_string_x_partial
{ {
char *dest; char *dest;
size_t offset;
long read_len; long read_len;
long chars_read = 0; long chars_read = 0;
int fdes; int fdes;
{ {
size_t offset;
size_t last; size_t last;
SCM_VALIDATE_STRING (1, str); SCM_VALIDATE_STRING (1, str);
scm_i_get_substring_spec (scm_i_string_length (str), scm_i_get_substring_spec (scm_i_string_length (str),
start, &offset, end, &last); start, &offset, end, &last);
dest += offset;
read_len = last - offset; read_len = last - offset;
} }
@ -130,7 +129,7 @@ SCM_DEFINE (scm_read_string_x_partial, "read-string!/partial", 1, 3, 0,
don't touch the file descriptor. otherwise the don't touch the file descriptor. otherwise the
"return immediately if something is available" rule may "return immediately if something is available" rule may
be violated. */ be violated. */
dest = scm_i_string_writable_chars (str); dest = scm_i_string_writable_chars (str) + offset;
chars_read = scm_take_from_input_buffers (port, dest, read_len); chars_read = scm_take_from_input_buffers (port, dest, read_len);
scm_i_string_stop_writing (); scm_i_string_stop_writing ();
fdes = SCM_FPORT_FDES (port); fdes = SCM_FPORT_FDES (port);
@ -139,7 +138,7 @@ SCM_DEFINE (scm_read_string_x_partial, "read-string!/partial", 1, 3, 0,
if (chars_read == 0 && read_len > 0) /* don't confuse read_len == 0 with if (chars_read == 0 && read_len > 0) /* don't confuse read_len == 0 with
EOF. */ EOF. */
{ {
dest = scm_i_string_writable_chars (str); dest = scm_i_string_writable_chars (str) + offset;
SCM_SYSCALL (chars_read = read (fdes, dest, read_len)); SCM_SYSCALL (chars_read = read (fdes, dest, read_len));
scm_i_string_stop_writing (); scm_i_string_stop_writing ();
if (chars_read == -1) if (chars_read == -1)