aboutsummaryrefslogtreecommitdiffstats
path: root/src/regex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex.c')
-rw-r--r--src/regex.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/regex.c b/src/regex.c
index 4bf119402ac..afe3751ea5e 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -255,8 +255,6 @@ xrealloc (void *block, size_t size)
255/* Sword must be nonzero for the wordchar pattern commands in re_match_2. */ 255/* Sword must be nonzero for the wordchar pattern commands in re_match_2. */
256enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 }; 256enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
257 257
258# define SWITCH_ENUM_CAST(x) (x)
259
260/* Dummy macros for non-Emacs environments. */ 258/* Dummy macros for non-Emacs environments. */
261# define CHAR_CHARSET(c) 0 259# define CHAR_CHARSET(c) 0
262# define CHARSET_LEADING_CODE_BASE(c) 0 260# define CHARSET_LEADING_CODE_BASE(c) 0
@@ -1739,20 +1737,6 @@ static int analyse_first (re_char *p, re_char *pend,
1739 be too small, many things would have to change. */ 1737 be too small, many things would have to change. */
1740# define MAX_BUF_SIZE (1L << 15) 1738# define MAX_BUF_SIZE (1L << 15)
1741 1739
1742#if 0 /* This is when we thought it could be 2^16 bytes. */
1743/* Any other compiler which, like MSC, has allocation limit below 2^16
1744 bytes will have to use approach similar to what was done below for
1745 MSC and drop MAX_BUF_SIZE a bit. Otherwise you may end up
1746 reallocating to 0 bytes. Such thing is not going to work too well.
1747 You have been warned!! */
1748#if defined _MSC_VER && !defined WIN32
1749/* Microsoft C 16-bit versions limit malloc to approx 65512 bytes. */
1750# define MAX_BUF_SIZE 65500L
1751#else
1752# define MAX_BUF_SIZE (1L << 16)
1753#endif
1754#endif /* 0 */
1755
1756/* Extend the buffer by twice its current size via realloc and 1740/* Extend the buffer by twice its current size via realloc and
1757 reset the pointers that pointed into the old block to point to the 1741 reset the pointers that pointed into the old block to point to the
1758 correct places in the new one. If extending the buffer results in it 1742 correct places in the new one. If extending the buffer results in it
@@ -3927,7 +3911,7 @@ analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int m
3927 as used for the *? operator. */ 3911 as used for the *? operator. */
3928 re_char *p1 = p; 3912 re_char *p1 = p;
3929 3913
3930 switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++)) 3914 switch (*p++)
3931 { 3915 {
3932 case succeed: 3916 case succeed:
3933 return 1; 3917 return 1;
@@ -4102,7 +4086,7 @@ analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int m
4102 visited. `re_compile' should make sure this is true. */ 4086 visited. `re_compile' should make sure this is true. */
4103 break; 4087 break;
4104 p += j; 4088 p += j;
4105 switch (SWITCH_ENUM_CAST ((re_opcode_t) *p)) 4089 switch (*p)
4106 { 4090 {
4107 case on_failure_jump: 4091 case on_failure_jump:
4108 case on_failure_keep_string_jump: 4092 case on_failure_keep_string_jump:
@@ -4635,7 +4619,7 @@ static int bcmp_translate (re_char *s1, re_char *s2,
4635static re_char * 4619static re_char *
4636skip_one_char (const re_char *p) 4620skip_one_char (const re_char *p)
4637{ 4621{
4638 switch (SWITCH_ENUM_CAST (*p++)) 4622 switch (*p++)
4639 { 4623 {
4640 case anychar: 4624 case anychar:
4641 break; 4625 break;
@@ -4680,7 +4664,7 @@ skip_noops (const re_char *p, const re_char *pend)
4680 int mcnt; 4664 int mcnt;
4681 while (p < pend) 4665 while (p < pend)
4682 { 4666 {
4683 switch (SWITCH_ENUM_CAST ((re_opcode_t) *p)) 4667 switch (*p)
4684 { 4668 {
4685 case start_memory: 4669 case start_memory:
4686 case stop_memory: 4670 case stop_memory:
@@ -4725,7 +4709,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const r
4725 4709
4726 op2 = p2 == pend ? succeed : *p2; 4710 op2 = p2 == pend ? succeed : *p2;
4727 4711
4728 switch (SWITCH_ENUM_CAST (op2)) 4712 switch (op2)
4729 { 4713 {
4730 case succeed: 4714 case succeed:
4731 case endbuf: 4715 case endbuf:
@@ -4849,7 +4833,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const r
4849 break; 4833 break;
4850 4834
4851 case charset_not: 4835 case charset_not:
4852 switch (SWITCH_ENUM_CAST (*p1)) 4836 switch (*p1)
4853 { 4837 {
4854 case exactn: 4838 case exactn:
4855 case charset: 4839 case charset:
@@ -5327,7 +5311,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1,
5327 } 5311 }
5328 5312
5329 /* Otherwise match next pattern command. */ 5313 /* Otherwise match next pattern command. */
5330 switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++)) 5314 switch (*p++)
5331 { 5315 {
5332 /* Ignore these. Used to ignore the n of succeed_n's which 5316 /* Ignore these. Used to ignore the n of succeed_n's which
5333 currently have n == 0. */ 5317 currently have n == 0. */
@@ -6249,7 +6233,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1,
6249 /* A restart point is known. Restore to that state. */ 6233 /* A restart point is known. Restore to that state. */
6250 DEBUG_PRINT1 ("\nFAIL:\n"); 6234 DEBUG_PRINT1 ("\nFAIL:\n");
6251 POP_FAILURE_POINT (str, pat); 6235 POP_FAILURE_POINT (str, pat);
6252 switch (SWITCH_ENUM_CAST ((re_opcode_t) *pat++)) 6236 switch (*pat++)
6253 { 6237 {
6254 case on_failure_keep_string_jump: 6238 case on_failure_keep_string_jump:
6255 assert (str == NULL); 6239 assert (str == NULL);