mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 04:25:06 +02:00
WIP string->number error detection
This commit is contained in:
parent
12770291b7
commit
0f04b9a935
1 changed files with 11 additions and 1 deletions
12
runtime.c
12
runtime.c
|
@ -1694,6 +1694,14 @@ int str2double(double *out, char *s)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int str2double_error(char *str, double result) {
|
||||||
|
//int i, len = strlen(str);
|
||||||
|
//for (i = 0; i < len; i++) {
|
||||||
|
// if (!isspace(str[i]) && str[i] != '.' &&
|
||||||
|
//}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
object Cyc_string2number_(void *data, object cont, object str)
|
object Cyc_string2number_(void *data, object cont, object str)
|
||||||
{
|
{
|
||||||
int result, rv;
|
int result, rv;
|
||||||
|
@ -1709,9 +1717,11 @@ object Cyc_string2number_(void *data, object cont, object str)
|
||||||
_return_closcall1(data, cont, obj_int2obj(result));
|
_return_closcall1(data, cont, obj_int2obj(result));
|
||||||
} else {
|
} else {
|
||||||
str2double(&n, s);
|
str2double(&n, s);
|
||||||
{
|
if (n > 0.0L || n < 0.0L || !str2double_error(s, n)) {
|
||||||
make_double(result, n);
|
make_double(result, n);
|
||||||
_return_closcall1(data, cont, &result);
|
_return_closcall1(data, cont, &result);
|
||||||
|
} else {
|
||||||
|
_return_closcall1(data, cont, boolean_f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue