Minor code cleaning.

This commit is contained in:
default 2024-09-14 18:59:49 +02:00
parent c6594949f9
commit 31ce1af736
3 changed files with 6 additions and 2 deletions

4
xs.h
View file

@ -157,6 +157,7 @@ unsigned int xs_hash_func(const char *data, int size);
#define xs_is_true(v) (xs_type((v)) == XSTYPE_TRUE)
#define xs_is_false(v) (xs_type((v)) == XSTYPE_FALSE)
#define xs_not(v) xs_stock(xs_is_true((v)) ? XSTYPE_FALSE : XSTYPE_TRUE)
#define xs_list_foreach(l, v) for (int ct_##__LINE__ = 0; xs_list_next(l, &v, &ct_##__LINE__); )
#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)
int xs_cmp(const xs_val *v1, const xs_val *v2)
/* compares two values */
{
if (xs_type(v1) == XSTYPE_STRING && xs_type(v2) == XSTYPE_STRING)
return strcmp(v1, v2);
int s1 = xs_size(v1);
int s2 = xs_size(v2);
int d = s1 - s2;

View file

@ -212,7 +212,7 @@ static xs_val *_xs_json_load_lexer(FILE *f, js_type *t)
*t = JS_ERROR;
/* skip blanks */
while ((c = fgetc(f)) == L' ' || c == L'\t' || c == L'\n' || c == L'\r');
while ((c = fgetc(f)) == ' ' || c == '\t' || c == '\n' || c == '\r');
if (c == '{')
*t = JS_OCURLY;

View file

@ -1 +1 @@
/* 2a3ecc6aef531366cfd45cbf19e34a15f83f69f8 2024-08-30T18:33:51+02:00 */
/* 9c3dd1b1165c25baa154e82d8d278926e376af81 2024-09-14T18:18:42+02:00 */