MCPcopy Create free account
hub / github.com/coreboot/coreboot / re_compile_fastmap

Function re_compile_fastmap

util/kconfig/regex.c:2533–2803  ·  view source on GitHub ↗
(bufp)

Source from the content-addressed store, hash-verified

2531 Returns 0 if we succeed, -2 if an internal error. */
2532
2533int
2534re_compile_fastmap (bufp)
2535 struct re_pattern_buffer *bufp;
2536{
2537 int j, k;
2538 fail_stack_type fail_stack;
2539#ifndef REGEX_MALLOC
2540 char *destination;
2541#endif
2542 /* We don't push any register information onto the failure stack. */
2543 unsigned num_regs = 0;
2544
2545 register char *fastmap = bufp->fastmap;
2546 unsigned char *pattern = bufp->buffer;
2547 unsigned long size = bufp->used;
2548 const unsigned char *p = pattern;
2549 register unsigned char *pend = pattern + size;
2550
2551 /* Assume that each path through the pattern can be null until
2552 proven otherwise. We set this false at the bottom of switch
2553 statement, to which we get only if a particular path doesn't
2554 match the empty string. */
2555 boolean path_can_be_null = true;
2556
2557 /* We aren't doing a `succeed_n' to begin with. */
2558 boolean succeed_n_p = false;
2559
2560 assert (fastmap != NULL && p != NULL);
2561
2562 INIT_FAIL_STACK ();
2563 bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */
2564 bufp->fastmap_accurate = 1; /* It will be when we're done. */
2565 bufp->can_be_null = 0;
2566
2567 while (p != pend || !FAIL_STACK_EMPTY ())
2568 {
2569 if (p == pend)
2570 {
2571 bufp->can_be_null |= path_can_be_null;
2572
2573 /* Reset for next path. */
2574 path_can_be_null = true;
2575
2576 p = fail_stack.stack[--fail_stack.avail];
2577 }
2578
2579 /* We should never be about to go beyond the end of the pattern. */
2580 assert (p < pend);
2581
2582#ifdef SWITCH_ENUM_BUG
2583 switch ((int) ((re_opcode_t) *p++))
2584#else
2585 switch ((re_opcode_t) *p++)
2586#endif
2587 {
2588
2589 /* I guess the idea here is to simply not bother with a fastmap
2590 if a backreference is used, since it's too hard to figure out

Callers 1

re_search_2Function · 0.85

Calls 1

abortFunction · 0.50

Tested by

no test coverage detected