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;
102 if (mode[0] != '-' || mode[1] == '\0' || mode[2] != '\0') in string_to_mode()
103 return (mode_t)-1; in string_to_mode()
117 case '-': in string_to_mode()
120 return (mode_t)-1; in string_to_mode()
126 struct spec *specs; in grow_specs()
129 if (data->nspec < data->alloc_specs) in grow_specs()
132 new_specs = data->nspec + 16; in grow_specs()
133 total_specs = data->nspec + new_specs; in grow_specs()
135 specs = realloc(data->spec_arr, total_specs * sizeof(*specs)); in grow_specs()
138 return -1; in grow_specs()
142 memset(&specs[data->nspec], 0, new_specs * sizeof(*specs)); in grow_specs()
144 data->spec_arr = specs; in grow_specs()
145 data->alloc_specs = total_specs; in grow_specs()
149 /* Determine if the regular expression specification has any meta characters. */
150 static inline void spec_hasMetaChars(struct spec *spec) in spec_hasMetaChars() argument
156 c = spec->regex_str; in spec_hasMetaChars()
157 len = strlen(spec->regex_str); in spec_hasMetaChars()
160 spec->hasMetaChars = 0; in spec_hasMetaChars()
161 spec->prefix_len = len; in spec_hasMetaChars()
164 * meta character. Return when any meta character reached. */ in spec_hasMetaChars()
177 spec->hasMetaChars = 1; in spec_hasMetaChars()
178 spec->prefix_len = c - spec->regex_str; in spec_hasMetaChars()
194 struct spec *spec_copy; in sort_specs()
195 struct spec spec; in sort_specs() local
200 spec_copy = malloc(len * data->nspec); in sort_specs()
202 return -1; in sort_specs()
206 back = data->nspec - 1; in sort_specs()
207 for (i = 0; i < data->nspec; i++) { in sort_specs()
208 if (data->spec_arr[i].hasMetaChars) in sort_specs()
209 memcpy(&spec_copy[front++], &data->spec_arr[i], len); in sort_specs()
211 memcpy(&spec_copy[back--], &data->spec_arr[i], len); in sort_specs()
219 back = data->nspec - 1; in sort_specs()
222 memcpy(&spec, &spec_copy[front], len); in sort_specs()
226 memcpy(&spec_copy[back], &spec, len); in sort_specs()
228 back--; in sort_specs()
231 free(data->spec_arr); in sort_specs()
232 data->spec_arr = spec_copy; in sort_specs()
251 return tmp - buf; in get_stem_from_spec()
262 for (i = 0; i < data->num_stems; i++) { in find_stem()
263 if (stem_len == data->stem_arr[i].len && in find_stem()
264 !strncmp(buf, data->stem_arr[i].buf, stem_len)) in find_stem()
268 return -1; in find_stem()
274 int num = data->num_stems; in store_stem()
276 if (data->alloc_stems == num) { in store_stem()
278 int alloc_stems = data->alloc_stems * 2 + 16; in store_stem()
279 tmp_arr = realloc(data->stem_arr, in store_stem()
282 return -1; in store_stem()
284 data->alloc_stems = alloc_stems; in store_stem()
285 data->stem_arr = tmp_arr; in store_stem()
287 data->stem_arr[num].len = stem_len; in store_stem()
288 data->stem_arr[num].buf = buf; in store_stem()
289 data->stem_arr[num].from_mmap = 0; in store_stem()
290 data->num_stems++; in store_stem()
295 /* find the stem of a file spec, returns the index into stem_arr for a new
296 * or existing stem, (or -1 if there is no possible stem - IE for a file in
306 return -1; in find_stem_from_spec()
315 return -1; in find_stem_from_spec()
324 /* This will always check for buffer over-runs and either read the next entry
329 if (bytes > fp->next_len) in next_entry()
330 return -1; in next_entry()
333 memcpy(buf, fp->next_addr, bytes); in next_entry()
335 fp->next_addr = (char *)fp->next_addr + bytes; in next_entry()
336 fp->next_len -= bytes; in next_entry()
340 static inline int compile_regex(struct spec *spec, const char **errbuf) in compile_regex() argument
355 __atomic_load_n(&spec->regex_compiled, __ATOMIC_ACQUIRE); in compile_regex()
359 regex_compiled = spec->regex_compiled; in compile_regex()
365 __pthread_mutex_lock(&spec->regex_lock); in compile_regex()
370 __atomic_load_n(&spec->regex_compiled, __ATOMIC_ACQUIRE); in compile_regex()
374 regex_compiled = spec->regex_compiled; in compile_regex()
377 __pthread_mutex_unlock(&spec->regex_lock); in compile_regex()
381 reg_buf = spec->regex_str; in compile_regex()
388 __pthread_mutex_unlock(&spec->regex_lock); in compile_regex()
389 return -1; in compile_regex()
400 rc = regex_prepare_data(&spec->regex, anchored_regex, &error_data); in compile_regex()
409 __pthread_mutex_unlock(&spec->regex_lock); in compile_regex()
411 return -1; in compile_regex()
416 __atomic_store_n(&spec->regex_compiled, true, __ATOMIC_RELEASE); in compile_regex()
419 spec->regex_compiled = true; in compile_regex()
422 __pthread_mutex_unlock(&spec->regex_lock); in compile_regex()
434 struct saved_data *data = (struct saved_data *)rec->data; in process_line()
435 struct spec *spec_arr; in process_line()
436 unsigned int nspec = data->nspec; in process_line()
453 return -1; in process_line()
466 return -1; in process_line()
486 spec_arr = data->spec_arr; in process_line()
488 /* process and store the specification in spec. */ in process_line()
501 * bump data->nspecs to cause closef() to cover it in its free in process_line()
504 data->nspec++; in process_line()
506 if (rec->validating in process_line()
512 return -1; in process_line()
518 if (mode == (mode_t)-1) { in process_line()
523 return -1; in process_line()
529 * any meta characters in the RE */ in process_line()
532 if (strcmp(context, "<<none>>") && rec->validating) in process_line()