mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
Support both types of ints
This commit is contained in:
parent
5d234d1509
commit
aabbc88cae
1 changed files with 8 additions and 7 deletions
15
runtime.c
15
runtime.c
|
@ -1062,24 +1062,25 @@ object Cyc_list2string(void *data, object cont, object lst){
|
||||||
object Cyc_string2number2_(void *data, object cont, int argc, object str, ...)
|
object Cyc_string2number2_(void *data, object cont, int argc, object str, ...)
|
||||||
{
|
{
|
||||||
object base = nil;
|
object base = nil;
|
||||||
|
int base_num;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
make_int(result, 0);
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
base = va_arg(ap, object);
|
base = va_arg(ap, object);
|
||||||
Cyc_check_int(data, base);
|
Cyc_check_int(data, base);
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
if (base) {
|
if (base) {
|
||||||
|
base_num = obj_is_int(base) ? obj_obj2int(base) : integer_value(base);
|
||||||
Cyc_check_str(data, str);
|
Cyc_check_str(data, str);
|
||||||
if (integer_value(base) == 2) {
|
if (base_num == 2) {
|
||||||
integer_value(&result) = binstr2int(string_str(str));
|
make_int(result, binstr2int(string_str(str)));
|
||||||
return_closcall1(data, cont, &result);
|
return_closcall1(data, cont, &result);
|
||||||
}else if (integer_value(base) == 8) {
|
}else if (base_num == 8) {
|
||||||
integer_value(&result) = octstr2int(string_str(str));
|
make_int(result, octstr2int(string_str(str)));
|
||||||
return_closcall1(data, cont, &result);
|
return_closcall1(data, cont, &result);
|
||||||
}else if (integer_value(base) == 16) {
|
}else if (base_num == 16) {
|
||||||
integer_value(&result) = hexstr2int(string_str(str));
|
make_int(result, hexstr2int(string_str(str)));
|
||||||
return_closcall1(data, cont, &result);
|
return_closcall1(data, cont, &result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue