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

Function regex_compile

util/kconfig/regex.c:1063–2058  ·  view source on GitHub ↗
(pattern, size, syntax, bufp)

Source from the content-addressed store, hash-verified

1061 examined nor set. */
1062
1063static reg_errcode_t
1064regex_compile (pattern, size, syntax, bufp)
1065 const char *pattern;
1066 int size;
1067 reg_syntax_t syntax;
1068 struct re_pattern_buffer *bufp;
1069{
1070 /* We fetch characters from PATTERN here. Even though PATTERN is
1071 `char *' (i.e., signed), we declare these variables as unsigned, so
1072 they can be reliably used as array indices. */
1073 register unsigned char c, c1;
1074
1075 /* A random tempory spot in PATTERN. */
1076 const char *p1;
1077
1078 /* Points to the end of the buffer, where we should append. */
1079 register unsigned char *b;
1080
1081 /* Keeps track of unclosed groups. */
1082 compile_stack_type compile_stack;
1083
1084 /* Points to the current (ending) position in the pattern. */
1085 const char *p = pattern;
1086 const char *pend = pattern + size;
1087
1088 /* How to translate the characters in the pattern. */
1089 char *translate = bufp->translate;
1090
1091 /* Address of the count-byte of the most recently inserted `exactn'
1092 command. This makes it possible to tell if a new exact-match
1093 character can be added to that command or if the character requires
1094 a new `exactn' command. */
1095 unsigned char *pending_exact = NULL;
1096
1097 /* Address of start of the most recently finished expression.
1098 This tells, e.g., postfix * where to find the start of its
1099 operand. Reset at the beginning of groups and alternatives. */
1100 unsigned char *laststart = NULL;
1101
1102 /* Address of beginning of regexp, or inside of last group. */
1103 unsigned char *begalt;
1104
1105 /* Place in the uncompiled pattern (i.e., the {) to
1106 which to go back if the interval is invalid. */
1107 const char *beg_interval;
1108
1109 /* Address of the place where a forward jump should go to the end of
1110 the containing expression. Each alternative of an `or' -- except the
1111 last -- ends with a forward jump of this sort. */
1112 unsigned char *fixup_alt_jump = NULL;
1113
1114 /* Counts open-groups as they are encountered. Remembered for the
1115 matching close-group on the compile stack, so the same register
1116 number is put in the stop_memory as the start_memory. */
1117 regnum_t regnum = 0;
1118
1119#ifdef DEBUG
1120 DEBUG_PRINT1 ("\nCompiling pattern: ");

Callers 2

regex.cFile · 0.85
regcompFunction · 0.85

Calls 9

putcharFunction · 0.85
init_syntax_onceFunction · 0.85
at_begline_loc_pFunction · 0.85
at_endline_loc_pFunction · 0.85
compile_rangeFunction · 0.85
insert_op2Function · 0.85
group_in_compile_stackFunction · 0.85
print_compiled_patternFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected