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

Function re_search_2

util/kconfig/regex.c:2878–2992  ·  view source on GitHub ↗
(bufp, string1, size1, string2, size2, startpos, range, regs, stop)

Source from the content-addressed store, hash-verified

2876 stack overflow). */
2877
2878int
2879re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
2880 struct re_pattern_buffer *bufp;
2881 const char *string1, *string2;
2882 int size1, size2;
2883 int startpos;
2884 int range;
2885 struct re_registers *regs;
2886 int stop;
2887{
2888 int val;
2889 register char *fastmap = bufp->fastmap;
2890 register char *translate = bufp->translate;
2891 int total_size = size1 + size2;
2892 int endpos = startpos + range;
2893
2894 /* Check for out-of-range STARTPOS. */
2895 if (startpos < 0 || startpos > total_size)
2896 return -1;
2897
2898 /* Fix up RANGE if it might eventually take us outside
2899 the virtual concatenation of STRING1 and STRING2. */
2900 if (endpos < -1)
2901 range = -1 - startpos;
2902 else if (endpos > total_size)
2903 range = total_size - startpos;
2904
2905 /* If the search isn't to be a backwards one, don't waste time in a
2906 search for a pattern that must be anchored. */
2907 if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0)
2908 {
2909 if (startpos > 0)
2910 return -1;
2911 else
2912 range = 1;
2913 }
2914
2915 /* Update the fastmap now if not correct already. */
2916 if (fastmap && !bufp->fastmap_accurate)
2917 if (re_compile_fastmap (bufp) == -2)
2918 return -2;
2919
2920 /* Loop through the string, looking for a place to start matching. */
2921 for (;;)
2922 {
2923 /* If a fastmap is supplied, skip quickly over characters that
2924 cannot be the start of a match. If the pattern can match the
2925 null string, however, we don't need to skip characters; we want
2926 the first null string. */
2927 if (fastmap && startpos < total_size && !bufp->can_be_null)
2928 {
2929 if (range > 0) /* Searching forwards. */
2930 {
2931 register const char *d;
2932 register int lim = 0;
2933 int irange = range;
2934
2935 if (startpos < size1 && startpos + range >= size1)

Callers 1

re_searchFunction · 0.85

Calls 2

re_compile_fastmapFunction · 0.85
re_match_2Function · 0.85

Tested by

no test coverage detected