M2: string

This commit is contained in:
Jan Nieuwenhuizen 2019-10-26 13:33:53 +02:00
parent 88fbcb5ff7
commit 18d255cf1f
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 7 additions and 3 deletions

View File

@ -50,7 +50,8 @@ list_to_cstring (SCM list, size_t *size)
{ {
if (i > MAX_STRING) if (i > MAX_STRING)
assert_max_string (i, "list_to_string", g_buf); assert_max_string (i, "list_to_string", g_buf);
g_buf[i] = VALUE (car (list)); SCM x = car (list);
g_buf[i] = VALUE (x);
i = i + 1; i = i + 1;
list = cdr (list); list = cdr (list);
} }
@ -172,8 +173,11 @@ read_string (SCM port) /*:((arity . n)) */
{ {
int fd = __stdin; int fd = __stdin;
if (TYPE (port) == TPAIR) if (TYPE (port) == TPAIR)
if (TYPE (car (port)) == TNUMBER) {
__stdin = VALUE (CAR (port)); SCM p = car (port);
if (TYPE (p) == TNUMBER)
__stdin = VALUE (p);
}
int c = readchar (); int c = readchar ();
size_t i = 0; size_t i = 0;
while (c != -1) while (c != -1)