1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

(scm_read_delimited_x): Avoid

SCM_VALIDATE_SUBSTRING_SPEC_COPY and use scm_from_size_t instead
of scm_from_long for the returned number of read characters.
This commit is contained in:
Marius Vollmer 2004-08-12 17:32:15 +00:00
parent 1299a0f17b
commit 3eb1e2aa88

View file

@ -63,14 +63,19 @@ SCM_DEFINE (scm_read_delimited_x, "%read-delimited!", 3, 3, 0,
char *cdelims; char *cdelims;
size_t num_delims; size_t num_delims;
SCM_VALIDATE_STRING_COPY (1, delims, cdelims); SCM_VALIDATE_STRING (1, delims);
num_delims = SCM_STRING_LENGTH (delims); cdelims = SCM_I_STRING_CHARS (delims);
SCM_VALIDATE_SUBSTRING_SPEC_COPY (2, str, buf, 5, start, cstart, num_delims = SCM_I_STRING_LENGTH (delims);
6, end, cend);
SCM_VALIDATE_STRING (2, str);
buf = SCM_I_STRING_CHARS (str);
scm_i_get_substring_spec (SCM_I_STRING_LENGTH (str),
start, &cstart, end, &cend);
if (SCM_UNBNDP (port)) if (SCM_UNBNDP (port))
port = scm_cur_inp; port = scm_cur_inp;
else else
SCM_VALIDATE_OPINPORT (4,port); SCM_VALIDATE_OPINPORT (4, port);
for (j = cstart; j < cend; j++) for (j = cstart; j < cend; j++)
{ {
@ -85,16 +90,16 @@ SCM_DEFINE (scm_read_delimited_x, "%read-delimited!", 3, 3, 0,
scm_ungetc (c, port); scm_ungetc (c, port);
return scm_cons (SCM_MAKE_CHAR (c), return scm_cons (SCM_MAKE_CHAR (c),
scm_from_long (j - cstart)); scm_from_size_t (j - cstart));
} }
} }
if (c == EOF) if (c == EOF)
return scm_cons (SCM_EOF_VAL, return scm_cons (SCM_EOF_VAL,
scm_from_long (j - cstart)); scm_from_size_t (j - cstart));
buf[j] = c; buf[j] = c;
} }
return scm_cons (SCM_BOOL_F, scm_from_long (j - cstart)); return scm_cons (SCM_BOOL_F, scm_from_size_t (j - cstart));
} }
#undef FUNC_NAME #undef FUNC_NAME