mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Fixed compiler warning, replaced hexstr2int
This commit is contained in:
parent
d6f5a81f2d
commit
cfb3209648
2 changed files with 3 additions and 21 deletions
|
@ -191,7 +191,6 @@ object Cyc_string2number_(void *d, object cont, object str);
|
|||
object Cyc_string2number2_(void *data, object cont, int argc, object str, ...);
|
||||
int binstr2int(const char *str);
|
||||
int octstr2int(const char *str);
|
||||
int hexstr2int(const char *str);
|
||||
object Cyc_string_append(void *data, object cont, int argc, object str1, ...);
|
||||
object Cyc_string_length(void *data, object str);
|
||||
object Cyc_substring(void *data, object cont, object str, object start,
|
||||
|
|
23
runtime.c
23
runtime.c
|
@ -1430,13 +1430,13 @@ object Cyc_string2number2_(void *data, object cont, int argc, object str, ...)
|
|||
base_num = unbox_number(base);
|
||||
Cyc_check_str(data, str);
|
||||
if (base_num == 2) {
|
||||
result = binstr2int(string_str(str));
|
||||
result = (int)strtol(string_str(str), NULL, 2);
|
||||
_return_closcall1(data, cont, obj_int2obj(result));
|
||||
} else if (base_num == 8) {
|
||||
result = octstr2int(string_str(str));
|
||||
result = (int)strtol(string_str(str), NULL, 8);
|
||||
_return_closcall1(data, cont, obj_int2obj(result));
|
||||
} else if (base_num == 16) {
|
||||
result = hexstr2int(string_str(str));
|
||||
result = (int)strtol(string_str(str), NULL, 16);
|
||||
_return_closcall1(data, cont, obj_int2obj(result));
|
||||
}
|
||||
}
|
||||
|
@ -1546,23 +1546,6 @@ int octstr2int(const char *str)
|
|||
return num;
|
||||
}
|
||||
|
||||
int hexstr2int(const char *str)
|
||||
{
|
||||
int num = 0;
|
||||
while (*str) {
|
||||
num <<= 4;
|
||||
if (*str >= 'A' && *str <= 'F') {
|
||||
num += (((*str) - 'A') + 10);
|
||||
} else if (*str >= 'a' && *str <= 'f') {
|
||||
num += (((*str) - 'a') + 10);
|
||||
} else {
|
||||
num += ((*str) - '0');
|
||||
}
|
||||
*str++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
object Cyc_string_cmp(void *data, object str1, object str2)
|
||||
{
|
||||
Cyc_check_str(data, str1);
|
||||
|
|
Loading…
Add table
Reference in a new issue