/* Whether to use ISO C Amendment 1 wide char functions.
Those should not be used for Emacs since it uses its own. */
+#if defined _LIBC
+#define WIDE_CHAR_SUPPORT 1
+#else
#define WIDE_CHAR_SUPPORT \
- (defined _LIBC || HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC && !emacs)
+ (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC && !emacs)
+#endif
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
# include "charset.h"
# include "category.h"
+# ifdef malloc
+# undef malloc
+# endif
# define malloc xmalloc
+# ifdef realloc
+# undef realloc
+# endif
# define realloc xrealloc
+# ifdef free
+# undef free
+# endif
# define free xfree
/* Converts the pointer to the char to BEG-based offset from the start. */
/* Roughly the maximum number of failure points on the stack. Would be
exactly that if always used TYPICAL_FAILURE_SIZE items each time we failed.
This is a variable only so users of regex can assign to it; we never
- change it ourselves. */
+ change it ourselves. We always multiply it by TYPICAL_FAILURE_SIZE
+ before using it, so it should probably be a byte-count instead. */
# if defined MATCH_MAY_ALLOCATE
/* Note that 4400 was enough to cause a crash on Alpha OSF/1,
whose default stack limit is 2mb. In order for a larger
/* Estimate the size of data pushed by a typical failure stack entry.
An estimate is all we need, because all we use this for
is to choose a limit for how big to make the failure stack. */
-
+/* BEWARE, the value `20' is hard-coded in emacs.c:main(). */
#define TYPICAL_FAILURE_SIZE 20
/* How many items can still be added to the stack without overflowing it. */
/* Map a string to the char class it names (if any). */
static re_wctype_t
-re_wctype (string)
- re_char *string;
+re_wctype (str)
+ re_char *str;
{
+ const char *string = str;
if (STREQ (string, "alnum")) return RECC_ALNUM;
else if (STREQ (string, "alpha")) return RECC_ALPHA;
else if (STREQ (string, "word")) return RECC_WORD;
{
register re_wchar_t c
= (re_opcode_t) *p2 == endline ? '\n'
- : RE_STRING_CHAR(p2 + 2, pend - p2 - 2);
+ : RE_STRING_CHAR (p2 + 2, pend - p2 - 2);
if ((re_opcode_t) *p1 == exactn)
{
break;
case charset:
- case charset_not:
{
if ((re_opcode_t) *p1 == exactn)
/* Reuse the code above. */
return mutually_exclusive_p (bufp, p2, p1);
-
/* It is hard to list up all the character in charset
P2 if it includes multibyte character. Give up in
such case. */
P2 is ASCII, it is enough to test only bitmap
table of P1. */
- if (*p1 == *p2)
+ if ((re_opcode_t) *p1 == charset)
{
int idx;
/* We win if the charset inside the loop
return 1;
}
}
- else if ((re_opcode_t) *p1 == charset
- || (re_opcode_t) *p1 == charset_not)
+ else if ((re_opcode_t) *p1 == charset_not)
{
int idx;
/* We win if the charset_not inside the loop lists
}
}
}
+ break;
+ case charset_not:
+ switch (SWITCH_ENUM_CAST (*p1))
+ {
+ case exactn:
+ case charset:
+ /* Reuse the code above. */
+ return mutually_exclusive_p (bufp, p2, p1);
+ case charset_not:
+ /* When we have two charset_not, it's very unlikely that
+ they don't overlap. The union of the two sets of excluded
+ chars should cover all possible chars, which, as a matter of
+ fact, is virtually impossible in multibyte buffers. */
+ ;
+ }
+ break;
+
case wordend:
case notsyntaxspec:
return ((re_opcode_t) *p1 == syntaxspec
int
regcomp (preg, pattern, cflags)
- regex_t *preg;
- const char *pattern;
+ regex_t *__restrict preg;
+ const char *__restrict pattern;
int cflags;
{
reg_errcode_t ret;
int
regexec (preg, string, nmatch, pmatch, eflags)
- const regex_t *preg;
- const char *string;
+ const regex_t *__restrict preg;
+ const char *__restrict string;
size_t nmatch;
regmatch_t pmatch[];
int eflags;