add h_in (counterpart to h_not_in)
This commit is contained in:
parent
7678e8dd68
commit
2d5b90e174
2 changed files with 18 additions and 3 deletions
|
|
@ -28,16 +28,24 @@ const HParser* h_ch_range(const uint8_t lower, const uint8_t upper) {
|
|||
}
|
||||
|
||||
|
||||
const HParser* h_not_in(const uint8_t *options, size_t count) {
|
||||
const HParser* h_in_or_not(const uint8_t *options, size_t count, int val) {
|
||||
HParser *ret = g_new(HParser, 1);
|
||||
HCharset cs = new_charset();
|
||||
for (size_t i = 0; i < 256; i++)
|
||||
charset_set(cs, i, 1);
|
||||
charset_set(cs, i, 1-val);
|
||||
for (size_t i = 0; i < count; i++)
|
||||
charset_set(cs, options[i], 0);
|
||||
charset_set(cs, options[i], val);
|
||||
|
||||
ret->vtable = &charset_vt;
|
||||
ret->env = (void*)cs;
|
||||
return (const HParser*)ret;
|
||||
}
|
||||
|
||||
const HParser* h_in(const uint8_t *options, size_t count) {
|
||||
return h_in_or_not(options, count, 1);
|
||||
}
|
||||
|
||||
const HParser* h_not_in(const uint8_t *options, size_t count) {
|
||||
return h_in_or_not(options, count, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue