41 const char *
re_cmp(
const char *,
const char *);
68 const char *
re_cmp(
const char *str,
const char *regexp) {
69 const char *next_regexp;
77 if (regexp == NULL || str == NULL)
94 while (*str !=
'\0' && !(matched =
re_match_token(*str, re_token[0])))
97 if (matched && *next_regexp == 0)
104 switch (re_token[0]->repeat) {
106 if (matched ==
False)
111 if (matched ==
False)
119 if (matched ==
False)
120 return re_cmp_step(str, next_regexp, 1, 0) ? str : NULL;
128 return re_cmp_step(str, next_regexp, 1, 0) ? str : NULL;
133 return re_cmp_step(str+1, next_regexp, 1, 0) ? str : NULL;
137 switch (re_token[0]->repeat) {
166 else if (*(str+1) != 0)
167 return re_cmp(str+1, regexp);
190 const char *next_regexp;
207 if (re_token[slot] == NULL)
210 if (next_regexp == NULL) {
224 return (*next_regexp == 0 || re_token[slot]->type ==
sel_end) && matched;
226 switch (re_token[slot]->repeat) {
246 }
else if (matches == 1) {
274 if (re_token[0] == NULL)
304 return (c >= sel->
u.
range.low && c <= sel->u.range.high);
313 return (c < sel->u.range.low && c > sel->
u.
range.high);
332 # define exit_if_null if (*regexp == 0) return NULL 334 # define exit_if_null 340 if (sel == NULL || regexp == NULL || *regexp == 0)
345 looking_at = *regexp++;
346 switch (looking_at) {
377 uchar first, last = 0;
380 looking_at = *regexp++;
382 if (looking_at ==
'^') {
385 looking_at = *regexp++;
389 looking_at = *regexp++;
390 if (looking_at ==
']') {
395 }
else if (looking_at ==
'-') {
409 looking_at = *regexp++;
410 if (looking_at ==
']') {
440 for (i = first; i <= last; i++) {
445 sel->
u.
array[first] = !neg;
447 sel->
u.
array[looking_at] = !neg;
450 previous = looking_at;
451 looking_at = *regexp++;
459 while (looking_at !=
']') {
460 if (looking_at ==
'-') {
462 looking_at = *regexp++;
463 if (looking_at !=
']') {
465 if (previous > looking_at)
468 for (i = previous+1; i < looking_at; i++) {
480 sel->
u.
array[looking_at] = !neg;
481 previous = looking_at;
483 looking_at = *regexp++;
507 if (*regexp ==
'*') {
510 }
else if (*regexp ==
'?') {
513 }
else if (*regexp ==
'+') {
static event_registration c
struct selection::@4::@5 range
Datastructures for representing a subset of regular expressions.
static selection * re_token[RE_TOKEN_MAX]
static void re_init(void)
Init the regular expression structures.
static const char * re_substr[RE_TOKEN_MAX]
#define RE_TOKEN_MAX
Max amount of tokens in a regexp.
Global type definitions and header inclusions.
static Boolean re_cmp_step(const char *, const char *, unsigned, int)
Tries to match a string with a regexp.
static unsigned int re_token_depth
corresponds to eg [AF-RqO-T]
#define True
Changing this value will break the code.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
const char * re_cmp(const char *, const char *)
re-cmp - get regular expression match.
static Boolean re_init_done
static const char * re_get_token(selection *, const char *)
Get the first regular expression token found in regexp in sel.
corresponds to no meta-char
static Boolean re_match_token(uchar, selection *)
Tests if a char matches a token.
static int matches(const char *exp, const char *text)
Does the text match the expression?
#define tolower(C)
Simple macro to convert a letter to lowercase.
Core defines: object types, flags, etc.