mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 04:55:04 +02:00
Hex scalars as part of strings
This commit is contained in:
parent
35cb42fb99
commit
56fcf3bb5b
1 changed files with 9 additions and 8 deletions
17
runtime.c
17
runtime.c
|
@ -5796,28 +5796,29 @@ void _read_string(void *data, object cont, port_type *p)
|
||||||
_read_add_to_tok_buf(p, '\t');
|
_read_add_to_tok_buf(p, '\t');
|
||||||
break;
|
break;
|
||||||
case 'x': {
|
case 'x': {
|
||||||
char buf[128];
|
char buf[32];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < 127){
|
while (i < 31){
|
||||||
if (p->mem_buf_len == 0 || p->mem_buf_len == p->buf_idx) {
|
if (p->mem_buf_len == 0 || p->mem_buf_len == p->buf_idx) {
|
||||||
int rv = read_from_port(p);
|
int rv = read_from_port(p);
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p->mem_buf[p->buf_idx] == ';') break;
|
if (p->mem_buf[p->buf_idx] == ';'){
|
||||||
|
p->buf_idx++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
buf[i] = p->mem_buf[p->buf_idx];
|
buf[i] = p->mem_buf[p->buf_idx];
|
||||||
p->buf_idx++;
|
p->buf_idx++;
|
||||||
p->col_num++;
|
p->col_num++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
// TODO: convert hex and return_closcall1(data, cont,
|
|
||||||
{
|
{
|
||||||
make_string(str, buf);
|
int result = (int)strtol(buf, NULL, 16);
|
||||||
// TODO: (integer->char (string->number (list->string buf) 16)))))
|
//return_closcall1(data, cont, obj_char2obj(result));
|
||||||
// Cyc_string2number2_(data, cont, 2, buf, obj_int2obj(16));
|
p->tok_buf[p->tok_end++] = (char)result;
|
||||||
return_closcall1(data, cont, boolean_f); // TODO: just a placeholder!
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue