diff options
Diffstat (limited to 'xs.h')
| -rw-r--r-- | xs.h | 4 |
1 files changed, 4 insertions, 0 deletions
| @@ -157,6 +157,7 @@ unsigned int xs_hash_func(const char *data, int size); | |||
| 157 | 157 | ||
| 158 | #define xs_is_true(v) (xs_type((v)) == XSTYPE_TRUE) | 158 | #define xs_is_true(v) (xs_type((v)) == XSTYPE_TRUE) |
| 159 | #define xs_is_false(v) (xs_type((v)) == XSTYPE_FALSE) | 159 | #define xs_is_false(v) (xs_type((v)) == XSTYPE_FALSE) |
| 160 | #define xs_not(v) xs_stock(xs_is_true((v)) ? XSTYPE_FALSE : XSTYPE_TRUE) | ||
| 160 | 161 | ||
| 161 | #define xs_list_foreach(l, v) for (int ct_##__LINE__ = 0; xs_list_next(l, &v, &ct_##__LINE__); ) | 162 | #define xs_list_foreach(l, v) for (int ct_##__LINE__ = 0; xs_list_next(l, &v, &ct_##__LINE__); ) |
| 162 | #define xs_dict_foreach(l, k, v) for (int ct_##__LINE__ = 0; xs_dict_next(l, &k, &v, &ct_##__LINE__); ) | 163 | #define xs_dict_foreach(l, k, v) for (int ct_##__LINE__ = 0; xs_dict_next(l, &k, &v, &ct_##__LINE__); ) |
| @@ -357,6 +358,9 @@ int xs_is_null(const xs_val *data) | |||
| 357 | int xs_cmp(const xs_val *v1, const xs_val *v2) | 358 | int xs_cmp(const xs_val *v1, const xs_val *v2) |
| 358 | /* compares two values */ | 359 | /* compares two values */ |
| 359 | { | 360 | { |
| 361 | if (xs_type(v1) == XSTYPE_STRING && xs_type(v2) == XSTYPE_STRING) | ||
| 362 | return strcmp(v1, v2); | ||
| 363 | |||
| 360 | int s1 = xs_size(v1); | 364 | int s1 = xs_size(v1); |
| 361 | int s2 = xs_size(v2); | 365 | int s2 = xs_size(v2); |
| 362 | int d = s1 - s2; | 366 | int d = s1 - s2; |