Simplify truthy()
This commit is contained in:
parent
a81d75164a
commit
0d078d7148
4
ell.c
4
ell.c
|
@ -211,7 +211,6 @@ struct lexer {
|
||||||
struct buffer string; ///< Parsed string value
|
struct buffer string; ///< Parsed string value
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Input has to be null-terminated anyway
|
|
||||||
static void
|
static void
|
||||||
lexer_init (struct lexer *self, const char *p, size_t len) {
|
lexer_init (struct lexer *self, const char *p, size_t len) {
|
||||||
*self = (struct lexer) { .p = (const unsigned char *) p, .len = len };
|
*self = (struct lexer) { .p = (const unsigned char *) p, .len = len };
|
||||||
|
@ -886,8 +885,7 @@ new_number (double n) {
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
truthy (struct item *item) {
|
truthy (struct item *item) {
|
||||||
return item
|
return item && (item->head || item->len);
|
||||||
&& ((item->type == ITEM_STRING && item->len != 0) || item->head);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct item * new_boolean (bool b) { return new_string ("1", b); }
|
static struct item * new_boolean (bool b) { return new_string ("1", b); }
|
||||||
|
|
Loading…
Reference in New Issue