24 #if defined _AIX && !defined REGEX_MALLOC
36 # if defined __GNUC__ || (defined __STDC__ && __STDC__)
37 # define PARAMS(args) args
39 # define PARAMS(args) ()
43 #ifndef INSIDE_RECURSION
45 # if defined STDC_HEADERS && !defined emacs
49 # include <sys/types.h>
52 # define WIDE_CHAR_SUPPORT (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC)
56 # if defined _LIBC || WIDE_CHAR_SUPPORT
64 # define regfree(preg) __regfree (preg)
65 # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
66 # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
67 # define regerror(errcode, preg, errbuf, errbuf_size) \
68 __regerror(errcode, preg, errbuf, errbuf_size)
69 # define re_set_registers(bu, re, nu, st, en) \
70 __re_set_registers (bu, re, nu, st, en)
71 # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
72 __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
73 # define re_match(bufp, string, size, pos, regs) \
74 __re_match (bufp, string, size, pos, regs)
75 # define re_search(bufp, string, size, startpos, range, regs) \
76 __re_search (bufp, string, size, startpos, range, regs)
77 # define re_compile_pattern(pattern, length, bufp) \
78 __re_compile_pattern (pattern, length, bufp)
79 # define re_set_syntax(syntax) __re_set_syntax (syntax)
80 # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
81 __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
82 # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
84 # define btowc __btowc
87 # include <locale/localeinfo.h>
88 # include <locale/elem-hash.h>
89 # include <langinfo.h>
90 # include <locale/coll-lookup.h>
94 # if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
98 # define gettext(msgid) __dcgettext ("libc", msgid, LC_MESSAGES)
101 # define gettext(msgid) (msgid)
104 # ifndef gettext_noop
107 # define gettext_noop(String) String
125 # if defined STDC_HEADERS || defined _LIBC
134 # ifdef INHIBIT_STRING_HEADER
135 # if !(defined HAVE_BZERO && defined HAVE_BCOPY)
136 # if !defined bzero && !defined bcopy
137 # undef INHIBIT_STRING_HEADER
145 #define HAVE_STRING_H // for SWORD Project
146 # ifndef INHIBIT_STRING_HEADER
147 # if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC
151 # define bzero(s, n) (memset (s, '\0', n), (s))
153 # define bzero(s, n) __bzero (s, n)
157 # include <strings.h>
159 # define memcmp(s1, s2, n) bcmp (s1, s2, n)
162 # define memcpy(d, s, n) (bcopy (s, d, n), (d))
175 # ifdef SWITCH_ENUM_BUG
176 # define SWITCH_ENUM_CAST(x) ((int)(x))
178 # define SWITCH_ENUM_CAST(x) (x)
183 # if defined _LIBC || HAVE_LIMITS_H
188 # define MB_LEN_MAX 1
211 # if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
212 # define ISASCII(c) 1
214 # define ISASCII(c) isascii(c)
218 # define ISBLANK(c) (ISASCII (c) && isblank (c))
220 # define ISBLANK(c) ((c) == ' ' || (c) == '\t')
223 # define ISGRAPH(c) (ISASCII (c) && isgraph (c))
225 # define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
229 # define ISPRINT(c) (ISASCII (c) && isprint (c))
230 # define ISDIGIT(c) (ISASCII (c) && isdigit (c))
231 # define ISALNUM(c) (ISASCII (c) && isalnum (c))
232 # define ISALPHA(c) (ISASCII (c) && isalpha (c))
233 # define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
234 # define ISLOWER(c) (ISASCII (c) && islower (c))
235 # define ISPUNCT(c) (ISASCII (c) && ispunct (c))
236 # define ISSPACE(c) (ISASCII (c) && isspace (c))
237 # define ISUPPER(c) (ISASCII (c) && isupper (c))
238 # define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
241 # define TOLOWER(c) _tolower(c)
243 # define TOLOWER(c) tolower(c)
247 # define NULL (void *)0
254 # undef SIGN_EXTEND_CHAR
256 # define SIGN_EXTEND_CHAR(c) ((signed char) (c))
259 # define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
265 # define CHAR_SET_SIZE 256
298 # define SYNTAX(c) re_syntax_table[(unsigned char) (c)]
302 #define HAVE_UINTPTR_T
304 # if !defined _LIBC && !defined HAVE_UINTPTR_T
305 typedef unsigned long int uintptr_t;
320 # define REGEX_ALLOCATE malloc
321 # define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize)
322 # define REGEX_FREE free
331 # define alloca __builtin_alloca
340 # define REGEX_ALLOCATE alloca
343 # define REGEX_REALLOCATE(source, osize, nsize) \
344 (destination = (char *) alloca (nsize), \
345 memcpy (destination, source, osize))
348 # define REGEX_FREE(arg) ((void)0)
354 # if defined REL_ALLOC && defined REGEX_MALLOC
356 # define REGEX_ALLOCATE_STACK(size) \
357 r_alloc (&failure_stack_ptr, (size))
358 # define REGEX_REALLOCATE_STACK(source, osize, nsize) \
359 r_re_alloc (&failure_stack_ptr, (nsize))
360 # define REGEX_FREE_STACK(ptr) \
361 r_alloc_free (&failure_stack_ptr)
367 # define REGEX_ALLOCATE_STACK malloc
368 # define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize)
369 # define REGEX_FREE_STACK free
373 # define REGEX_ALLOCATE_STACK alloca
375 # define REGEX_REALLOCATE_STACK(source, osize, nsize) \
376 REGEX_REALLOCATE (source, osize, nsize)
378 # define REGEX_FREE_STACK(arg)
387 # define FIRST_STRING_P(ptr) \
388 (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
391 # define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t)))
392 # define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
393 # define RETALLOC_IF(addr, n, t) \
394 if (addr) RETALLOC((addr), (n), t); else (addr) = TALLOC ((n), t)
395 # define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
399 # define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
403 # define MAX(a, b) ((a) > (b) ? (a) : (b))
404 # define MIN(a, b) ((a) < (b) ? (a) : (b))
434 const char *cstring1,
int csize1,
435 const char *cstring2,
int csize2,
441 int *mbs_offset1,
int *mbs_offset2));
614 # define UCHAR_T unsigned char
615 # define COMPILED_BUFFER_VAR bufp->buffer
616 # define OFFSET_ADDRESS_SIZE 2
617 # define PREFIX(name) byte_##name
618 # define ARG_PREFIX(name) name
619 # define PUT_CHAR(c) putchar (c)
622 # define CHAR_T wchar_t
623 # define UCHAR_T wchar_t
624 # define COMPILED_BUFFER_VAR wc_buffer
625 # define OFFSET_ADDRESS_SIZE 1
626 # define CHAR_CLASS_SIZE ((__alignof__(wctype_t)+sizeof(wctype_t))/sizeof(CHAR_T)+1)
627 # define PREFIX(name) wcs_##name
628 # define ARG_PREFIX(name) c##name
630 # define PUT_CHAR(c) printf ("%C", c);
636 # define INSIDE_RECURSION
638 # undef INSIDE_RECURSION
641 # define INSIDE_RECURSION
643 # undef INSIDE_RECURSION
647 #ifdef INSIDE_RECURSION
654 # define STORE_NUMBER(destination, number) \
656 *(destination) = (UCHAR_T)(number); \
659 # define STORE_NUMBER(destination, number) \
661 (destination)[0] = (number) & 0377; \
662 (destination)[1] = (number) >> 8; \
671 # define STORE_NUMBER_AND_INCR(destination, number) \
673 STORE_NUMBER (destination, number); \
674 (destination) += OFFSET_ADDRESS_SIZE; \
682 # define EXTRACT_NUMBER(destination, source) \
684 (destination) = *(source); \
687 # define EXTRACT_NUMBER(destination, source) \
689 (destination) = *(source) & 0377; \
690 (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \
695 static void PREFIX(extract_number)
_RE_ARGS ((
int *dest, UCHAR_T *source));
697 PREFIX(extract_number) (dest, source)
705 *dest = *source & 0377;
710 # ifndef EXTRACT_MACROS
711 # undef EXTRACT_NUMBER
712 # define EXTRACT_NUMBER(dest, src) PREFIX(extract_number) (&dest, src)
720 # define EXTRACT_NUMBER_AND_INCR(destination, source) \
722 EXTRACT_NUMBER (destination, source); \
723 (source) += OFFSET_ADDRESS_SIZE; \
727 static void PREFIX(extract_number_and_incr)
_RE_ARGS ((
int *destination,
730 PREFIX(extract_number_and_incr) (destination, source)
734 PREFIX(extract_number) (destination, *source);
735 *source += OFFSET_ADDRESS_SIZE;
738 # ifndef EXTRACT_MACROS
739 # undef EXTRACT_NUMBER_AND_INCR
740 # define EXTRACT_NUMBER_AND_INCR(dest, src) \
741 PREFIX(extract_number_and_incr) (&dest, &src)
757 # ifndef DEFINED_ONCE
767 # define DEBUG_STATEMENT(e) e
768 # define DEBUG_PRINT1(x) if (debug) printf (x)
769 # define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2)
770 # define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3)
771 # define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4)
774 # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \
775 if (debug) PREFIX(print_partial_compiled_pattern) (s, e)
776 # define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \
777 if (debug) PREFIX(print_double_string) (w, s1, sz1, s2, sz2)
782 # ifndef DEFINED_ONCE
787 unsigned was_a_range = 0;
796 while (i < (1 <<
BYTEWIDTH) && fastmap[i])
817 PREFIX(print_partial_compiled_pattern) (start, end)
836 printf (
"%td:\t", p - start);
838 printf (
"%ld:\t", (
long int) (p - start));
849 printf (
"/exactn/%d", mcnt);
861 printf (
"/exactn_bin/%d", mcnt);
864 printf(
"/%lx", (
long int) *p++);
872 printf (
"/start_memory/%d/%ld", mcnt, (
long int) *p++);
877 printf (
"/stop_memory/%d/%ld", mcnt, (
long int) *p++);
881 printf (
"/duplicate/%ld", (
long int) *p++);
894 printf (
"/charset [%s",
898 for (i=0 ; i<
length ; i++)
899 printf(
"[:%lx:]", (
long int) *p++);
905 PUT_CHAR((i++,*p++));
914 PUT_CHAR((i++,*p++));
919 for (i=0 ; i<
length ; i++)
921 wchar_t range_start = *p++;
922 wchar_t range_end = *p++;
923 printf(
"%C-%C", range_start, range_end);
926 for (i=0 ; i<
length ; i++)
930 register int c, last = -100;
931 register int in_range = 0;
933 printf (
"/charset [%s",
936 assert (p + *p < pend);
938 for (c = 0; c < 256; c++)
940 && (p[1 + (c/8)] & (1 << (c % 8))))
943 if (last + 1 == c && ! in_range)
949 else if (last + 1 != c && in_range)
980 PREFIX(extract_number_and_incr) (&mcnt, &p);
982 printf (
"/on_failure_jump to %td", p + mcnt - start);
984 printf (
"/on_failure_jump to %ld", (
long int) (p + mcnt - start));
989 PREFIX(extract_number_and_incr) (&mcnt, &p);
991 printf (
"/on_failure_keep_string_jump to %td", p + mcnt - start);
993 printf (
"/on_failure_keep_string_jump to %ld",
994 (
long int) (p + mcnt - start));
999 PREFIX(extract_number_and_incr) (&mcnt, &p);
1001 printf (
"/dummy_failure_jump to %td", p + mcnt - start);
1003 printf (
"/dummy_failure_jump to %ld", (
long int) (p + mcnt - start));
1008 printf (
"/push_dummy_failure");
1012 PREFIX(extract_number_and_incr) (&mcnt, &p);
1014 printf (
"/maybe_pop_jump to %td", p + mcnt - start);
1016 printf (
"/maybe_pop_jump to %ld", (
long int) (p + mcnt - start));
1021 PREFIX(extract_number_and_incr) (&mcnt, &p);
1023 printf (
"/pop_failure_jump to %td", p + mcnt - start);
1025 printf (
"/pop_failure_jump to %ld", (
long int) (p + mcnt - start));
1030 PREFIX(extract_number_and_incr) (&mcnt, &p);
1032 printf (
"/jump_past_alt to %td", p + mcnt - start);
1034 printf (
"/jump_past_alt to %ld", (
long int) (p + mcnt - start));
1039 PREFIX(extract_number_and_incr) (&mcnt, &p);
1041 printf (
"/jump to %td", p + mcnt - start);
1043 printf (
"/jump to %ld", (
long int) (p + mcnt - start));
1048 PREFIX(extract_number_and_incr) (&mcnt, &p);
1050 PREFIX(extract_number_and_incr) (&mcnt2, &p);
1052 printf (
"/succeed_n to %td, %d times", p1 - start, mcnt2);
1054 printf (
"/succeed_n to %ld, %d times",
1055 (
long int) (p1 - start), mcnt2);
1060 PREFIX(extract_number_and_incr) (&mcnt, &p);
1062 PREFIX(extract_number_and_incr) (&mcnt2, &p);
1063 printf (
"/jump_n to %d, %d times", p1 - start, mcnt2);
1067 PREFIX(extract_number_and_incr) (&mcnt, &p);
1069 PREFIX(extract_number_and_incr) (&mcnt2, &p);
1071 printf (
"/set_number_at location %td to %d", p1 - start, mcnt2);
1073 printf (
"/set_number_at location %ld to %d",
1074 (
long int) (p1 - start), mcnt2);
1079 printf (
"/wordbound");
1083 printf (
"/notwordbound");
1087 printf (
"/wordbeg");
1091 printf (
"/wordend");
1096 printf (
"/before_dot");
1104 printf (
"/after_dot");
1108 printf (
"/syntaxspec");
1110 printf (
"/%d", mcnt);
1114 printf (
"/notsyntaxspec");
1116 printf (
"/%d", mcnt);
1121 printf (
"/wordchar");
1125 printf (
"/notwordchar");
1137 printf (
"?%ld", (
long int) *(p-1));
1144 printf (
"%td:\tend of pattern.\n", p - start);
1146 printf (
"%ld:\tend of pattern.\n", (
long int) (p - start));
1152 PREFIX(print_compiled_pattern) (
bufp)
1157 PREFIX(print_partial_compiled_pattern) (
buffer, buffer
1159 printf (
"%ld bytes used/%ld bytes allocated.\n",
1164 printf (
"fastmap: ");
1171 printf (
"re_nsub: %ld\t", (
long int)
bufp->
re_nsub);
1186 const CHAR_T *where;
1202 for (this_char = where - string1; this_char <
size1; this_char++)
1203 PUT_CHAR (string1[this_char]);
1209 for (this_char = where - string2; this_char <
size2; this_char++)
1211 PUT_CHAR (string2[this_char]);
1214 fputs (
"...", stdout);
1221 # ifndef DEFINED_ONCE
1232 # ifndef DEFINED_ONCE
1236 # define DEBUG_STATEMENT(e)
1237 # define DEBUG_PRINT1(x)
1238 # define DEBUG_PRINT2(x1, x2)
1239 # define DEBUG_PRINT3(x1, x2, x3)
1240 # define DEBUG_PRINT4(x1, x2, x3, x4)
1242 # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)
1243 # define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)
1258 static size_t convert_mbs_to_wcs (CHAR_T *dest,
const unsigned char* src,
1259 size_t len,
int *offset_buffer,
1262 convert_mbs_to_wcs (dest, src, len, offset_buffer, is_binary)
1264 const unsigned char* src;
1279 wchar_t *pdest = dest;
1280 const unsigned char *psrc = src;
1281 size_t wc_count = 0;
1285 size_t mb_remain = len;
1286 size_t mb_count = 0;
1289 memset (&mbs, 0,
sizeof (mbstate_t));
1291 offset_buffer[0] = 0;
1292 for( ; mb_remain > 0 ; ++wc_count, ++pdest, mb_remain -= consumed,
1296 consumed = __mbrtowc (pdest, psrc, mb_remain, &mbs);
1298 consumed = mbrtowc (pdest, psrc, mb_remain, &mbs);
1307 is_binary[wc_count] = TRUE;
1310 is_binary[wc_count] = FALSE;
1315 if (consumed == 1 && (
int) *psrc == 0x5c && (
int) *pdest == 0xa5)
1316 *pdest = (wchar_t) *psrc;
1318 offset_buffer[wc_count + 1] = mb_count += consumed;
1322 for (i = wc_count + 1 ; i <= len ; i++)
1323 offset_buffer[i] = mb_count + 1;
1353 re_syntax_options =
syntax;
1363 weak_alias (__re_set_syntax, re_set_syntax)
1374 # define REG_NOERROR_IDX 0
1377 # define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
1380 # define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match")
1383 # define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
1386 # define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
1389 # define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name")
1392 # define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash")
1395 # define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
1398 # define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^")
1401 # define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
1404 # define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{")
1407 # define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
1410 # define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end")
1413 # define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted")
1416 # define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
1419 # define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression")
1422 # define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big")
1450 #ifndef DEFINED_ONCE
1471 # define MATCH_MAY_ALLOCATE
1484 # if (defined C_ALLOCA || defined REGEX_MALLOC) && defined emacs
1485 # undef MATCH_MAY_ALLOCATE
1490 #ifdef INSIDE_RECURSION
1499 # ifndef INIT_FAILURE_ALLOC
1500 # define INIT_FAILURE_ALLOC 5
1508 # ifdef INT_IS_16BIT
1510 # ifndef DEFINED_ONCE
1511 # if defined MATCH_MAY_ALLOCATE
1514 long int re_max_failures = 4000;
1516 long int re_max_failures = 2000;
1520 union PREFIX(fail_stack_elt)
1526 typedef union PREFIX(fail_stack_elt) PREFIX(fail_stack_elt_t);
1530 PREFIX(fail_stack_elt_t) *stack;
1531 unsigned long int size;
1532 unsigned long int avail;
1533 } PREFIX(fail_stack_type);
1537 # ifndef DEFINED_ONCE
1538 # if defined MATCH_MAY_ALLOCATE
1541 int re_max_failures = 4000;
1543 int re_max_failures = 2000;
1547 union PREFIX(fail_stack_elt)
1553 typedef union PREFIX(fail_stack_elt) PREFIX(fail_stack_elt_t);
1557 PREFIX(fail_stack_elt_t) *stack;
1560 } PREFIX(fail_stack_type);
1564 # ifndef DEFINED_ONCE
1565 # define FAIL_STACK_EMPTY() (fail_stack.avail == 0)
1566 # define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0)
1567 # define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size)
1574 # ifdef MATCH_MAY_ALLOCATE
1575 # define INIT_FAIL_STACK() \
1577 fail_stack.stack = (PREFIX(fail_stack_elt_t) *) \
1578 REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * sizeof (PREFIX(fail_stack_elt_t))); \
1580 if (fail_stack.stack == NULL) \
1583 fail_stack.size = INIT_FAILURE_ALLOC; \
1584 fail_stack.avail = 0; \
1587 # define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack)
1589 # define INIT_FAIL_STACK() \
1591 fail_stack.avail = 0; \
1594 # define RESET_FAIL_STACK()
1605 # define DOUBLE_FAIL_STACK(fail_stack) \
1606 ((fail_stack).size > (unsigned) (re_max_failures * MAX_FAILURE_ITEMS) \
1608 : ((fail_stack).stack = (PREFIX(fail_stack_elt_t) *) \
1609 REGEX_REALLOCATE_STACK ((fail_stack).stack, \
1610 (fail_stack).size * sizeof (PREFIX(fail_stack_elt_t)), \
1611 ((fail_stack).size << 1) * sizeof (PREFIX(fail_stack_elt_t))),\
1613 (fail_stack).stack == NULL \
1615 : ((fail_stack).size <<= 1, \
1622 # define PUSH_PATTERN_OP(POINTER, FAIL_STACK) \
1623 ((FAIL_STACK_FULL () \
1624 && !DOUBLE_FAIL_STACK (FAIL_STACK)) \
1626 : ((FAIL_STACK).stack[(FAIL_STACK).avail++].pointer = POINTER, \
1632 # define PUSH_FAILURE_POINTER(item) \
1633 fail_stack.stack[fail_stack.avail++].pointer = (UCHAR_T *) (item)
1638 # define PUSH_FAILURE_INT(item) \
1639 fail_stack.stack[fail_stack.avail++].integer = (item)
1644 # define PUSH_FAILURE_ELT(item) \
1645 fail_stack.stack[fail_stack.avail++] = (item)
1649 # define POP_FAILURE_POINTER() fail_stack.stack[--fail_stack.avail].pointer
1650 # define POP_FAILURE_INT() fail_stack.stack[--fail_stack.avail].integer
1651 # define POP_FAILURE_ELT() fail_stack.stack[--fail_stack.avail]
1655 # define DEBUG_PUSH PUSH_FAILURE_INT
1656 # define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT ()
1658 # define DEBUG_PUSH(item)
1659 # define DEBUG_POP(item_addr)
1672 # define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \
1674 char *destination; \
1680 active_reg_t this_reg; \
1682 DEBUG_STATEMENT (failure_id++); \
1683 DEBUG_STATEMENT (nfailure_points_pushed++); \
1684 DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \
1685 DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\
1686 DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\
1688 DEBUG_PRINT2 (" slots needed: %ld\n", NUM_FAILURE_ITEMS); \
1689 DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \
1692 while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \
1694 if (!DOUBLE_FAIL_STACK (fail_stack)) \
1695 return failure_code; \
1697 DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \
1698 (fail_stack).size); \
1699 DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\
1703 DEBUG_PRINT1 ("\n"); \
1706 for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \
1709 DEBUG_PRINT2 (" Pushing reg: %lu\n", this_reg); \
1710 DEBUG_STATEMENT (num_regs_pushed++); \
1712 DEBUG_PRINT2 (" start: %p\n", regstart[this_reg]); \
1713 PUSH_FAILURE_POINTER (regstart[this_reg]); \
1715 DEBUG_PRINT2 (" end: %p\n", regend[this_reg]); \
1716 PUSH_FAILURE_POINTER (regend[this_reg]); \
1718 DEBUG_PRINT2 (" info: %p\n ", \
1719 reg_info[this_reg].word.pointer); \
1720 DEBUG_PRINT2 (" match_null=%d", \
1721 REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \
1722 DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \
1723 DEBUG_PRINT2 (" matched_something=%d", \
1724 MATCHED_SOMETHING (reg_info[this_reg])); \
1725 DEBUG_PRINT2 (" ever_matched=%d", \
1726 EVER_MATCHED_SOMETHING (reg_info[this_reg])); \
1727 DEBUG_PRINT1 ("\n"); \
1728 PUSH_FAILURE_ELT (reg_info[this_reg].word); \
1731 DEBUG_PRINT2 (" Pushing low active reg: %ld\n", lowest_active_reg);\
1732 PUSH_FAILURE_INT (lowest_active_reg); \
1734 DEBUG_PRINT2 (" Pushing high active reg: %ld\n", highest_active_reg);\
1735 PUSH_FAILURE_INT (highest_active_reg); \
1737 DEBUG_PRINT2 (" Pushing pattern %p:\n", pattern_place); \
1738 DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
1739 PUSH_FAILURE_POINTER (pattern_place); \
1741 DEBUG_PRINT2 (" Pushing string %p: `", string_place); \
1742 DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \
1744 DEBUG_PRINT1 ("'\n"); \
1745 PUSH_FAILURE_POINTER (string_place); \
1747 DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \
1748 DEBUG_PUSH (failure_id); \
1751 # ifndef DEFINED_ONCE
1754 # define NUM_REG_ITEMS 3
1758 # define NUM_NONREG_ITEMS 5
1760 # define NUM_NONREG_ITEMS 4
1767 # define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS)
1770 # define NUM_FAILURE_ITEMS \
1772 ? 0 : highest_active_reg - lowest_active_reg + 1) \
1777 # define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail)
1792 # define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\
1794 DEBUG_STATEMENT (unsigned failure_id;) \
1795 active_reg_t this_reg; \
1796 const UCHAR_T *string_temp; \
1798 assert (!FAIL_STACK_EMPTY ()); \
1801 DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \
1802 DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \
1803 DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \
1805 assert (fail_stack.avail >= NUM_NONREG_ITEMS); \
1807 DEBUG_POP (&failure_id); \
1808 DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \
1813 string_temp = POP_FAILURE_POINTER (); \
1814 if (string_temp != NULL) \
1815 str = (const CHAR_T *) string_temp; \
1817 DEBUG_PRINT2 (" Popping string %p: `", str); \
1818 DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \
1819 DEBUG_PRINT1 ("'\n"); \
1821 pat = (UCHAR_T *) POP_FAILURE_POINTER (); \
1822 DEBUG_PRINT2 (" Popping pattern %p:\n", pat); \
1823 DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
1826 high_reg = (active_reg_t) POP_FAILURE_INT (); \
1827 DEBUG_PRINT2 (" Popping high active reg: %ld\n", high_reg); \
1829 low_reg = (active_reg_t) POP_FAILURE_INT (); \
1830 DEBUG_PRINT2 (" Popping low active reg: %ld\n", low_reg); \
1833 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
1835 DEBUG_PRINT2 (" Popping reg: %ld\n", this_reg); \
1837 reg_info[this_reg].word = POP_FAILURE_ELT (); \
1838 DEBUG_PRINT2 (" info: %p\n", \
1839 reg_info[this_reg].word.pointer); \
1841 regend[this_reg] = (const CHAR_T *) POP_FAILURE_POINTER (); \
1842 DEBUG_PRINT2 (" end: %p\n", regend[this_reg]); \
1844 regstart[this_reg] = (const CHAR_T *) POP_FAILURE_POINTER (); \
1845 DEBUG_PRINT2 (" start: %p\n", regstart[this_reg]); \
1849 for (this_reg = highest_active_reg; this_reg > high_reg; this_reg--) \
1851 reg_info[this_reg].word.integer = 0; \
1852 regend[this_reg] = 0; \
1853 regstart[this_reg] = 0; \
1855 highest_active_reg = high_reg; \
1858 set_regs_matched_done = 0; \
1859 DEBUG_STATEMENT (nfailure_points_popped++); \
1879 PREFIX(fail_stack_elt_t) word;
1884 # define MATCH_NULL_UNSET_VALUE 3
1885 unsigned match_null_string_p : 2;
1886 unsigned is_active : 1;
1887 unsigned matched_something : 1;
1888 unsigned ever_matched_something : 1;
1890 } PREFIX(register_info_type);
1892 # ifndef DEFINED_ONCE
1893 # define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p)
1894 # define IS_ACTIVE(R) ((R).bits.is_active)
1895 # define MATCHED_SOMETHING(R) ((R).bits.matched_something)
1896 # define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something)
1902 # define SET_REGS_MATCHED() \
1905 if (!set_regs_matched_done) \
1908 set_regs_matched_done = 1; \
1909 for (r = lowest_active_reg; r <= highest_active_reg; r++) \
1911 MATCHED_SOMETHING (reg_info[r]) \
1912 = EVER_MATCHED_SOMETHING (reg_info[r]) \
1921 static CHAR_T PREFIX(reg_unset_dummy);
1922 # define REG_UNSET_VALUE (&PREFIX(reg_unset_dummy))
1923 # define REG_UNSET(e) ((e) == REG_UNSET_VALUE)
1928 int arg1,
int arg2));
1930 int arg, UCHAR_T *end));
1932 int arg1,
int arg2, UCHAR_T *end));
1936 static
boolean PREFIX(at_endline_loc_p)
_RE_ARGS ((
const CHAR_T *p,
1941 const CHAR_T **p_ptr,
1947 static void insert_space
_RE_ARGS ((
int num, CHAR_T *loc, CHAR_T *end));
1966 # define PATFETCH(c) \
1967 do {if (p == pend) return REG_EEND; \
1968 c = (UCHAR_T) *p++; \
1969 if (translate && (c <= 0xff)) c = (UCHAR_T) translate[c]; \
1972 # define PATFETCH(c) \
1973 do {if (p == pend) return REG_EEND; \
1974 c = (unsigned char) *p++; \
1975 if (translate) c = (unsigned char) translate[c]; \
1982 # define PATFETCH_RAW(c) \
1983 do {if (p == pend) return REG_EEND; \
1984 c = (UCHAR_T) *p++; \
1988 # define PATUNFETCH p--
2001 # define TRANSLATE(d) \
2002 ((translate && ((UCHAR_T) (d)) <= 0xff) \
2003 ? (char) translate[(unsigned char) (d)] : (d))
2005 # define TRANSLATE(d) \
2006 (translate ? (char) translate[(unsigned char) (d)] : (d))
2014 # define INIT_BUF_SIZE (32 * sizeof(UCHAR_T))
2018 # define GET_BUFFER_SPACE(n) \
2019 while (((unsigned long)b - (unsigned long)COMPILED_BUFFER_VAR \
2020 + (n)*sizeof(CHAR_T)) > bufp->allocated) \
2023 # define GET_BUFFER_SPACE(n) \
2024 while ((unsigned long) (b - bufp->buffer + (n)) > bufp->allocated) \
2029 # define BUF_PUSH(c) \
2031 GET_BUFFER_SPACE (1); \
2032 *b++ = (UCHAR_T) (c); \
2037 # define BUF_PUSH_2(c1, c2) \
2039 GET_BUFFER_SPACE (2); \
2040 *b++ = (UCHAR_T) (c1); \
2041 *b++ = (UCHAR_T) (c2); \
2046 # define BUF_PUSH_3(c1, c2, c3) \
2048 GET_BUFFER_SPACE (3); \
2049 *b++ = (UCHAR_T) (c1); \
2050 *b++ = (UCHAR_T) (c2); \
2051 *b++ = (UCHAR_T) (c3); \
2056 # define STORE_JUMP(op, loc, to) \
2057 PREFIX(store_op1) (op, loc, (int) ((to) - (loc) - (1 + OFFSET_ADDRESS_SIZE)))
2060 # define STORE_JUMP2(op, loc, to, arg) \
2061 PREFIX(store_op2) (op, loc, (int) ((to) - (loc) - (1 + OFFSET_ADDRESS_SIZE)), arg)
2064 # define INSERT_JUMP(op, loc, to) \
2065 PREFIX(insert_op1) (op, loc, (int) ((to) - (loc) - (1 + OFFSET_ADDRESS_SIZE)), b)
2068 # define INSERT_JUMP2(op, loc, to, arg) \
2069 PREFIX(insert_op2) (op, loc, (int) ((to) - (loc) - (1 + OFFSET_ADDRESS_SIZE)),\
2080 # ifndef DEFINED_ONCE
2081 # if defined _MSC_VER && !defined WIN32
2085 # define MAX_BUF_SIZE 65500L
2086 # define REALLOC(p,s) realloc ((p), (size_t) (s))
2088 # define MAX_BUF_SIZE (1L << 16)
2089 # define REALLOC(p,s) realloc ((p), (s))
2096 # if __BOUNDED_POINTERS__
2097 # define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
2098 # define MOVE_BUFFER_POINTER(P) \
2099 (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr)
2100 # define ELSE_EXTEND_BUFFER_HIGH_BOUND \
2103 SET_HIGH_BOUND (b); \
2104 SET_HIGH_BOUND (begalt); \
2105 if (fixup_alt_jump) \
2106 SET_HIGH_BOUND (fixup_alt_jump); \
2108 SET_HIGH_BOUND (laststart); \
2109 if (pending_exact) \
2110 SET_HIGH_BOUND (pending_exact); \
2113 # define MOVE_BUFFER_POINTER(P) (P) += incr
2114 # define ELSE_EXTEND_BUFFER_HIGH_BOUND
2119 # define EXTEND_BUFFER() \
2121 UCHAR_T *old_buffer = COMPILED_BUFFER_VAR; \
2123 if (bufp->allocated + sizeof(UCHAR_T) > MAX_BUF_SIZE) \
2125 bufp->allocated <<= 1; \
2126 if (bufp->allocated > MAX_BUF_SIZE) \
2127 bufp->allocated = MAX_BUF_SIZE; \
2129 wchar_count = bufp->allocated / sizeof(UCHAR_T); \
2130 if (wchar_count == 0) wchar_count = 1; \
2132 bufp->allocated = wchar_count * sizeof(UCHAR_T); \
2133 RETALLOC (COMPILED_BUFFER_VAR, wchar_count, UCHAR_T); \
2134 bufp->buffer = (char*)COMPILED_BUFFER_VAR; \
2135 if (COMPILED_BUFFER_VAR == NULL) \
2136 return REG_ESPACE; \
2138 if (old_buffer != COMPILED_BUFFER_VAR) \
2140 int incr = COMPILED_BUFFER_VAR - old_buffer; \
2141 MOVE_BUFFER_POINTER (b); \
2142 MOVE_BUFFER_POINTER (begalt); \
2143 if (fixup_alt_jump) \
2144 MOVE_BUFFER_POINTER (fixup_alt_jump); \
2146 MOVE_BUFFER_POINTER (laststart); \
2147 if (pending_exact) \
2148 MOVE_BUFFER_POINTER (pending_exact); \
2150 ELSE_EXTEND_BUFFER_HIGH_BOUND \
2153 # define EXTEND_BUFFER() \
2155 UCHAR_T *old_buffer = COMPILED_BUFFER_VAR; \
2156 if (bufp->allocated == MAX_BUF_SIZE) \
2158 bufp->allocated <<= 1; \
2159 if (bufp->allocated > MAX_BUF_SIZE) \
2160 bufp->allocated = MAX_BUF_SIZE; \
2161 bufp->buffer = (UCHAR_T *) REALLOC (COMPILED_BUFFER_VAR, \
2163 if (COMPILED_BUFFER_VAR == NULL) \
2164 return REG_ESPACE; \
2166 if (old_buffer != COMPILED_BUFFER_VAR) \
2168 int incr = COMPILED_BUFFER_VAR - old_buffer; \
2169 MOVE_BUFFER_POINTER (b); \
2170 MOVE_BUFFER_POINTER (begalt); \
2171 if (fixup_alt_jump) \
2172 MOVE_BUFFER_POINTER (fixup_alt_jump); \
2174 MOVE_BUFFER_POINTER (laststart); \
2175 if (pending_exact) \
2176 MOVE_BUFFER_POINTER (pending_exact); \
2178 ELSE_EXTEND_BUFFER_HIGH_BOUND \
2182 # ifndef DEFINED_ONCE
2186 # define MAX_REGNUM 255
2190 typedef unsigned regnum_t;
2198 typedef long pattern_offset_t;
2202 pattern_offset_t begalt_offset;
2203 pattern_offset_t fixup_alt_jump;
2204 pattern_offset_t inner_group_offset;
2205 pattern_offset_t laststart_offset;
2207 } compile_stack_elt_t;
2212 compile_stack_elt_t *stack;
2215 } compile_stack_type;
2218 # define INIT_COMPILE_STACK_SIZE 32
2220 # define COMPILE_STACK_EMPTY (compile_stack.avail == 0)
2221 # define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size)
2224 # define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])
2229 # ifndef DEFINED_ONCE
2230 # define SET_LIST_BIT(c) \
2231 (b[((unsigned char) (c)) / BYTEWIDTH] \
2232 |= 1 << (((unsigned char) c) % BYTEWIDTH))
2236 # define GET_UNSIGNED_NUMBER(num) \
2241 if (c < '0' || c > '9') \
2243 if (num <= RE_DUP_MAX) \
2247 num = num * 10 + c - '0'; \
2252 # ifndef DEFINED_ONCE
2253 # if defined _LIBC || WIDE_CHAR_SUPPORT
2256 # ifdef CHARCLASS_NAME_MAX
2257 # define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
2261 # define CHAR_CLASS_MAX_LENGTH 256
2265 # define IS_CHAR_CLASS(string) __wctype (string)
2267 # define IS_CHAR_CLASS(string) wctype (string)
2270 # define CHAR_CLASS_MAX_LENGTH 6
2272 # define IS_CHAR_CLASS(string) \
2273 (STREQ (string, "alpha") || STREQ (string, "upper") \
2274 || STREQ (string, "lower") || STREQ (string, "digit") \
2275 || STREQ (string, "alnum") || STREQ (string, "xdigit") \
2276 || STREQ (string, "space") || STREQ (string, "print") \
2277 || STREQ (string, "punct") || STREQ (string, "graph") \
2278 || STREQ (string, "cntrl") || STREQ (string, "blank"))
2283 # ifndef MATCH_MAY_ALLOCATE
2292 static PREFIX(fail_stack_type) fail_stack;
2297 # ifdef DEFINED_ONCE
2298 static int regs_allocated_size;
2300 static const char ** regstart, ** regend;
2301 static const char ** old_regstart, ** old_regend;
2302 static const char **best_regstart, **best_regend;
2303 static const char **reg_dummy;
2306 static PREFIX(register_info_type) *PREFIX(reg_info);
2307 static PREFIX(register_info_type) *PREFIX(reg_info_dummy);
2313 PREFIX(regex_grow_registers) (
num_regs)
2316 if (
num_regs > regs_allocated_size)
2335 # ifndef DEFINED_ONCE
2336 static boolean group_in_compile_stack
_RE_ARGS ((compile_stack_type
2361 # define FREE_STACK_RETURN(value) \
2362 return (free(pattern), free(mbs_offset), free(is_binary), free (compile_stack.stack), value)
2364 # define FREE_STACK_RETURN(value) \
2365 return (free (compile_stack.stack), value)
2369 PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(
size),
syntax,
bufp)
2370 const char *ARG_PREFIX(pattern);
2371 size_t ARG_PREFIX(
size);
2378 register UCHAR_T c, c1;
2382 CHAR_T *
pattern, *COMPILED_BUFFER_VAR;
2385 int *mbs_offset =
NULL;
2387 char *is_binary =
NULL;
2389 char is_exactn_bin = FALSE;
2396 register UCHAR_T *b;
2407 const CHAR_T *pend = pattern +
size;
2417 UCHAR_T *pending_exact = 0;
2422 UCHAR_T *laststart = 0;
2430 UCHAR_T *fixup_alt_jump = 0;
2439 p = pend = pattern =
TALLOC(csize + 1, CHAR_T);
2440 mbs_offset =
TALLOC(csize + 1,
int);
2441 is_binary =
TALLOC(csize + 1,
char);
2442 if (pattern ==
NULL || mbs_offset ==
NULL || is_binary ==
NULL)
2449 pattern[csize] = L
'\0';
2450 size = convert_mbs_to_wcs(pattern, cpattern, csize, mbs_offset, is_binary);
2462 DEBUG_PRINT1 (
"\nCompiling pattern: ");
2465 unsigned debug_count;
2467 for (debug_count = 0; debug_count <
size; debug_count++)
2468 PUT_CHAR (pattern[debug_count]);
2474 compile_stack.stack =
TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t);
2475 if (compile_stack.stack ==
NULL)
2485 compile_stack.size = INIT_COMPILE_STACK_SIZE;
2486 compile_stack.avail = 0;
2501 #if !defined emacs && !defined SYNTAX_TABLE
2516 COMPILED_BUFFER_VAR =
TALLOC (INIT_BUF_SIZE/
sizeof(UCHAR_T),
2519 RETALLOC (COMPILED_BUFFER_VAR, INIT_BUF_SIZE, UCHAR_T);
2524 COMPILED_BUFFER_VAR =
TALLOC (INIT_BUF_SIZE /
sizeof(UCHAR_T),
2528 if (!COMPILED_BUFFER_VAR) FREE_STACK_RETURN (
REG_ESPACE);
2536 COMPILED_BUFFER_VAR = (UCHAR_T*)
bufp->
buffer;
2539 begalt = b = COMPILED_BUFFER_VAR;
2555 || PREFIX(at_begline_loc_p) (pattern, p, syntax))
2570 || PREFIX(at_endline_loc_p) (p, pend, syntax))
2596 boolean keep_string_p =
false;
2599 char zero_times_ok = 0, many_times_ok = 0;
2608 zero_times_ok |= c !=
'+';
2609 many_times_ok |= c !=
'?';
2617 || (!(syntax & RE_BK_PLUS_QM) && (c ==
'+' || c ==
'?')))
2620 else if (syntax & RE_BK_PLUS_QM && c ==
'\\')
2625 if (!(c1 ==
'+' || c1 ==
'?'))
2661 assert (p - 1 > pattern);
2664 GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
2671 if (TRANSLATE (*(p - 2)) == TRANSLATE (
'.')
2673 && p < pend && TRANSLATE (*p) == TRANSLATE (
'\n')
2676 STORE_JUMP (
jump, b, laststart);
2677 keep_string_p =
true;
2682 (1 + OFFSET_ADDRESS_SIZE));
2685 b += 1 + OFFSET_ADDRESS_SIZE;
2692 GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
2695 laststart, b + 1 + OFFSET_ADDRESS_SIZE);
2697 b += 1 + OFFSET_ADDRESS_SIZE;
2706 GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
2708 2 + 2 * OFFSET_ADDRESS_SIZE);
2709 b += 1 + OFFSET_ADDRESS_SIZE;
2723 boolean had_char_class =
false;
2725 CHAR_T range_start = 0xffffffff;
2727 unsigned int range_start = 0xffffffff;
2729 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
2778 GET_BUFFER_SPACE (6);
2794 BUF_PUSH_3 (0, 0, 0);
2811 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
2830 if (c ==
']' && p != p1 + 1)
2835 if (had_char_class && c ==
'-' && *p !=
']')
2843 && !(p - 2 >= pattern && p[-2] ==
'[')
2844 && !(p - 3 >= pattern && p[-3] ==
'[' && p[-2] ==
'^')
2849 GET_BUFFER_SPACE (2);
2852 ret = wcs_compile_range (range_start, &p, pend, translate,
2853 syntax, b, laststart);
2855 range_start = 0xffffffff;
2857 else if (p[0] ==
'-' && p[1] !=
']')
2864 GET_BUFFER_SPACE (2);
2867 ret = wcs_compile_range (c, &p, pend, translate, syntax, b,
2870 range_start = 0xffffffff;
2877 char str[CHAR_CLASS_MAX_LENGTH + 1];
2883 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
2888 if ((c ==
':' && *p ==
']') || p == pend)
2890 if (c1 < CHAR_CLASS_MAX_LENGTH)
2901 if (c ==
':' && *p ==
']')
2907 wt = IS_CHAR_CLASS (str);
2915 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
2918 GET_BUFFER_SPACE(CHAR_CLASS_SIZE);
2920 b += CHAR_CLASS_SIZE;
2923 insert_space(CHAR_CLASS_SIZE,
2924 laststart + 6 + laststart[1],
2926 alignedp = ((uintptr_t)(laststart + 6 + laststart[1])
2927 + __alignof__(wctype_t) - 1)
2928 & ~(uintptr_t)(__alignof__(wctype_t) - 1);
2930 *((wctype_t*)alignedp) = wt;
2932 laststart[1] += CHAR_CLASS_SIZE;
2934 had_char_class =
true;
2945 had_char_class =
false;
2955 _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
2961 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
2966 if ((c == delim && *p ==
']') || p == pend)
2968 if (c1 <
sizeof (str) - 1)
2976 if (c == delim && *p ==
']' && str[0] !=
'\0')
2978 unsigned int i, offset;
2988 int datasize = c1 + 1;
3001 const int32_t *table;
3002 const int32_t *weights;
3003 const int32_t *extra;
3004 const int32_t *indirect;
3008 # include <locale/weightwc.h>
3015 table = (
const int32_t *)
3016 _NL_CURRENT (LC_COLLATE,
3017 _NL_COLLATE_TABLEWC);
3018 weights = (
const int32_t *)
3019 _NL_CURRENT (LC_COLLATE,
3020 _NL_COLLATE_WEIGHTWC);
3021 extra = (
const int32_t *)
3022 _NL_CURRENT (LC_COLLATE,
3023 _NL_COLLATE_EXTRAWC);
3024 indirect = (
const int32_t *)
3025 _NL_CURRENT (LC_COLLATE,
3026 _NL_COLLATE_INDIRECTWC);
3028 idx = findidx ((
const wint_t**)&cp);
3029 if (idx == 0 || cp < (wint_t*) str + c1)
3033 str[0] = (wchar_t)idx;
3040 const int32_t *symb_table;
3041 const unsigned char *extra;
3052 for (i = 0; i < c1; ++i)
3053 char_str[i] = str[i];
3056 _NL_CURRENT_WORD (LC_COLLATE,
3057 _NL_COLLATE_SYMB_HASH_SIZEMB);
3058 symb_table = (
const int32_t *)
3059 _NL_CURRENT (LC_COLLATE,
3060 _NL_COLLATE_SYMB_TABLEMB);
3061 extra = (
const unsigned char *)
3062 _NL_CURRENT (LC_COLLATE,
3063 _NL_COLLATE_SYMB_EXTRAMB);
3066 hash = elem_hash (char_str, c1);
3069 elem = hash % table_size;
3070 second = hash % (table_size - 2);
3071 while (symb_table[2 * elem] != 0)
3074 if (symb_table[2 * elem] == hash
3075 && c1 == extra[symb_table[2 * elem + 1]]
3076 && memcmp (char_str,
3077 &extra[symb_table[2 * elem + 1]
3081 idx = symb_table[2 * elem + 1];
3082 idx += 1 + extra[idx];
3090 if (symb_table[2 * elem] != 0)
3094 idx += 1 + extra[idx];
3096 idx = (idx + 3) & ~3;
3098 str[0] = (wchar_t) idx + 4;
3100 else if (symb_table[2 * elem] == 0 && c1 == 1)
3104 had_char_class =
false;
3108 range_start = str[0];
3128 GET_BUFFER_SPACE(datasize);
3136 offset = laststart[1] + laststart[2]
3139 insert_space(datasize, laststart + offset, b - 1);
3142 for (i = 0 ; i < datasize ; i++)
3143 laststart[offset + i] = str[i];
3146 laststart[3] += datasize;
3147 had_char_class =
true;
3153 offset = laststart[1] + laststart[2] + 6;
3156 insert_space(datasize, laststart + offset, b-1);
3157 for (i = 0 ; i < datasize ; i++)
3158 laststart[offset + i] = str[i];
3166 range_start = -(laststart[1] + laststart[2] + 6);
3168 laststart[2] += datasize;
3169 had_char_class =
false;
3180 range_start = delim;
3181 had_char_class =
false;
3186 had_char_class =
false;
3196 GET_BUFFER_SPACE (34);
3217 && (syntax & RE_HAT_LISTS_NOT_NEWLINE))
3218 SET_LIST_BIT (
'\n');
3223 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
3228 if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c ==
'\\')
3241 if (c ==
']' && p != p1 + 1)
3246 if (had_char_class && c ==
'-' && *p !=
']')
3254 && !(p - 2 >= pattern && p[-2] ==
'[')
3255 && !(p - 3 >= pattern && p[-3] ==
'[' && p[-2] ==
'^')
3259 = byte_compile_range (range_start, &p, pend, translate,
3262 range_start = 0xffffffff;
3265 else if (p[0] ==
'-' && p[1] !=
']')
3272 ret = byte_compile_range (c, &p, pend, translate, syntax, b);
3274 range_start = 0xffffffff;
3282 char str[CHAR_CLASS_MAX_LENGTH + 1];
3288 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
3293 if ((c ==
':' && *p ==
']') || p == pend)
3295 if (c1 < CHAR_CLASS_MAX_LENGTH)
3306 if (c ==
':' && *p ==
']')
3308 # if defined _LIBC || WIDE_CHAR_SUPPORT
3309 boolean is_lower =
STREQ (str,
"lower");
3310 boolean is_upper =
STREQ (str,
"upper");
3314 wt = IS_CHAR_CLASS (str);
3322 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
3327 if (__iswctype (__btowc (ch), wt))
3330 if (iswctype (btowc (ch), wt))
3334 if (translate && (is_upper || is_lower)
3339 had_char_class =
true;
3342 boolean is_alnum =
STREQ (str,
"alnum");
3343 boolean is_alpha =
STREQ (str,
"alpha");
3344 boolean is_blank =
STREQ (str,
"blank");
3345 boolean is_cntrl =
STREQ (str,
"cntrl");
3346 boolean is_digit =
STREQ (str,
"digit");
3347 boolean is_graph =
STREQ (str,
"graph");
3348 boolean is_lower =
STREQ (str,
"lower");
3349 boolean is_print =
STREQ (str,
"print");
3350 boolean is_punct =
STREQ (str,
"punct");
3351 boolean is_space =
STREQ (str,
"space");
3352 boolean is_upper =
STREQ (str,
"upper");
3353 boolean is_xdigit =
STREQ (str,
"xdigit");
3355 if (!IS_CHAR_CLASS (str))
3362 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
3368 if ( (is_alnum &&
ISALNUM (ch))
3371 || (is_cntrl &&
ISCNTRL (ch)))
3373 if ( (is_digit &&
ISDIGIT (ch))
3376 || (is_print &&
ISPRINT (ch)))
3378 if ( (is_punct &&
ISPUNCT (ch))
3383 if ( translate && (is_upper || is_lower)
3387 had_char_class =
true;
3398 had_char_class =
false;
3406 _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
3413 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
3418 if ((c ==
'=' && *p ==
']') || p == pend)
3428 if (c ==
'=' && *p ==
']' && str[0] !=
'\0')
3448 SET_LIST_BIT (str[0]);
3457 const int32_t *table;
3458 const unsigned char *weights;
3459 const unsigned char *extra;
3460 const int32_t *indirect;
3462 const unsigned char *cp = str;
3466 # include <locale/weight.h>
3468 table = (
const int32_t *)
3469 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
3470 weights = (
const unsigned char *)
3471 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
3472 extra = (
const unsigned char *)
3473 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
3474 indirect = (
const int32_t *)
3475 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
3477 idx = findidx (&cp);
3478 if (idx == 0 || cp < str + c1)
3494 for (ch = 1; ch < 256; ++ch)
3499 int32_t idx2 = table[ch];
3500 size_t len = weights[idx2];
3503 if (weights[idx] == len)
3510 && (weights[idx + 1 + cnt]
3511 == weights[idx2 + 1 + cnt]))
3522 had_char_class =
true;
3532 had_char_class =
false;
3537 unsigned char str[128];
3540 _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
3547 if (p == pend) FREE_STACK_RETURN (
REG_EBRACK);
3552 if ((c ==
'.' && *p ==
']') || p == pend)
3554 if (c1 <
sizeof (str))
3562 if (c ==
'.' && *p ==
']' && str[0] !=
'\0')
3583 SET_LIST_BIT (str[0]);
3584 range_start = ((
const unsigned char *) str)[0];
3594 const int32_t *symb_table;
3595 const unsigned char *extra;
3602 _NL_CURRENT_WORD (LC_COLLATE,
3603 _NL_COLLATE_SYMB_HASH_SIZEMB);
3604 symb_table = (
const int32_t *)
3605 _NL_CURRENT (LC_COLLATE,
3606 _NL_COLLATE_SYMB_TABLEMB);
3607 extra = (
const unsigned char *)
3608 _NL_CURRENT (LC_COLLATE,
3609 _NL_COLLATE_SYMB_EXTRAMB);
3612 hash = elem_hash (str, c1);
3615 elem = hash % table_size;
3616 second = hash % (table_size - 2);
3617 while (symb_table[2 * elem] != 0)
3620 if (symb_table[2 * elem] == hash
3621 && c1 == extra[symb_table[2 * elem + 1]]
3623 &extra[symb_table[2 * elem + 1]
3628 idx = symb_table[2 * elem + 1];
3629 idx += 1 + extra[idx];
3637 if (symb_table[2 * elem] == 0)
3657 range_start = extra[idx];
3660 SET_LIST_BIT (extra[idx]);
3665 had_char_class =
false;
3675 had_char_class =
false;
3680 had_char_class =
false;
3688 while ((
int) b[-1] > 0 && b[b[-1] - 1] == 0)
3704 if (syntax & RE_NO_BK_PARENS)
3726 goto handle_interval;
3742 if (syntax & RE_NO_BK_PARENS)
3743 goto normal_backslash;
3749 if (COMPILE_STACK_FULL)
3751 RETALLOC (compile_stack.stack, compile_stack.size << 1,
3752 compile_stack_elt_t);
3755 compile_stack.size <<= 1;
3762 COMPILE_STACK_TOP.begalt_offset = begalt - COMPILED_BUFFER_VAR;
3763 COMPILE_STACK_TOP.fixup_alt_jump
3764 = fixup_alt_jump ? fixup_alt_jump - COMPILED_BUFFER_VAR + 1 : 0;
3765 COMPILE_STACK_TOP.laststart_offset = b - COMPILED_BUFFER_VAR;
3766 COMPILE_STACK_TOP.regnum =
regnum;
3772 if (regnum <= MAX_REGNUM)
3774 COMPILE_STACK_TOP.inner_group_offset = b
3775 - COMPILED_BUFFER_VAR + 2;
3779 compile_stack.avail++;
3792 if (syntax & RE_NO_BK_PARENS)
goto normal_backslash;
3794 if (COMPILE_STACK_EMPTY)
3797 goto normal_backslash;
3816 if (COMPILE_STACK_EMPTY)
3826 assert (compile_stack.avail != 0);
3831 regnum_t this_group_regnum;
3833 compile_stack.avail--;
3834 begalt = COMPILED_BUFFER_VAR + COMPILE_STACK_TOP.begalt_offset;
3836 = COMPILE_STACK_TOP.fixup_alt_jump
3837 ? COMPILED_BUFFER_VAR + COMPILE_STACK_TOP.fixup_alt_jump - 1
3839 laststart = COMPILED_BUFFER_VAR + COMPILE_STACK_TOP.laststart_offset;
3840 this_group_regnum = COMPILE_STACK_TOP.regnum;
3848 if (this_group_regnum <= MAX_REGNUM)
3850 UCHAR_T *inner_group_loc
3851 = COMPILED_BUFFER_VAR + COMPILE_STACK_TOP.inner_group_offset;
3853 *inner_group_loc = regnum - this_group_regnum;
3855 regnum - this_group_regnum);
3862 if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR)
3863 goto normal_backslash;
3865 if (syntax & RE_LIMITED_OPS)
3870 GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
3872 b + 2 + 2 * OFFSET_ADDRESS_SIZE);
3874 b += 1 + OFFSET_ADDRESS_SIZE;
3899 GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
3900 b += 1 + OFFSET_ADDRESS_SIZE;
3912 || (syntax & RE_NO_BK_BRACES))
3913 goto normal_backslash;
3920 int lower_bound = -1, upper_bound = -1;
3924 const CHAR_T *beg_interval = p;
3927 goto invalid_interval;
3929 GET_UNSIGNED_NUMBER (lower_bound);
3933 GET_UNSIGNED_NUMBER (upper_bound);
3934 if (upper_bound < 0)
3939 upper_bound = lower_bound;
3941 if (! (0 <= lower_bound && lower_bound <= upper_bound))
3942 goto invalid_interval;
3944 if (!(syntax & RE_NO_BK_BRACES))
3946 if (c !=
'\\' || p == pend)
3947 goto invalid_interval;
3952 goto invalid_interval;
3957 if (syntax & RE_CONTEXT_INVALID_OPS
3963 goto unfetch_interval;
3976 if (upper_bound == 0)
3978 GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
3979 INSERT_JUMP (
jump, laststart, b + 1
3980 + OFFSET_ADDRESS_SIZE);
3981 b += 1 + OFFSET_ADDRESS_SIZE;
3996 unsigned nbytes = 2 + 4 * OFFSET_ADDRESS_SIZE +
3997 (upper_bound > 1) * (2 + 4 * OFFSET_ADDRESS_SIZE);
3999 GET_BUFFER_SPACE (nbytes);
4007 b + 1 + 2 * OFFSET_ADDRESS_SIZE
4008 + (upper_bound > 1) * (1 + 2 * OFFSET_ADDRESS_SIZE)
4010 b += 1 + 2 * OFFSET_ADDRESS_SIZE;
4020 + 2 * OFFSET_ADDRESS_SIZE, lower_bound, b);
4021 b += 1 + 2 * OFFSET_ADDRESS_SIZE;
4023 if (upper_bound > 1)
4031 STORE_JUMP2 (
jump_n, b, laststart
4032 + 2 * OFFSET_ADDRESS_SIZE + 1,
4034 b += 1 + 2 * OFFSET_ADDRESS_SIZE;
4052 upper_bound - 1, b);
4053 b += 1 + 2 * OFFSET_ADDRESS_SIZE;
4060 if (!(syntax & RE_INVALID_INTERVAL_ORD))
4066 if (syntax & RE_NO_BK_BRACES)
4069 goto normal_backslash;
4082 BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]);
4088 BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]);
4102 if (syntax & RE_NO_GNU_OPS)
4110 if (syntax & RE_NO_GNU_OPS)
4116 if (syntax & RE_NO_GNU_OPS)
4122 if (syntax & RE_NO_GNU_OPS)
4128 if (syntax & RE_NO_GNU_OPS)
4134 if (syntax & RE_NO_GNU_OPS)
4140 if (syntax & RE_NO_GNU_OPS)
4145 case '1':
case '2':
case '3':
case '4':
case '5':
4146 case '6':
case '7':
case '8':
case '9':
4156 if (group_in_compile_stack (compile_stack, (regnum_t) c1))
4166 if (syntax & RE_BK_PLUS_QM)
4169 goto normal_backslash;
4190 || is_exactn_bin != is_binary[p - 1 - pattern]
4194 || pending_exact + *pending_exact + 1 != b
4197 || *pending_exact == (1 << BYTEWIDTH) - 1
4200 || *p ==
'*' || *p ==
'^'
4201 || ((syntax & RE_BK_PLUS_QM)
4202 ? *p ==
'\\' && (p[1] ==
'+' || p[1] ==
'?')
4203 : (*p ==
'+' || *p ==
'?'))
4204 || ((syntax & RE_INTERVALS)
4205 && ((syntax & RE_NO_BK_BRACES)
4207 : (p[0] ==
'\\' && p[1] ==
'{'))))
4215 is_exactn_bin = is_binary[p - 1 -
pattern];
4217 BUF_PUSH_2 (exactn_bin, 0);
4223 pending_exact = b - 1;
4238 if (!COMPILE_STACK_EMPTY)
4251 free (compile_stack.stack);
4255 bufp->
used = (uintptr_t) b - (uintptr_t) COMPILED_BUFFER_VAR;
4263 DEBUG_PRINT1 (
"\nCompiled pattern: \n");
4264 PREFIX(print_compiled_pattern) (
bufp);
4268 #ifndef MATCH_MAY_ALLOCATE
4278 if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS))
4280 fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS);
4283 if (! fail_stack.stack)
4285 = (PREFIX(fail_stack_elt_t) *) xmalloc (fail_stack.size
4286 * sizeof (PREFIX(fail_stack_elt_t)));
4289 = (PREFIX(fail_stack_elt_t) *) xrealloc (fail_stack.stack,
4291 * sizeof (PREFIX(fail_stack_elt_t))));
4293 if (! fail_stack.stack)
4295 = (PREFIX(fail_stack_elt_t) *)
malloc (fail_stack.size
4296 * sizeof (PREFIX(fail_stack_elt_t)));
4299 = (PREFIX(fail_stack_elt_t) *)
realloc (fail_stack.stack,
4301 * sizeof (PREFIX(fail_stack_elt_t))));
4305 PREFIX(regex_grow_registers) (
num_regs);
4318 PREFIX(store_op1) (op, loc, arg)
4323 *loc = (UCHAR_T) op;
4324 STORE_NUMBER (loc + 1, arg);
4332 PREFIX(store_op2) (op, loc, arg1, arg2)
4337 *loc = (UCHAR_T) op;
4338 STORE_NUMBER (loc + 1, arg1);
4339 STORE_NUMBER (loc + 1 + OFFSET_ADDRESS_SIZE, arg2);
4348 PREFIX(insert_op1) (op, loc, arg, end)
4354 register UCHAR_T *pfrom = end;
4355 register UCHAR_T *pto = end + 1 + OFFSET_ADDRESS_SIZE;
4357 while (pfrom != loc)
4360 PREFIX(store_op1) (op, loc, arg);
4368 PREFIX(insert_op2) (op, loc, arg1, arg2, end)
4374 register UCHAR_T *pfrom = end;
4375 register UCHAR_T *pto = end + 1 + 2 * OFFSET_ADDRESS_SIZE;
4377 while (pfrom != loc)
4380 PREFIX(store_op2) (op, loc, arg1, arg2);
4390 const CHAR_T *pattern, *p;
4393 const CHAR_T *prev = p - 2;
4394 boolean prev_prev_backslash = prev > pattern && prev[-1] ==
'\\';
4398 (*prev ==
'(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
4400 || (*prev ==
'|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash));
4408 PREFIX(at_endline_loc_p) (p, pend,
syntax)
4409 const CHAR_T *p, *pend;
4412 const CHAR_T *next = p;
4413 boolean next_backslash = *next ==
'\\';
4414 const CHAR_T *next_next = p + 1 < pend ? p + 1 : 0;
4418 (syntax & RE_NO_BK_PARENS ? *next ==
')'
4419 : next_backslash && next_next && *next_next ==
')')
4421 || (syntax & RE_NO_BK_VBAR ? *next ==
'|'
4422 : next_backslash && next_next && *next_next ==
'|');
4431 group_in_compile_stack (compile_stack, regnum)
4432 compile_stack_type compile_stack;
4437 for (this_element = compile_stack.avail - 1;
4440 if (compile_stack.stack[this_element].regnum == regnum)
4447 #ifdef INSIDE_RECURSION
4453 insert_space (num, loc, end)
4458 register CHAR_T *pto = end;
4459 register CHAR_T *pfrom = end - num;
4461 while (pfrom >= loc)
4468 wcs_compile_range (range_start_char, p_ptr, pend, translate, syntax, b,
4470 CHAR_T range_start_char;
4471 const CHAR_T **p_ptr, *pend;
4472 CHAR_T *char_set, *b;
4476 const CHAR_T *p = *p_ptr;
4477 CHAR_T range_start, range_end;
4481 uint32_t start_val, end_val;
4487 nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
4490 const char *collseq = (
const char *) _NL_CURRENT(LC_COLLATE,
4491 _NL_COLLATE_COLLSEQWC);
4492 const unsigned char *extra = (
const unsigned char *)
4493 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
4495 if (range_start_char < -1)
4500 wextra = (int32_t*)(extra + char_set[-range_start_char]);
4501 start_val = wextra[1 + *wextra];
4504 start_val = collseq_table_lookup(collseq, TRANSLATE(range_start_char));
4506 end_val = collseq_table_lookup (collseq, TRANSLATE (p[0]));
4514 insert_space(2, b - char_set[5] - 2, b - 1);
4515 *(b - char_set[5] - 2) = (
wchar_t)start_val;
4516 *(b - char_set[5] - 1) = (
wchar_t)end_val;
4522 range_start = (range_start_char >= 0)? TRANSLATE (range_start_char):
4524 range_end = TRANSLATE (p[0]);
4531 insert_space(2, b - char_set[5] - 2, b - 1);
4532 *(b - char_set[5] - 2) = range_start;
4533 *(b - char_set[5] - 1) = range_end;
4555 byte_compile_range (range_start_char, p_ptr, pend, translate, syntax, b)
4556 unsigned
int range_start_char;
4557 const char **p_ptr, *pend;
4563 const char *p = *p_ptr;
4566 const unsigned char *collseq;
4567 unsigned int start_colseq;
4568 unsigned int end_colseq;
4584 collseq = (
const unsigned char *) _NL_CURRENT (LC_COLLATE,
4585 _NL_COLLATE_COLLSEQMB);
4587 start_colseq = collseq[(
unsigned char) TRANSLATE (range_start_char)];
4588 end_colseq = collseq[(
unsigned char) TRANSLATE (p[0])];
4589 for (this_char = 0; this_char <= (
unsigned char) -1; ++this_char)
4591 unsigned int this_colseq = collseq[(
unsigned char) TRANSLATE (this_char)];
4593 if (start_colseq <= this_colseq && this_colseq <= end_colseq)
4595 SET_LIST_BIT (TRANSLATE (this_char));
4603 range_start_char = TRANSLATE (range_start_char);
4609 end_char = ((unsigned)TRANSLATE(p[0]) & ((1 <<
BYTEWIDTH) - 1));
4611 for (this_char = range_start_char; this_char <= end_char; ++this_char)
4613 SET_LIST_BIT (TRANSLATE (this_char));
4639 static unsigned char truncate_wchar (CHAR_T c);
4641 static unsigned char
4645 unsigned char buf[MB_CUR_MAX];
4648 memset (&state,
'\0',
sizeof (state));
4650 retval = __wcrtomb (buf, c, &state);
4652 retval = wcrtomb (buf, c, &state);
4654 return retval > 0 ? buf[0] : (
unsigned char) c;
4659 PREFIX(re_compile_fastmap) (
bufp)
4663 #ifdef MATCH_MAY_ALLOCATE
4664 PREFIX(fail_stack_type) fail_stack;
4666 #ifndef REGEX_MALLOC
4679 register UCHAR_T *pend = pattern +
bufp->
used;
4686 fail_stack_elt_t *failure_stack_ptr;
4693 boolean path_can_be_null =
true;
4696 boolean succeed_n_p =
false;
4698 assert (fastmap !=
NULL && p !=
NULL);
4701 bzero (fastmap, 1 << BYTEWIDTH);
4707 if (p == pend || *p ==
succeed)
4710 if (!FAIL_STACK_EMPTY ())
4715 path_can_be_null =
true;
4717 p = fail_stack.stack[--fail_stack.avail].pointer;
4746 fastmap[truncate_wchar(p[1])] = 1;
4770 for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
4771 if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
4778 for (j = *p * BYTEWIDTH; j < (1 <<
BYTEWIDTH); j++)
4781 for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
4782 if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
4803 int fastmap_newline = fastmap[
'\n'];
4811 fastmap[
'\n'] = fastmap_newline;
4826 if (
SYNTAX (j) == (
enum syntaxcode) k)
4834 if (
SYNTAX (j) != (
enum syntaxcode) k)
4869 EXTRACT_NUMBER_AND_INCR (j, p);
4884 EXTRACT_NUMBER_AND_INCR (j, p);
4888 if (!FAIL_STACK_EMPTY ()
4889 && fail_stack.stack[fail_stack.avail - 1].pointer == p)
4897 handle_on_failure_jump:
4898 EXTRACT_NUMBER_AND_INCR (j, p);
4909 if (!PUSH_PATTERN_OP (p + j, fail_stack))
4911 RESET_FAIL_STACK ();
4920 EXTRACT_NUMBER_AND_INCR (k, p);
4921 succeed_n_p =
false;
4929 p += OFFSET_ADDRESS_SIZE;
4932 EXTRACT_NUMBER_AND_INCR (k, p);
4935 p -= 2 * OFFSET_ADDRESS_SIZE;
4937 goto handle_on_failure_jump;
4943 p += 2 * OFFSET_ADDRESS_SIZE;
4963 path_can_be_null =
false;
4972 RESET_FAIL_STACK ();
4979 re_compile_fastmap (
bufp)
4983 if (MB_CUR_MAX != 1)
4984 return wcs_re_compile_fastmap(bufp);
4987 return byte_re_compile_fastmap(bufp);
4990 weak_alias (__re_compile_fastmap, re_compile_fastmap)
5030 weak_alias (__re_set_registers, re_set_registers)
5046 return re_search_2 (bufp,
NULL, 0,
string, size, startpos, range,
5050 weak_alias (__re_search, re_search)
5086 if (MB_CUR_MAX != 1)
5087 return wcs_re_search_2 (bufp, string1, size1, string2, size2, startpos,
5091 return byte_re_search_2 (bufp, string1, size1, string2, size2, startpos,
5095 weak_alias (__re_search_2, re_search_2)
5100 #ifdef INSIDE_RECURSION
5102 #ifdef MATCH_MAY_ALLOCATE
5103 # define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL
5105 # define FREE_VAR(var) if (var) free (var); var = NULL
5109 # define MAX_ALLOCA_SIZE 2000
5111 # define FREE_WCS_BUFFERS() \
5113 if (size1 > MAX_ALLOCA_SIZE) \
5115 free (wcs_string1); \
5116 free (mbs_offset1); \
5120 FREE_VAR (wcs_string1); \
5121 FREE_VAR (mbs_offset1); \
5123 if (size2 > MAX_ALLOCA_SIZE) \
5125 free (wcs_string2); \
5126 free (mbs_offset2); \
5130 FREE_VAR (wcs_string2); \
5131 FREE_VAR (mbs_offset2); \
5150 register char *fastmap = bufp->fastmap;
5152 int total_size = size1 +
size2;
5156 wchar_t *wcs_string1 =
NULL, *wcs_string2 =
NULL;
5158 int wcs_size1 = 0, wcs_size2 = 0;
5160 int *mbs_offset1 =
NULL, *mbs_offset2 =
NULL;
5162 char *is_binary =
NULL;
5166 if (startpos < 0 || startpos > total_size)
5174 else if (endpos > total_size)
5179 if (bufp->used > 0 && range > 0
5183 && !bufp->newline_anchor)))
5194 if (bufp->used > 0 && (
re_opcode_t) bufp->buffer[0] == at_dot && range > 0)
5203 if (fastmap && !bufp->fastmap_accurate)
5204 if (re_compile_fastmap (bufp) == -2)
5212 if (size1 > MAX_ALLOCA_SIZE)
5214 wcs_string1 =
TALLOC (size1 + 1, CHAR_T);
5215 mbs_offset1 =
TALLOC (size1 + 1,
int);
5216 is_binary =
TALLOC (size1 + 1,
char);
5224 if (!wcs_string1 || !mbs_offset1 || !is_binary)
5226 if (size1 > MAX_ALLOCA_SIZE)
5234 FREE_VAR (wcs_string1);
5235 FREE_VAR (mbs_offset1);
5236 FREE_VAR (is_binary);
5240 wcs_size1 = convert_mbs_to_wcs(wcs_string1, string1, size1,
5241 mbs_offset1, is_binary);
5242 wcs_string1[wcs_size1] = L
'\0';
5243 if (size1 > MAX_ALLOCA_SIZE)
5246 FREE_VAR (is_binary);
5250 if (size2 > MAX_ALLOCA_SIZE)
5252 wcs_string2 =
TALLOC (size2 + 1, CHAR_T);
5253 mbs_offset2 =
TALLOC (size2 + 1,
int);
5254 is_binary =
TALLOC (size2 + 1,
char);
5262 if (!wcs_string2 || !mbs_offset2 || !is_binary)
5264 FREE_WCS_BUFFERS ();
5265 if (size2 > MAX_ALLOCA_SIZE)
5268 FREE_VAR (is_binary);
5271 wcs_size2 = convert_mbs_to_wcs(wcs_string2, string2, size2,
5272 mbs_offset2, is_binary);
5273 wcs_string2[wcs_size2] = L
'\0';
5274 if (size2 > MAX_ALLOCA_SIZE)
5277 FREE_VAR (is_binary);
5289 if (fastmap && startpos < total_size && !bufp->can_be_null)
5293 register const char *d;
5294 register int lim = 0;
5297 if (startpos < size1 && startpos + range >= size1)
5300 d = (startpos >= size1 ? string2 - size1 :
string1) + startpos;
5306 && !fastmap[(
unsigned char)
5307 translate[(
unsigned char) *d++]])
5310 while (range > lim && !fastmap[(
unsigned char) *d++])
5313 startpos += irange -
range;
5317 register CHAR_T c = (size1 == 0 || startpos >= size1
5318 ? string2[startpos -
size1]
5321 if (!fastmap[(
unsigned char) TRANSLATE (c)])
5327 if (range >= 0 && startpos == total_size && fastmap
5328 && !bufp->can_be_null)
5331 FREE_WCS_BUFFERS ();
5337 val = wcs_re_match_2_internal (bufp, string1, size1, string2,
5339 wcs_string1, wcs_size1,
5340 wcs_string2, wcs_size2,
5341 mbs_offset1, mbs_offset2);
5343 val = byte_re_match_2_internal (bufp, string1, size1, string2,
5347 #ifndef REGEX_MALLOC
5356 FREE_WCS_BUFFERS ();
5364 FREE_WCS_BUFFERS ();
5384 FREE_WCS_BUFFERS ();
5394 # define POINTER_TO_OFFSET(ptr) \
5395 (FIRST_STRING_P (ptr) \
5396 ? ((regoff_t)(mbs_offset1 != NULL? mbs_offset1[(ptr)-string1] : 0)) \
5397 : ((regoff_t)((mbs_offset2 != NULL? mbs_offset2[(ptr)-string2] : 0) \
5402 # define POINTER_TO_OFFSET(ptr) \
5403 (FIRST_STRING_P (ptr) \
5404 ? ((regoff_t) ((ptr) - string1)) \
5405 : ((regoff_t) ((ptr) - string2 + size1)))
5410 #define MATCHING_IN_FIRST_STRING (dend == end_match_1)
5414 #define PREFETCH() \
5418 if (dend == end_match_2) \
5422 dend = end_match_2; \
5427 #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2)
5428 #define AT_STRINGS_END(d) ((d) == end2)
5437 # define WORDCHAR_P(d) \
5438 (iswalnum ((wint_t)((d) == end1 ? *string2 \
5439 : (d) == string2 - 1 ? *(end1 - 1) : *(d))) != 0 \
5440 || ((d) == end1 ? *string2 \
5441 : (d) == string2 - 1 ? *(end1 - 1) : *(d)) == L'_')
5443 # define WORDCHAR_P(d) \
5444 (SYNTAX ((d) == end1 ? *string2 \
5445 : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \
5453 #define AT_WORD_BOUNDARY(d) \
5454 (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \
5455 || WORDCHAR_P (d - 1) != WORDCHAR_P (d))
5459 #ifdef MATCH_MAY_ALLOCATE
5461 # define FREE_VARIABLES() \
5463 REGEX_FREE_STACK (fail_stack.stack); \
5464 FREE_VAR (regstart); \
5465 FREE_VAR (regend); \
5466 FREE_VAR (old_regstart); \
5467 FREE_VAR (old_regend); \
5468 FREE_VAR (best_regstart); \
5469 FREE_VAR (best_regend); \
5470 FREE_VAR (reg_info); \
5471 FREE_VAR (reg_dummy); \
5472 FREE_VAR (reg_info_dummy); \
5473 if (!cant_free_wcs_buf) \
5475 FREE_VAR (string1); \
5476 FREE_VAR (string2); \
5477 FREE_VAR (mbs_offset1); \
5478 FREE_VAR (mbs_offset2); \
5482 # define FREE_VARIABLES() \
5484 REGEX_FREE_STACK (fail_stack.stack); \
5485 FREE_VAR (regstart); \
5486 FREE_VAR (regend); \
5487 FREE_VAR (old_regstart); \
5488 FREE_VAR (old_regend); \
5489 FREE_VAR (best_regstart); \
5490 FREE_VAR (best_regend); \
5491 FREE_VAR (reg_info); \
5492 FREE_VAR (reg_dummy); \
5493 FREE_VAR (reg_info_dummy); \
5498 # define FREE_VARIABLES() \
5500 if (!cant_free_wcs_buf) \
5502 FREE_VAR (string1); \
5503 FREE_VAR (string2); \
5504 FREE_VAR (mbs_offset1); \
5505 FREE_VAR (mbs_offset2); \
5509 # define FREE_VARIABLES() ((void)0)
5520 #define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH)
5521 #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1)
5531 re_match (bufp,
string, size,
pos,
regs)
5539 if (MB_CUR_MAX != 1)
5540 result = wcs_re_match_2_internal (bufp,
NULL, 0,
string, size,
5545 result = byte_re_match_2_internal (bufp,
NULL, 0,
string, size,
5547 # ifndef REGEX_MALLOC
5555 weak_alias (__re_match, re_match)
5561 #ifdef INSIDE_RECURSION
5562 static boolean PREFIX(group_match_null_string_p)
_RE_ARGS ((UCHAR_T **p,
5564 PREFIX(register_info_type) *reg_info));
5565 static
boolean PREFIX(alt_match_null_string_p)
_RE_ARGS ((UCHAR_T *p,
5567 PREFIX(register_info_type) *reg_info));
5568 static
boolean PREFIX(common_op_match_null_string_p)
_RE_ARGS ((UCHAR_T **p,
5570 PREFIX(register_info_type) *reg_info));
5572 int len,
char *translate));
5589 re_match_2 (bufp, string1, size1, string2, size2,
pos,
regs,
stop)
5591 const char *string1, *string2;
5599 if (MB_CUR_MAX != 1)
5600 result = wcs_re_match_2_internal (bufp, string1, size1, string2, size2,
5605 result = byte_re_match_2_internal (bufp, string1, size1, string2, size2,
5608 #ifndef REGEX_MALLOC
5616 weak_alias (__re_match_2, re_match_2)
5621 #ifdef INSIDE_RECURSION
5624 static int count_mbs_length
PARAMS ((
int *,
int));
5632 count_mbs_length(offset_buffer, length)
5642 if (offset_buffer ==
NULL)
5647 if (offset_buffer[length] == length)
5656 int middle = (lower + upper) / 2;
5657 if (middle == lower || middle == upper)
5659 if (offset_buffer[middle] > length)
5661 else if (offset_buffer[middle] < length)
5675 wcs_re_match_2_internal (bufp, cstring1, csize1, cstring2, csize2, pos,
5676 regs, stop, string1, size1, string2, size2,
5677 mbs_offset1, mbs_offset2)
5679 const char *cstring1, *cstring2;
5687 wchar_t *string1, *string2;
5691 int *mbs_offset1, *mbs_offset2;
5694 byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
5697 const char *string1, *string2;
5709 char *is_binary =
NULL;
5711 int cant_free_wcs_buf = 1;
5715 const CHAR_T *end1, *end2;
5719 const CHAR_T *end_match_1, *end_match_2;
5722 const CHAR_T *d, *dend;
5727 register UCHAR_T *pend;
5729 UCHAR_T *p = bufp->buffer;
5730 register UCHAR_T *pend = p + bufp->used;
5735 UCHAR_T *just_past_start_mem = 0;
5749 #ifdef MATCH_MAY_ALLOCATE
5750 PREFIX(fail_stack_type) fail_stack;
5753 static unsigned failure_id;
5754 unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0;
5760 fail_stack_elt_t *failure_stack_ptr;
5766 size_t num_regs = bufp->re_nsub + 1;
5770 active_reg_t highest_active_reg = NO_HIGHEST_ACTIVE_REG;
5779 #ifdef MATCH_MAY_ALLOCATE
5780 const CHAR_T **regstart, **regend;
5788 #ifdef MATCH_MAY_ALLOCATE
5789 const CHAR_T **old_regstart, **old_regend;
5798 #ifdef MATCH_MAY_ALLOCATE
5799 PREFIX(register_info_type) *reg_info;
5806 unsigned best_regs_set =
false;
5807 #ifdef MATCH_MAY_ALLOCATE
5808 const CHAR_T **best_regstart, **best_regend;
5819 const CHAR_T *match_end =
NULL;
5822 int set_regs_matched_done = 0;
5825 #ifdef MATCH_MAY_ALLOCATE
5826 const CHAR_T **reg_dummy;
5827 PREFIX(register_info_type) *reg_info_dummy;
5832 unsigned num_regs_pushed = 0;
5835 DEBUG_PRINT1 (
"\n\nEntering re_match_2.\n");
5839 #ifdef MATCH_MAY_ALLOCATE
5849 old_regstart =
REGEX_TALLOC (num_regs,
const CHAR_T *);
5851 best_regstart =
REGEX_TALLOC (num_regs,
const CHAR_T *);
5853 reg_info =
REGEX_TALLOC (num_regs, PREFIX(register_info_type));
5855 reg_info_dummy =
REGEX_TALLOC (num_regs, PREFIX(register_info_type));
5857 if (!(regstart && regend && old_regstart && old_regend && reg_info
5858 && best_regstart && best_regend && reg_dummy && reg_info_dummy))
5868 regstart = regend = old_regstart = old_regend = best_regstart
5869 = best_regend = reg_dummy =
NULL;
5870 reg_info = reg_info_dummy = (PREFIX(register_info_type) *)
NULL;
5876 if (pos < 0 || pos > csize1 + csize2)
5878 if (pos < 0 || pos > size1 + size2)
5888 if (string1 ==
NULL && string2 ==
NULL)
5893 cant_free_wcs_buf = 0;
5900 if (!string1 || !mbs_offset1 || !is_binary)
5903 FREE_VAR (mbs_offset1);
5904 FREE_VAR (is_binary);
5913 if (!string2 || !mbs_offset2 || !is_binary)
5916 FREE_VAR (mbs_offset1);
5918 FREE_VAR (mbs_offset2);
5919 FREE_VAR (is_binary);
5922 size2 = convert_mbs_to_wcs(string2, cstring2, csize2,
5923 mbs_offset2, is_binary);
5924 string2[
size2] = L
'\0';
5925 FREE_VAR (is_binary);
5931 p = pattern = (CHAR_T*)bufp->buffer;
5932 pend = (CHAR_T*)(bufp->buffer + bufp->used);
5939 for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
5941 regstart[mcnt] = regend[mcnt]
5942 = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
5944 REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE;
5945 IS_ACTIVE (reg_info[mcnt]) = 0;
5946 MATCHED_SOMETHING (reg_info[mcnt]) = 0;
5947 EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
5952 if (size2 == 0 && string1 !=
NULL)
5959 mbs_offset2 = mbs_offset1;
5965 end1 = string1 +
size1;
5966 end2 = string2 +
size2;
5972 mcnt = count_mbs_length(mbs_offset1, stop);
5973 end_match_1 = string1 + mcnt;
5978 if (stop > csize1 + csize2)
5979 stop = csize1 + csize2;
5981 mcnt = count_mbs_length(mbs_offset2, stop-csize1);
5982 end_match_2 = string2 + mcnt;
5992 end_match_1 = string1 +
stop;
5998 end_match_2 = string2 + stop -
size1;
6009 if (size1 > 0 && pos <= csize1)
6011 mcnt = count_mbs_length(mbs_offset1, pos);
6017 mcnt = count_mbs_length(mbs_offset2, pos-csize1);
6028 if (size1 > 0 && pos <= size1)
6035 d = string2 + pos -
size1;
6040 DEBUG_PRINT1 (
"The compiled pattern is:\n");
6041 DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend);
6042 DEBUG_PRINT1 (
"The string to match is: `");
6043 DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2);
6044 DEBUG_PRINT1 (
"'\n");
6052 DEBUG_PRINT2 (
"\n%p: ", p);
6054 DEBUG_PRINT2 (
"\n0x%x: ", p);
6059 DEBUG_PRINT1 (
"end of pattern ... ");
6063 if (d != end_match_2)
6068 == MATCHING_IN_FIRST_STRING);
6070 boolean best_match_p;
6075 best_match_p = d > match_end;
6077 best_match_p = !MATCHING_IN_FIRST_STRING;
6079 DEBUG_PRINT1 (
"backtracking.\n");
6081 if (!FAIL_STACK_EMPTY ())
6085 if (!best_regs_set || best_match_p)
6087 best_regs_set =
true;
6090 DEBUG_PRINT1 (
"\nSAVING match as best so far.\n");
6092 for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
6094 best_regstart[mcnt] = regstart[mcnt];
6095 best_regend[mcnt] = regend[mcnt];
6104 else if (best_regs_set && !best_match_p)
6112 DEBUG_PRINT1 (
"Restoring best registers.\n");
6115 dend = ((d >= string1 && d <= end1)
6116 ? end_match_1 : end_match_2);
6118 for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
6120 regstart[mcnt] = best_regstart[mcnt];
6121 regend[mcnt] = best_regend[mcnt];
6127 DEBUG_PRINT1 (
"Accepting match.\n");
6129 if (regs && !bufp->no_sub)
6176 if (MATCHING_IN_FIRST_STRING)
6177 regs->
end[0] = mbs_offset1 !=
NULL ?
6180 regs->
end[0] = csize1 + (mbs_offset2 !=
NULL ?
6183 regs->
end[0] = (MATCHING_IN_FIRST_STRING
6191 for (mcnt = 1; (unsigned) mcnt <
MIN (num_regs, regs->
num_regs);
6194 if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
6195 regs->
start[mcnt] = regs->
end[mcnt] = -1;
6199 = (
regoff_t) POINTER_TO_OFFSET (regstart[mcnt]);
6201 = (
regoff_t) POINTER_TO_OFFSET (regend[mcnt]);
6210 for (mcnt = num_regs; (unsigned) mcnt < regs->num_regs; mcnt++)
6211 regs->
start[mcnt] = regs->
end[mcnt] = -1;
6214 DEBUG_PRINT4 (
"%u failure points pushed, %u popped (%u remain).\n",
6215 nfailure_points_pushed, nfailure_points_popped,
6216 nfailure_points_pushed - nfailure_points_popped);
6217 DEBUG_PRINT2 (
"%u registers pushed.\n", num_regs_pushed);
6220 if (MATCHING_IN_FIRST_STRING)
6221 mcnt = mbs_offset1 !=
NULL ? mbs_offset1[d-
string1] : 0;
6223 mcnt = (mbs_offset2 !=
NULL ? mbs_offset2[d-
string2] : 0) +
6227 mcnt = d - pos - (MATCHING_IN_FIRST_STRING
6232 DEBUG_PRINT2 (
"Returning %d from re_match_2.\n", mcnt);
6244 DEBUG_PRINT1 (
"EXECUTING no_op.\n");
6248 DEBUG_PRINT1 (
"EXECUTING succeed.\n");
6259 DEBUG_PRINT2 (
"EXECUTING exactn %d.\n", mcnt);
6271 if ((UCHAR_T) translate[(
unsigned char) *d++]
6277 if (*d++ != (CHAR_T) *p++)
6281 if ((UCHAR_T) translate[(
unsigned char) *d++]
6293 if (*d++ != (CHAR_T) *p++)
goto fail;
6297 SET_REGS_MATCHED ();
6303 DEBUG_PRINT1 (
"EXECUTING anychar.\n");
6307 if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) ==
'\n')
6311 SET_REGS_MATCHED ();
6312 DEBUG_PRINT2 (
" Matched `%ld'.\n", (
long int) *d);
6322 unsigned int i, char_class_length, coll_symbol_length,
6323 equiv_class_length, ranges_length, chars_length,
length;
6324 CHAR_T *workp, *workp2, *charset_top;
6325 #define WORK_BUFFER_SIZE 128
6326 CHAR_T str_buf[WORK_BUFFER_SIZE];
6333 DEBUG_PRINT2 (
"EXECUTING charset%s.\n", not ?
"_not" :
"");
6338 nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
6340 charset_top = p - 1;
6341 char_class_length = *p++;
6342 coll_symbol_length = *p++;
6343 equiv_class_length = *p++;
6344 ranges_length = *p++;
6345 chars_length = *p++;
6353 p += char_class_length + coll_symbol_length+ equiv_class_length +
6354 2*ranges_length + chars_length;
6357 for (i = 0; i < char_class_length ; i += CHAR_CLASS_SIZE)
6360 uintptr_t alignedp = ((uintptr_t)workp
6361 + __alignof__(wctype_t) - 1)
6362 & ~(uintptr_t)(__alignof__(wctype_t) - 1);
6363 wctype = *((wctype_t*)alignedp);
6364 workp += CHAR_CLASS_SIZE;
6366 if (__iswctype((wint_t)c, wctype))
6367 goto char_set_matched;
6369 if (iswctype((wint_t)c, wctype))
6370 goto char_set_matched;
6378 const unsigned char *extra = (
const unsigned char *)
6379 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
6381 for (workp2 = workp + coll_symbol_length ; workp < workp2 ;
6385 wextra = (int32_t*)(extra + *workp++);
6386 for (i = 0; i < *wextra; ++i)
6387 if (TRANSLATE(d[i]) != wextra[1 + i])
6395 goto char_set_matched;
6404 for (workp2 = workp + coll_symbol_length ; workp < workp2 ;)
6406 const CHAR_T *backup_d = d, *backup_dend = dend;
6408 length = __wcslen (workp);
6410 length = wcslen (workp);
6417 if (__wcscoll (workp, d) > 0)
6419 if (wcscoll (workp, d) > 0)
6422 workp += length + 1;
6430 for (i = 0 ; i < WORK_BUFFER_SIZE-1 ; i++, d++)
6435 if (dend == end_match_2)
6442 str_buf[i] = TRANSLATE(*d);
6443 str_buf[i+1] =
'\0';
6446 match = __wcscoll (workp, str_buf);
6448 match = wcscoll (workp, str_buf);
6451 goto char_set_matched;
6466 workp += length + 1;
6473 const CHAR_T *backup_d = d, *backup_dend = dend;
6476 const int32_t *table;
6477 const int32_t *weights;
6478 const int32_t *extra;
6479 const int32_t *indirect;
6485 # include <locale/weightwc.h>
6487 table = (
const int32_t *)
6488 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC);
6489 weights = (
const wint_t *)
6490 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC);
6491 extra = (
const wint_t *)
6492 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC);
6493 indirect = (
const int32_t *)
6494 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC);
6500 for (i = 0 ; idx2 == 0 && i < WORK_BUFFER_SIZE - 1; i++)
6502 cp = (wint_t*)str_buf;
6505 if (dend == end_match_2)
6510 str_buf[i] = TRANSLATE(*(d+i));
6511 str_buf[i+1] =
'\0';
6512 idx2 = findidx ((
const wint_t**)&cp);
6517 d = backup_d + ((
wchar_t*)cp - (
wchar_t*)str_buf - 1);
6520 if (dend == end_match_2)
6529 len = weights[idx2];
6531 for (workp2 = workp + equiv_class_length ; workp < workp2 ;
6534 idx = (int32_t)*workp;
6537 if (idx2 != 0 && len == weights[idx])
6540 while (cnt < len && (weights[idx + 1 + cnt]
6541 == weights[idx2 + 1 + cnt]))
6545 goto char_set_matched;
6557 for (workp2 = workp + equiv_class_length ; workp < workp2 ;)
6559 const CHAR_T *backup_d = d, *backup_dend = dend;
6561 length = __wcslen (workp);
6563 length = wcslen (workp);
6570 if (__wcscoll (workp, d) > 0)
6572 if (wcscoll (workp, d) > 0)
6575 workp += length + 1;
6583 for (i = 0 ; i < WORK_BUFFER_SIZE - 1 ; i++, d++)
6588 if (dend == end_match_2)
6595 str_buf[i] = TRANSLATE(*d);
6596 str_buf[i+1] =
'\0';
6599 match = __wcscoll (workp, str_buf);
6601 match = wcscoll (workp, str_buf);
6605 goto char_set_matched;
6620 workp += length + 1;
6628 uint32_t collseqval;
6629 const char *collseq = (
const char *)
6630 _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC);
6632 collseqval = collseq_table_lookup (collseq, c);
6634 for (; workp < p - chars_length ;)
6636 uint32_t start_val, end_val;
6640 start_val = (uint32_t) *workp++;
6641 end_val = (uint32_t) *workp++;
6643 if (start_val <= collseqval && collseqval <= end_val)
6644 goto char_set_matched;
6656 for (; workp < p - chars_length ;)
6658 wchar_t *range_start_char, *range_end_char;
6668 range_start_char = charset_top - (*workp++);
6671 str_buf[0] = *workp++;
6672 range_start_char = str_buf;
6677 range_end_char = charset_top - (*workp++);
6680 str_buf[4] = *workp++;
6681 range_end_char = str_buf + 4;
6685 if (__wcscoll (range_start_char, str_buf+2) <= 0
6686 && __wcscoll (str_buf+2, range_end_char) <= 0)
6688 if (wcscoll (range_start_char, str_buf+2) <= 0
6689 && wcscoll (str_buf+2, range_end_char) <= 0)
6691 goto char_set_matched;
6696 for (; workp < p ; workp++)
6698 goto char_set_matched;
6708 && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
6713 if (!not)
goto fail;
6714 #undef WORK_BUFFER_SIZE
6716 SET_REGS_MATCHED ();
6728 DEBUG_PRINT3 (
"EXECUTING start_memory %ld (%ld):\n",
6729 (
long int) *p, (
long int) p[1]);
6734 if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
6735 REG_MATCH_NULL_STRING_P (reg_info[*p])
6736 = PREFIX(group_match_null_string_p) (&p1, pend, reg_info);
6743 old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
6744 ? REG_UNSET (regstart[*p]) ? d : regstart[*p]
6746 DEBUG_PRINT2 (
" old_regstart: %d\n",
6747 POINTER_TO_OFFSET (old_regstart[*p]));
6750 DEBUG_PRINT2 (
" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p]));
6752 IS_ACTIVE (reg_info[*p]) = 1;
6753 MATCHED_SOMETHING (reg_info[*p]) = 0;
6756 set_regs_matched_done = 0;
6759 highest_active_reg = *p;
6763 if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
6764 lowest_active_reg = *p;
6768 just_past_start_mem = p;
6777 DEBUG_PRINT3 (
"EXECUTING stop_memory %ld (%ld):\n",
6778 (
long int) *p, (
long int) p[1]);
6785 old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
6786 ? REG_UNSET (regend[*p]) ? d : regend[*p]
6788 DEBUG_PRINT2 (
" old_regend: %d\n",
6789 POINTER_TO_OFFSET (old_regend[*p]));
6792 DEBUG_PRINT2 (
" regend: %d\n", POINTER_TO_OFFSET (regend[*p]));
6795 IS_ACTIVE (reg_info[*p]) = 0;
6798 set_regs_matched_done = 0;
6802 if (lowest_active_reg == highest_active_reg)
6804 lowest_active_reg = NO_LOWEST_ACTIVE_REG;
6805 highest_active_reg = NO_HIGHEST_ACTIVE_REG;
6813 while (r > 0 && !IS_ACTIVE (reg_info[r]))
6825 lowest_active_reg = NO_LOWEST_ACTIVE_REG;
6826 highest_active_reg = NO_HIGHEST_ACTIVE_REG;
6829 highest_active_reg = r;
6837 if ((!MATCHED_SOMETHING (reg_info[*p])
6838 || just_past_start_mem == p - 1)
6841 boolean is_a_jump_n =
false;
6853 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
6855 p1 += OFFSET_ADDRESS_SIZE;
6870 && p1[2+OFFSET_ADDRESS_SIZE] == *p)
6882 if (EVER_MATCHED_SOMETHING (reg_info[*p]))
6886 EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
6889 for (r = *p; r < (unsigned) *p + (
unsigned) *(p + 1);
6892 regstart[r] = old_regstart[r];
6895 if (old_regend[r] >= regstart[r])
6896 regend[r] = old_regend[r];
6900 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
6901 PUSH_FAILURE_POINT (p1 + mcnt, d, -2);
6916 register const CHAR_T *d2, *dend2;
6918 DEBUG_PRINT2 (
"EXECUTING duplicate %d.\n", regno);
6921 if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno]))
6925 d2 = regstart[regno];
6934 ? regend[regno] : end_match_1);
6941 if (dend2 == end_match_2)
break;
6942 if (dend2 == regend[regno])
break;
6946 dend2 = regend[regno];
6949 if (d2 == dend2)
break;
6959 if (mcnt > dend2 - d2)
6965 ? PREFIX(bcmp_translate) (d, d2, mcnt, translate)
6966 : memcmp (d, d2, mcnt*
sizeof(UCHAR_T)))
6968 d += mcnt, d2 += mcnt;
6971 SET_REGS_MATCHED ();
6981 DEBUG_PRINT1 (
"EXECUTING begline.\n");
6983 if (AT_STRINGS_BEG (d))
6985 if (!bufp->not_bol)
break;
6987 else if (d[-1] ==
'\n' && bufp->newline_anchor)
6997 DEBUG_PRINT1 (
"EXECUTING endline.\n");
6999 if (AT_STRINGS_END (d))
7001 if (!bufp->not_eol)
break;
7005 else if ((d == end1 ? *string2 : *d) ==
'\n'
7006 && bufp->newline_anchor)
7015 DEBUG_PRINT1 (
"EXECUTING begbuf.\n");
7016 if (AT_STRINGS_BEG (d))
7023 DEBUG_PRINT1 (
"EXECUTING endbuf.\n");
7024 if (AT_STRINGS_END (d))
7046 DEBUG_PRINT1 (
"EXECUTING on_failure_keep_string_jump");
7048 EXTRACT_NUMBER_AND_INCR (mcnt, p);
7050 DEBUG_PRINT3 (
" %d (to %p):\n", mcnt, p + mcnt);
7052 DEBUG_PRINT3 (
" %d (to 0x%x):\n", mcnt, p + mcnt);
7055 PUSH_FAILURE_POINT (p + mcnt,
NULL, -2);
7073 DEBUG_PRINT1 (
"EXECUTING on_failure_jump");
7075 EXTRACT_NUMBER_AND_INCR (mcnt, p);
7077 DEBUG_PRINT3 (
" %d (to %p)", mcnt, p + mcnt);
7079 DEBUG_PRINT3 (
" %d (to 0x%x)", mcnt, p + mcnt);
7106 highest_active_reg = *(p1 + 1) + *(p1 + 2);
7107 if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
7108 lowest_active_reg = *(p1 + 1);
7111 DEBUG_PRINT1 (
":\n");
7112 PUSH_FAILURE_POINT (p + mcnt, d, -2);
7119 EXTRACT_NUMBER_AND_INCR (mcnt, p);
7120 DEBUG_PRINT2 (
"EXECUTING maybe_pop_jump %d.\n", mcnt);
7122 register UCHAR_T *p2 = p;
7147 else if (p2 + 2 + 2 * OFFSET_ADDRESS_SIZE < pend
7149 p2 += 2 + 2 * OFFSET_ADDRESS_SIZE;
7165 p[-(1+OFFSET_ADDRESS_SIZE)] = (UCHAR_T)
7168 (" End of pattern: change to `pop_failure_jump'.\n");
7178 = *p2 == (UCHAR_T)
endline ?
'\n' : p2[2];
7182 || (
re_opcode_t) p1[1+OFFSET_ADDRESS_SIZE] == exactn_bin
7184 ) && p1[3+OFFSET_ADDRESS_SIZE] != c)
7186 p[-(1+OFFSET_ADDRESS_SIZE)] = (UCHAR_T)
7189 DEBUG_PRINT3 (
" %C != %C => pop_failure_jump.\n",
7191 (wint_t) p1[3+OFFSET_ADDRESS_SIZE]);
7193 DEBUG_PRINT3 (
" %c != %c => pop_failure_jump.\n",
7195 (
char) p1[3+OFFSET_ADDRESS_SIZE]);
7206 && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
7213 p[-3] = (
unsigned char) pop_failure_jump;
7214 DEBUG_PRINT1 (
" No match => pop_failure_jump.\n");
7225 && ! ((
int) p2[1] * BYTEWIDTH > (
int) p1[5]
7226 && (p2[2 + p1[5] / BYTEWIDTH]
7227 & (1 << (p1[5] % BYTEWIDTH)))))
7229 p[-3] = (
unsigned char) pop_failure_jump;
7230 DEBUG_PRINT1 (
" No match => pop_failure_jump.\n");
7238 for (idx = 0; idx < (int) p2[1]; idx++)
7239 if (! (p2[2 + idx] == 0
7240 || (idx < (
int) p1[4]
7241 && ((p2[2 + idx] & ~ p1[5 + idx]) == 0))))
7246 p[-3] = (
unsigned char) pop_failure_jump;
7247 DEBUG_PRINT1 (
" No match => pop_failure_jump.\n");
7256 idx < (int) p2[1] && idx < (
int) p1[4];
7258 if ((p2[2 + idx] & p1[5 + idx]) != 0)
7261 if (idx == p2[1] || idx == p1[4])
7263 p[-3] = (
unsigned char) pop_failure_jump;
7264 DEBUG_PRINT1 (
" No match => pop_failure_jump.\n");
7270 p -= OFFSET_ADDRESS_SIZE;
7273 p[-1] = (UCHAR_T)
jump;
7274 DEBUG_PRINT1 (
" Match => jump.\n");
7275 goto unconditional_jump;
7286 case pop_failure_jump:
7294 UCHAR_T *pdummy =
NULL;
7295 const CHAR_T *sdummy =
NULL;
7297 DEBUG_PRINT1 (
"EXECUTING pop_failure_jump.\n");
7298 POP_FAILURE_POINT (sdummy, pdummy,
7299 dummy_low_reg, dummy_high_reg,
7300 reg_dummy, reg_dummy, reg_info_dummy);
7306 DEBUG_PRINT2 (
"\n%p: ", p);
7308 DEBUG_PRINT2 (
"\n0x%x: ", p);
7314 EXTRACT_NUMBER_AND_INCR (mcnt, p);
7315 DEBUG_PRINT2 (
"EXECUTING jump %d ", mcnt);
7318 DEBUG_PRINT2 (
"(to %p).\n", p);
7320 DEBUG_PRINT2 (
"(to 0x%x).\n", p);
7328 DEBUG_PRINT1 (
"EXECUTING jump_past_alt.\n");
7329 goto unconditional_jump;
7338 DEBUG_PRINT1 (
"EXECUTING dummy_failure_jump.\n");
7341 PUSH_FAILURE_POINT (
NULL,
NULL, -2);
7342 goto unconditional_jump;
7351 DEBUG_PRINT1 (
"EXECUTING push_dummy_failure.\n");
7354 PUSH_FAILURE_POINT (
NULL,
NULL, -2);
7360 EXTRACT_NUMBER (mcnt, p + OFFSET_ADDRESS_SIZE);
7361 DEBUG_PRINT2 (
"EXECUTING succeed_n %d.\n", mcnt);
7368 p += OFFSET_ADDRESS_SIZE;
7369 STORE_NUMBER_AND_INCR (p, mcnt);
7371 DEBUG_PRINT3 (
" Setting %p to %d.\n", p - OFFSET_ADDRESS_SIZE
7374 DEBUG_PRINT3 (
" Setting 0x%x to %d.\n", p - OFFSET_ADDRESS_SIZE
7381 DEBUG_PRINT2 (
" Setting two bytes from %p to no_op.\n",
7382 p + OFFSET_ADDRESS_SIZE);
7384 DEBUG_PRINT2 (
" Setting two bytes from 0x%x to no_op.\n",
7385 p + OFFSET_ADDRESS_SIZE);
7389 p[1] = (UCHAR_T)
no_op;
7391 p[2] = (UCHAR_T)
no_op;
7392 p[3] = (UCHAR_T)
no_op;
7399 EXTRACT_NUMBER (mcnt, p + OFFSET_ADDRESS_SIZE);
7400 DEBUG_PRINT2 (
"EXECUTING jump_n %d.\n", mcnt);
7406 STORE_NUMBER (p + OFFSET_ADDRESS_SIZE, mcnt);
7409 DEBUG_PRINT3 (
" Setting %p to %d.\n", p + OFFSET_ADDRESS_SIZE,
7412 DEBUG_PRINT3 (
" Setting 0x%x to %d.\n", p + OFFSET_ADDRESS_SIZE,
7415 goto unconditional_jump;
7419 p += 2 * OFFSET_ADDRESS_SIZE;
7424 DEBUG_PRINT1 (
"EXECUTING set_number_at.\n");
7426 EXTRACT_NUMBER_AND_INCR (mcnt, p);
7428 EXTRACT_NUMBER_AND_INCR (mcnt, p);
7430 DEBUG_PRINT3 (
" Setting %p to %d.\n", p1, mcnt);
7432 DEBUG_PRINT3 (
" Setting 0x%x to %d.\n", p1, mcnt);
7434 STORE_NUMBER (p1, mcnt);
7445 DEBUG_PRINT1 (
"EXECUTING wordbound.\n");
7446 if (AT_WORD_BOUNDARY (d))
7451 DEBUG_PRINT1 (
"EXECUTING notwordbound.\n");
7452 if (AT_WORD_BOUNDARY (d))
7458 boolean prevchar, thischar;
7460 DEBUG_PRINT1 (
"EXECUTING wordbound.\n");
7461 if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
7464 prevchar = WORDCHAR_P (d - 1);
7465 thischar = WORDCHAR_P (d);
7466 if (prevchar != thischar)
7473 boolean prevchar, thischar;
7475 DEBUG_PRINT1 (
"EXECUTING notwordbound.\n");
7476 if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
7479 prevchar = WORDCHAR_P (d - 1);
7480 thischar = WORDCHAR_P (d);
7481 if (prevchar != thischar)
7488 DEBUG_PRINT1 (
"EXECUTING wordbeg.\n");
7489 if (!AT_STRINGS_END (d) && WORDCHAR_P (d)
7490 && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1)))
7495 DEBUG_PRINT1 (
"EXECUTING wordend.\n");
7496 if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1)
7497 && (AT_STRINGS_END (d) || !WORDCHAR_P (d)))
7503 DEBUG_PRINT1 (
"EXECUTING before_dot.\n");
7504 if (PTR_CHAR_POS ((
unsigned char *) d) >= point)
7509 DEBUG_PRINT1 (
"EXECUTING at_dot.\n");
7510 if (PTR_CHAR_POS ((
unsigned char *) d) != point)
7515 DEBUG_PRINT1 (
"EXECUTING after_dot.\n");
7516 if (PTR_CHAR_POS ((
unsigned char *) d) <= point)
7521 DEBUG_PRINT2 (
"EXECUTING syntaxspec %d.\n", mcnt);
7526 DEBUG_PRINT1 (
"EXECUTING Emacs wordchar.\n");
7532 if (
SYNTAX (d[-1]) != (
enum syntaxcode) mcnt)
7534 SET_REGS_MATCHED ();
7538 DEBUG_PRINT2 (
"EXECUTING notsyntaxspec %d.\n", mcnt);
7540 goto matchnotsyntax;
7543 DEBUG_PRINT1 (
"EXECUTING Emacs notwordchar.\n");
7549 if (
SYNTAX (d[-1]) == (
enum syntaxcode) mcnt)
7551 SET_REGS_MATCHED ();
7556 DEBUG_PRINT1 (
"EXECUTING non-Emacs wordchar.\n");
7558 if (!WORDCHAR_P (d))
7560 SET_REGS_MATCHED ();
7565 DEBUG_PRINT1 (
"EXECUTING non-Emacs notwordchar.\n");
7569 SET_REGS_MATCHED ();
7582 if (!FAIL_STACK_EMPTY ())
7584 DEBUG_PRINT1 (
"\nFAIL:\n");
7585 POP_FAILURE_POINT (d, p,
7586 lowest_active_reg, highest_active_reg,
7587 regstart, regend, reg_info);
7597 boolean is_a_jump_n =
false;
7606 case pop_failure_jump:
7609 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
7622 if (d >= string1 && d <= end1)
7630 goto restore_best_regs;
7652 PREFIX(group_match_null_string_p) (p,
end, reg_info)
7654 PREFIX(register_info_type) *reg_info;
7658 UCHAR_T *p1 = *p + 2;
7671 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
7696 while ((
re_opcode_t) p1[mcnt-(1+OFFSET_ADDRESS_SIZE)] ==
7703 if (!PREFIX(alt_match_null_string_p) (p1, p1 + mcnt -
7704 (1 + OFFSET_ADDRESS_SIZE),
7720 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
7721 if ((
re_opcode_t) p1[mcnt-(1+OFFSET_ADDRESS_SIZE)] !=
7725 p1 -= 1 + OFFSET_ADDRESS_SIZE;
7733 EXTRACT_NUMBER (mcnt, p1 - OFFSET_ADDRESS_SIZE);
7735 if (!PREFIX(alt_match_null_string_p) (p1, p1 + mcnt, reg_info))
7744 assert (p1[1] == **p);
7750 if (!PREFIX(common_op_match_null_string_p) (&p1, end, reg_info))
7764 PREFIX(alt_match_null_string_p) (p,
end, reg_info)
7766 PREFIX(register_info_type) *reg_info;
7781 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
7786 if (!PREFIX(common_op_match_null_string_p) (&p1, end, reg_info))
7801 PREFIX(common_op_match_null_string_p) (p,
end, reg_info)
7803 PREFIX(register_info_type) *reg_info;
7830 assert (reg_no > 0 && reg_no <= MAX_REGNUM);
7831 ret = PREFIX(group_match_null_string_p) (&p1,
end, reg_info);
7836 if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE)
7837 REG_MATCH_NULL_STRING_P (reg_info[reg_no]) =
ret;
7845 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
7854 p1 += OFFSET_ADDRESS_SIZE;
7855 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
7859 p1 -= 2 * OFFSET_ADDRESS_SIZE;
7860 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
7868 if (!REG_MATCH_NULL_STRING_P (reg_info[*p1]))
7873 p1 += 2 * OFFSET_ADDRESS_SIZE;
7889 PREFIX(bcmp_translate) (s1, s2, len,
translate)
7890 const CHAR_T *s1, *s2;
7894 register const UCHAR_T *p1 = (
const UCHAR_T *) s1;
7895 register const UCHAR_T *p2 = (
const UCHAR_T *) s2;
7899 if (((*p1<=0xff)?translate[*p1++]:*p1++)
7900 != ((*p2<=0xff)?translate[*p2++]:*p2++))
7903 if (translate[*p1++] != translate[*p2++])
return 1;
7926 re_compile_pattern (pattern, length, bufp)
7946 if (MB_CUR_MAX != 1)
7947 ret = wcs_regex_compile (pattern, length, re_syntax_options, bufp);
7950 ret = byte_regex_compile (pattern, length, re_syntax_options, bufp);
7954 return gettext (re_error_msgid + re_error_msgid_idx[(
int) ret]);
7957 weak_alias (__re_compile_pattern, re_compile_pattern)
7964 #if defined _REGEX_RE_COMP || defined _LIBC
7983 if (!re_comp_buf.buffer)
7984 return gettext (
"No previous regular expression");
7988 if (!re_comp_buf.buffer)
7990 re_comp_buf.buffer = (
unsigned char *)
malloc (200);
7991 if (re_comp_buf.buffer ==
NULL)
7992 return (
char *)
gettext (re_error_msgid
7994 re_comp_buf.allocated = 200;
7996 re_comp_buf.fastmap = (
char *)
malloc (1 << BYTEWIDTH);
7997 if (re_comp_buf.fastmap ==
NULL)
7998 return (
char *)
gettext (re_error_msgid
8006 re_comp_buf.newline_anchor = 1;
8009 if (MB_CUR_MAX != 1)
8010 ret = wcs_regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf);
8013 ret = byte_regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf);
8019 return (
char *)
gettext (re_error_msgid + re_error_msgid_idx[(
int) ret]);
8030 const int len = strlen (s);
8032 0 <= re_search (&re_comp_buf, s, len, 0, len, (
struct re_registers *) 0);
8080 const char *pattern;
8116 syntax &= ~RE_DOT_NEWLINE;
8129 if (MB_CUR_MAX != 1)
8130 ret = wcs_regex_compile (pattern, strlen (pattern), syntax, preg);
8133 ret = byte_regex_compile (pattern, strlen (pattern), syntax, preg);
8143 if (re_compile_fastmap (preg) == -2)
8155 weak_alias (__regcomp, regcomp)
8174 regexec (preg,
string, nmatch, pmatch, eflags)
8184 int len = strlen (
string);
8185 boolean want_reg_info = !preg->no_sub && nmatch > 0;
8187 private_preg = *
preg;
8190 private_preg.not_eol = !!(eflags &
REG_NOTEOL);
8207 ret = re_search (&private_preg,
string, len,
8218 for (r = 0; r < nmatch; r++)
8233 weak_alias (__regexec, regexec)
8251 || errcode >= (
int) (
sizeof (re_error_msgid_idx)
8252 /
sizeof (re_error_msgid_idx[0])))
8259 msg =
gettext (re_error_msgid + re_error_msgid_idx[errcode]);
8261 msg_size = strlen (msg) + 1;
8263 if (errbuf_size != 0)
8265 if (msg_size > errbuf_size)
8267 #if defined HAVE_MEMPCPY || defined _LIBC
8268 *((
char *) __mempcpy (errbuf, msg, errbuf_size - 1)) =
'\0';
8270 memcpy (errbuf, msg, errbuf_size - 1);
8271 errbuf[errbuf_size - 1] = 0;
8275 memcpy (errbuf, msg, msg_size);
8281 weak_alias (__regerror, regerror)
8291 if (preg->buffer !=
NULL)
8292 free (preg->buffer);
8293 preg->buffer =
NULL;
8295 preg->allocated = 0;
8298 if (preg->fastmap !=
NULL)
8299 free (preg->fastmap);
8300 preg->fastmap =
NULL;
8301 preg->fastmap_accurate = 0;
8303 if (preg->translate !=
NULL)
8304 free (preg->translate);
8305 preg->translate =
NULL;
8308 weak_alias (__regfree, regfree)
8318 #undef STORE_NUMBER_AND_INCR
8319 #undef EXTRACT_NUMBER
8320 #undef EXTRACT_NUMBER_AND_INCR
8322 #undef DEBUG_PRINT_COMPILED_PATTERN
8323 #undef DEBUG_PRINT_DOUBLE_STRING
8325 #undef INIT_FAIL_STACK
8326 #undef RESET_FAIL_STACK
8327 #undef DOUBLE_FAIL_STACK
8328 #undef PUSH_PATTERN_OP
8329 #undef PUSH_FAILURE_POINTER
8330 #undef PUSH_FAILURE_INT
8331 #undef PUSH_FAILURE_ELT
8332 #undef POP_FAILURE_POINTER
8333 #undef POP_FAILURE_INT
8334 #undef POP_FAILURE_ELT
8337 #undef PUSH_FAILURE_POINT
8338 #undef POP_FAILURE_POINT
8340 #undef REG_UNSET_VALUE
8348 #undef INIT_BUF_SIZE
8349 #undef GET_BUFFER_SPACE
8357 #undef EXTEND_BUFFER
8358 #undef GET_UNSIGNED_NUMBER
8359 #undef FREE_STACK_RETURN
8361 # undef POINTER_TO_OFFSET
8362 # undef MATCHING_IN_FRST_STRING
8364 # undef AT_STRINGS_BEG
8365 # undef AT_STRINGS_END
8368 # undef FREE_VARIABLES
8369 # undef NO_HIGHEST_ACTIVE_REG
8370 # undef NO_LOWEST_ACTIVE_REG
8374 # undef COMPILED_BUFFER_VAR
8375 # undef OFFSET_ADDRESS_SIZE
8376 # undef CHAR_CLASS_SIZE
8383 # define DEFINED_ONCE
unsigned long int active_reg_t
struct re_registers * regs
#define SWITCH_ENUM_CAST(x)
#define RE_SYNTAX_POSIX_BASIC
void struct re_pattern_buffer * bufp
static char re_syntax_table[CHAR_SET_SIZE]
#define RE_CONTEXT_INDEP_ANCHORS
static const char re_error_msgid[]
#define RE_INVALID_INTERVAL_ORD
#define RE_NO_POSIX_BACKTRACKING
#define SIGN_EXTEND_CHAR(c)
#define RETALLOC(addr, n, t)
unsigned long int reg_syntax_t
#define RE_BACKSLASH_ESCAPE_IN_LISTS
reg_syntax_t reg_syntax_t syntax
#define RE_TRANSLATE_TYPE
#define RE_UNMATCHED_RIGHT_PAREN_ORD
unsigned fastmap_accurate
#define RE_NO_EMPTY_RANGES
static const size_t re_error_msgid_idx[]
#define RE_CONTEXT_INDEP_OPS
const char *const char * pattern
#define FIRST_STRING_P(ptr)
#define RETALLOC_IF(addr, n, t)
unsigned long int allocated
reg_syntax_t re_syntax_options
#define RE_CONTEXT_INVALID_OPS
#define gettext_noop(String)
#define RE_HAT_LISTS_NOT_NEWLINE
#define REGEX_TALLOC(n, t)
static boolean compile_stack_type compile_stack
#define RE_SYNTAX_POSIX_EXTENDED
RE_TRANSLATE_TYPE translate
static void init_syntax_once()