minor
This commit is contained in:
parent
22aa38e31d
commit
d7dd697c35
1 changed files with 6 additions and 8 deletions
14
toml.c
14
toml.c
|
@ -2034,7 +2034,7 @@ int toml_rtoi(toml_raw_t src, int64_t* ret_)
|
||||||
if (s[0] == '_')
|
if (s[0] == '_')
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* if 0 ... */
|
/* if 0* ... */
|
||||||
if ('0' == s[0]) {
|
if ('0' == s[0]) {
|
||||||
switch (s[1]) {
|
switch (s[1]) {
|
||||||
case 'x': base = 16; s += 2; break;
|
case 'x': base = 16; s += 2; break;
|
||||||
|
@ -2050,20 +2050,18 @@ int toml_rtoi(toml_raw_t src, int64_t* ret_)
|
||||||
/* just strip underscores and pass to strtoll */
|
/* just strip underscores and pass to strtoll */
|
||||||
while (*s && p < q) {
|
while (*s && p < q) {
|
||||||
int ch = *s++;
|
int ch = *s++;
|
||||||
switch (ch) {
|
if (ch == '_') {
|
||||||
case '_':
|
|
||||||
// disallow '__'
|
// disallow '__'
|
||||||
if (s[0] == '_') return -1;
|
if (s[0] == '_') return -1;
|
||||||
|
// numbers cannot end with '_'
|
||||||
|
if (s[0] == '\0') return -1;
|
||||||
continue; /* skip _ */
|
continue; /* skip _ */
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
*p++ = ch;
|
*p++ = ch;
|
||||||
}
|
}
|
||||||
if (*s || p == q) return -1;
|
|
||||||
|
|
||||||
/* last char cannot be '_' */
|
// if not at end-of-string or we ran out of buffer ...
|
||||||
if (s[-1] == '_') return -1;
|
if (*s || p == q) return -1;
|
||||||
|
|
||||||
/* cap with NUL */
|
/* cap with NUL */
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
Loading…
Reference in a new issue