Lines Matching +full:meta +full:- +full:spec
13 * expression back-end when we started supporting PCRE2. regex.h defines a
46 struct spec { struct
55 int stem_id; /* indicates which stem-compression item */
56 char hasMetaChars; /* regular expression has meta-chars */
57 char from_mmap; /* this spec is from an mmap of the data */ argument
83 struct spec *spec_arr;
107 if (mode[0] != '-' || len != 2) in string_to_mode()
108 return -1; in string_to_mode()
122 case '-': in string_to_mode()
125 return -1; in string_to_mode()
133 struct spec *specs; in grow_specs()
136 if (data->nspec < data->alloc_specs) in grow_specs()
139 new_specs = data->nspec + 16; in grow_specs()
140 total_specs = data->nspec + new_specs; in grow_specs()
142 specs = realloc(data->spec_arr, total_specs * sizeof(*specs)); in grow_specs()
145 return -1; in grow_specs()
149 memset(&specs[data->nspec], 0, new_specs * sizeof(*specs)); in grow_specs()
151 data->spec_arr = specs; in grow_specs()
152 data->alloc_specs = total_specs; in grow_specs()
156 /* Determine if the regular expression specification has any meta characters. */
157 static inline void spec_hasMetaChars(struct spec *spec) in spec_hasMetaChars() argument
163 c = spec->regex_str; in spec_hasMetaChars()
164 len = strlen(spec->regex_str); in spec_hasMetaChars()
167 spec->hasMetaChars = 0; in spec_hasMetaChars()
168 spec->prefix_len = len; in spec_hasMetaChars()
171 * meta character. Return when any meta character reached. */ in spec_hasMetaChars()
184 spec->hasMetaChars = 1; in spec_hasMetaChars()
185 spec->prefix_len = c - spec->regex_str; in spec_hasMetaChars()
201 struct spec *spec_copy; in sort_specs()
202 struct spec spec; in sort_specs() local
207 spec_copy = malloc(len * data->nspec); in sort_specs()
209 return -1; in sort_specs()
213 back = data->nspec - 1; in sort_specs()
214 for (i = 0; i < data->nspec; i++) { in sort_specs()
215 if (data->spec_arr[i].hasMetaChars) in sort_specs()
216 memcpy(&spec_copy[front++], &data->spec_arr[i], len); in sort_specs()
218 memcpy(&spec_copy[back--], &data->spec_arr[i], len); in sort_specs()
226 back = data->nspec - 1; in sort_specs()
229 memcpy(&spec, &spec_copy[front], len); in sort_specs()
233 memcpy(&spec_copy[back], &spec, len); in sort_specs()
235 back--; in sort_specs()
238 free(data->spec_arr); in sort_specs()
239 data->spec_arr = spec_copy; in sort_specs()
258 return tmp - buf; in get_stem_from_spec()
269 for (i = 0; i < data->num_stems; i++) { in find_stem()
270 if (stem_len == data->stem_arr[i].len && in find_stem()
271 !strncmp(buf, data->stem_arr[i].buf, stem_len)) in find_stem()
275 return -1; in find_stem()
281 int num = data->num_stems; in store_stem()
283 if (data->alloc_stems == num) { in store_stem()
285 int alloc_stems = data->alloc_stems * 2 + 16; in store_stem()
286 tmp_arr = realloc(data->stem_arr, in store_stem()
289 return -1; in store_stem()
291 data->alloc_stems = alloc_stems; in store_stem()
292 data->stem_arr = tmp_arr; in store_stem()
294 data->stem_arr[num].len = stem_len; in store_stem()
295 data->stem_arr[num].buf = buf; in store_stem()
296 data->stem_arr[num].from_mmap = 0; in store_stem()
297 data->num_stems++; in store_stem()
302 /* find the stem of a file spec, returns the index into stem_arr for a new
303 * or existing stem, (or -1 if there is no possible stem - IE for a file in
313 return -1; in find_stem_from_spec()
322 return -1; in find_stem_from_spec()
331 /* This will always check for buffer over-runs and either read the next entry
336 if (bytes > fp->next_len) in next_entry()
337 return -1; in next_entry()
340 memcpy(buf, fp->next_addr, bytes); in next_entry()
342 fp->next_addr = (char *)fp->next_addr + bytes; in next_entry()
343 fp->next_len -= bytes; in next_entry()
347 static inline int compile_regex(struct spec *spec, const char **errbuf) in compile_regex() argument
362 __atomic_load_n(&spec->regex_compiled, __ATOMIC_ACQUIRE); in compile_regex()
366 regex_compiled = spec->regex_compiled; in compile_regex()
372 __pthread_mutex_lock(&spec->regex_lock); in compile_regex()
377 __atomic_load_n(&spec->regex_compiled, __ATOMIC_ACQUIRE); in compile_regex()
381 regex_compiled = spec->regex_compiled; in compile_regex()
384 __pthread_mutex_unlock(&spec->regex_lock); in compile_regex()
388 reg_buf = spec->regex_str; in compile_regex()
395 __pthread_mutex_unlock(&spec->regex_lock); in compile_regex()
396 return -1; in compile_regex()
407 rc = regex_prepare_data(&spec->regex, anchored_regex, &error_data); in compile_regex()
416 __pthread_mutex_unlock(&spec->regex_lock); in compile_regex()
417 return -1; in compile_regex()
422 __atomic_store_n(&spec->regex_compiled, true, __ATOMIC_RELEASE); in compile_regex()
425 spec->regex_compiled = true; in compile_regex()
428 __pthread_mutex_unlock(&spec->regex_lock); in compile_regex()
440 struct saved_data *data = (struct saved_data *)rec->data; in process_line()
441 struct spec *spec_arr; in process_line()
442 unsigned int nspec = data->nspec; in process_line()
456 return -1; in process_line()
469 return -1; in process_line()
489 spec_arr = data->spec_arr; in process_line()
491 /* process and store the specification in spec. */ in process_line()
504 * bump data->nspecs to cause closef() to cover it in its free in process_line()
507 data->nspec++; in process_line()
509 if (rec->validating in process_line()
515 return -1; in process_line()
521 if (mode == (mode_t)-1) { in process_line()
526 return -1; in process_line()
532 * any meta characters in the RE */ in process_line()
535 if (strcmp(context, "<<none>>") && rec->validating) in process_line()