comparison src/regex.c @ 4750:b5f21bb36684

Fix crash in regex.c (closes issue630).
author Stephen J. Turnbull <stephen@xemacs.org>
date Tue, 17 Nov 2009 23:41:39 +0900
parents 8418d1ad4944
children aa5ed11f473b
comparison
equal deleted inserted replaced
4747:294a86d29f99 4750:b5f21bb36684
110 110
111 #define INC_IBYTEPTR(p) ((p)++) 111 #define INC_IBYTEPTR(p) ((p)++)
112 #define INC_IBYTEPTR_FMT(p, fmt) ((p)++) 112 #define INC_IBYTEPTR_FMT(p, fmt) ((p)++)
113 #define DEC_IBYTEPTR(p) ((p)--) 113 #define DEC_IBYTEPTR(p) ((p)--)
114 #define DEC_IBYTEPTR_FMT(p, fmt) ((p)--) 114 #define DEC_IBYTEPTR_FMT(p, fmt) ((p)--)
115 #define MAX_ICHAR_LEN 1
115 #define itext_ichar_len(ptr) 1 116 #define itext_ichar_len(ptr) 1
116 #define itext_ichar_len_fmt(ptr, fmt) 1 117 #define itext_ichar_len_fmt(ptr, fmt) 1
117 118
118 /* Define the syntax stuff for \<, \>, etc. */ 119 /* Define the syntax stuff for \<, \>, etc. */
119 120
811 break; 812 break;
812 813
813 case exactn: 814 case exactn:
814 mcnt = *p++; 815 mcnt = *p++;
815 printf ("/exactn/%d", mcnt); 816 printf ("/exactn/%d", mcnt);
816 do 817 while (mcnt--)
817 { 818 {
818 putchar ('/'); 819 putchar ('/');
819 putchar (*p++); 820 putchar (*p++);
820 } 821 }
821 while (--mcnt);
822 break; 822 break;
823 823
824 case start_memory: 824 case start_memory:
825 mcnt = *p++; 825 mcnt = *p++;
826 printf ("/start_memory/%d/%d", mcnt, *p++); 826 printf ("/start_memory/%d/%d", mcnt, *p++);
3337 default: 3337 default:
3338 /* Expects the character in `c'. */ 3338 /* Expects the character in `c'. */
3339 /* `p' points to the location after where `c' came from. */ 3339 /* `p' points to the location after where `c' came from. */
3340 normal_char: 3340 normal_char:
3341 { 3341 {
3342 /* XEmacs: modifications here for Mule. */ 3342 /* The following conditional synced to GNU Emacs 22.1. */
3343 /* `q' points to the beginning of the next char. */
3344 re_char *q = p;
3345
3346 /* If no exactn currently being built. */ 3343 /* If no exactn currently being built. */
3347 if (!pending_exact 3344 if (!pending_exact
3348 3345
3349 /* If last exactn not at current position. */ 3346 /* If last exactn not at current position. */
3350 || pending_exact + *pending_exact + 1 != buf_end 3347 || pending_exact + *pending_exact + 1 != buf_end
3351 3348
3352 /* We have only one byte following the exactn for the count. */ 3349 /* We have only one byte following the exactn for the count. */
3353 || ((unsigned int) (*pending_exact + (q - p)) >= 3350 || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN
3354 ((unsigned int) (1 << BYTEWIDTH) - 1)) 3351
3355 3352 /* If followed by a repetition operator.
3356 /* If followed by a repetition operator. */ 3353 If the lookahead fails because of end of pattern, any
3357 || *q == '*' || *q == '^' 3354 trailing backslash will get caught later. */
3355 || (p != pend && (*p == '*' || *p == '^'))
3358 || ((syntax & RE_BK_PLUS_QM) 3356 || ((syntax & RE_BK_PLUS_QM)
3359 ? *q == '\\' && (q[1] == '+' || q[1] == '?') 3357 ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?')
3360 : (*q == '+' || *q == '?')) 3358 : p != pend && (*p == '+' || *p == '?'))
3361 || ((syntax & RE_INTERVALS) 3359 || ((syntax & RE_INTERVALS)
3362 && ((syntax & RE_NO_BK_BRACES) 3360 && ((syntax & RE_NO_BK_BRACES)
3363 ? *q == '{' 3361 ? p != pend && *p == '{'
3364 : (q[0] == '\\' && q[1] == '{')))) 3362 : p + 1 < pend && (p[0] == '\\' && p[1] == '{'))))
3365 { 3363 {
3366 /* Start building a new exactn. */ 3364 /* Start building a new exactn. */
3367 3365
3368 laststart = buf_end; 3366 laststart = buf_end;
3369 3367