cleanup
This commit is contained in:
parent
f7c39273fe
commit
72eda69b5a
1 changed files with 19 additions and 46 deletions
45
toml.c
45
toml.c
|
@ -2153,10 +2153,7 @@ toml_datum_t toml_string_at(const toml_array_t* arr, int idx)
|
||||||
{
|
{
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_at(arr, idx);
|
ret.ok = (0 == toml_rtos(toml_raw_at(arr, idx), &ret.u.s));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtos(raw, &ret.u.s));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2164,10 +2161,7 @@ toml_datum_t toml_bool_at(const toml_array_t* arr, int idx)
|
||||||
{
|
{
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_at(arr, idx);
|
ret.ok = (0 == toml_rtob(toml_raw_at(arr, idx), &ret.u.b));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtob(raw, &ret.u.b));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2175,10 +2169,7 @@ toml_datum_t toml_int_at(const toml_array_t* arr, int idx)
|
||||||
{
|
{
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_at(arr, idx);
|
ret.ok = (0 == toml_rtoi(toml_raw_at(arr, idx), &ret.u.i));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtoi(raw, &ret.u.i));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2186,10 +2177,7 @@ toml_datum_t toml_double_at(const toml_array_t* arr, int idx)
|
||||||
{
|
{
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_at(arr, idx);
|
ret.ok = (0 == toml_rtod(toml_raw_at(arr, idx), &ret.u.d));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtod(raw, &ret.u.d));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2198,16 +2186,13 @@ toml_datum_t toml_timestamp_at(const toml_array_t* arr, int idx)
|
||||||
toml_timestamp_t ts;
|
toml_timestamp_t ts;
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_at(arr, idx);
|
ret.ok = (0 == toml_rtots(toml_raw_at(arr, idx), &ts));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtots(raw, &ts));
|
|
||||||
if (ret.ok) {
|
if (ret.ok) {
|
||||||
ret.ok = !!(ret.u.ts = malloc(sizeof(*ret.u.ts)));
|
ret.ok = !!(ret.u.ts = malloc(sizeof(*ret.u.ts)));
|
||||||
if (ret.ok) {
|
if (ret.ok) {
|
||||||
*ret.u.ts = ts;
|
*ret.u.ts = ts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2226,10 +2211,7 @@ toml_datum_t toml_bool_in(const toml_table_t* arr, const char* key)
|
||||||
{
|
{
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_in(arr, key);
|
ret.ok = (0 == toml_rtob(toml_raw_in(arr, key), &ret.u.b));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtob(raw, &ret.u.b));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2237,10 +2219,7 @@ toml_datum_t toml_int_in(const toml_table_t* arr, const char* key)
|
||||||
{
|
{
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_in(arr, key);
|
ret.ok = (0 == toml_rtoi(toml_raw_in(arr, key), &ret.u.i));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtoi(raw, &ret.u.i));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2248,10 +2227,7 @@ toml_datum_t toml_double_in(const toml_table_t* arr, const char* key)
|
||||||
{
|
{
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_in(arr, key);
|
ret.ok = (0 == toml_rtod(toml_raw_in(arr, key), &ret.u.d));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtod(raw, &ret.u.d));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2260,15 +2236,12 @@ toml_datum_t toml_timestamp_in(const toml_table_t* arr, const char* key)
|
||||||
toml_timestamp_t ts;
|
toml_timestamp_t ts;
|
||||||
toml_datum_t ret;
|
toml_datum_t ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
toml_raw_t raw = toml_raw_in(arr, key);
|
ret.ok = (0 == toml_rtots(toml_raw_in(arr, key), &ts));
|
||||||
if (raw) {
|
|
||||||
ret.ok = (0 == toml_rtots(raw, &ts));
|
|
||||||
if (ret.ok) {
|
if (ret.ok) {
|
||||||
ret.ok = !!(ret.u.ts = malloc(sizeof(*ret.u.ts)));
|
ret.ok = !!(ret.u.ts = malloc(sizeof(*ret.u.ts)));
|
||||||
if (ret.ok) {
|
if (ret.ok) {
|
||||||
*ret.u.ts = ts;
|
*ret.u.ts = ts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue