comparison src/regex.c @ 49600:23a1cea22d13

Trailing whitespace deleted.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 04 Feb 2003 14:56:31 +0000
parents f71131f142ff
children 0f71486df5bc d7ddb3e565de
comparison
equal deleted inserted replaced
49599:5ade352e8d1c 49600:23a1cea22d13
2063 /* Actually extend the space in WORK_AREA. */ 2063 /* Actually extend the space in WORK_AREA. */
2064 2064
2065 static void 2065 static void
2066 extend_range_table_work_area (work_area) 2066 extend_range_table_work_area (work_area)
2067 struct range_table_work_area *work_area; 2067 struct range_table_work_area *work_area;
2068 { 2068 {
2069 work_area->allocated += 16 * sizeof (int); 2069 work_area->allocated += 16 * sizeof (int);
2070 if (work_area->table) 2070 if (work_area->table)
2071 work_area->table 2071 work_area->table
2072 = (int *) realloc (work_area->table, work_area->allocated); 2072 = (int *) realloc (work_area->table, work_area->allocated);
2073 else 2073 else
2102 each of which has two case-equivalent forms. 2102 each of which has two case-equivalent forms.
2103 This includes all ASCII letters. 2103 This includes all ASCII letters.
2104 2104
2105 `strange' indicates a character that has more than one 2105 `strange' indicates a character that has more than one
2106 case-equivalent. */ 2106 case-equivalent. */
2107 2107
2108 enum case_type {one_case, two_case, strange}; 2108 enum case_type {one_case, two_case, strange};
2109 2109
2110 /* Describe the run that is in progress, 2110 /* Describe the run that is in progress,
2111 which the next character can try to extend. 2111 which the next character can try to extend.
2112 If run_type is strange, that means there really is no run. 2112 If run_type is strange, that means there really is no run.
2172 work_area->table[work_area->used++] 2172 work_area->table[work_area->used++]
2173 = RE_TRANSLATE (eqv_table, run_end); 2173 = RE_TRANSLATE (eqv_table, run_end);
2174 } 2174 }
2175 run_type = strange; 2175 run_type = strange;
2176 } 2176 }
2177 2177
2178 if (this_type == strange) 2178 if (this_type == strange)
2179 { 2179 {
2180 /* For a strange character, add each of its equivalents, one 2180 /* For a strange character, add each of its equivalents, one
2181 by one. Don't start a range. */ 2181 by one. Don't start a range. */
2182 do 2182 do
2622 re_opcode_t ofj = 2622 re_opcode_t ofj =
2623 /* Check if the loop can match the empty string. */ 2623 /* Check if the loop can match the empty string. */
2624 (simple || !analyse_first (laststart, b, NULL, 0)) 2624 (simple || !analyse_first (laststart, b, NULL, 0))
2625 ? on_failure_jump : on_failure_jump_loop; 2625 ? on_failure_jump : on_failure_jump_loop;
2626 assert (skip_one_char (laststart) <= b); 2626 assert (skip_one_char (laststart) <= b);
2627 2627
2628 if (!zero_times_ok && simple) 2628 if (!zero_times_ok && simple)
2629 { /* Since simple * loops can be made faster by using 2629 { /* Since simple * loops can be made faster by using
2630 on_failure_keep_string_jump, we turn simple P+ 2630 on_failure_keep_string_jump, we turn simple P+
2631 into PP* if P is simple. */ 2631 into PP* if P is simple. */
2632 unsigned char *p1, *p2; 2632 unsigned char *p1, *p2;
3939 p += 4; 3939 p += 4;
3940 /* jump_n can either jump or fall through. The (backward) jump 3940 /* jump_n can either jump or fall through. The (backward) jump
3941 case has already been handled, so we only need to look at the 3941 case has already been handled, so we only need to look at the
3942 fallthrough case. */ 3942 fallthrough case. */
3943 continue; 3943 continue;
3944 3944
3945 case succeed_n: 3945 case succeed_n:
3946 /* If N == 0, it should be an on_failure_jump_loop instead. */ 3946 /* If N == 0, it should be an on_failure_jump_loop instead. */
3947 DEBUG_STATEMENT (EXTRACT_NUMBER (j, p + 2); assert (j > 0)); 3947 DEBUG_STATEMENT (EXTRACT_NUMBER (j, p + 2); assert (j > 0));
3948 p += 4; 3948 p += 4;
3949 /* We only care about one iteration of the loop, so we don't 3949 /* We only care about one iteration of the loop, so we don't
4422 { 4422 {
4423 switch (SWITCH_ENUM_CAST (*p++)) 4423 switch (SWITCH_ENUM_CAST (*p++))
4424 { 4424 {
4425 case anychar: 4425 case anychar:
4426 break; 4426 break;
4427 4427
4428 case exactn: 4428 case exactn:
4429 p += *p + 1; 4429 p += *p + 1;
4430 break; 4430 break;
4431 4431
4432 case charset_not: 4432 case charset_not:
4439 p = CHARSET_RANGE_TABLE_END (p, mcnt); 4439 p = CHARSET_RANGE_TABLE_END (p, mcnt);
4440 } 4440 }
4441 else 4441 else
4442 p += 1 + CHARSET_BITMAP_SIZE (p - 1); 4442 p += 1 + CHARSET_BITMAP_SIZE (p - 1);
4443 break; 4443 break;
4444 4444
4445 case syntaxspec: 4445 case syntaxspec:
4446 case notsyntaxspec: 4446 case notsyntaxspec:
4447 #ifdef emacs 4447 #ifdef emacs
4448 case categoryspec: 4448 case categoryspec:
4449 case notcategoryspec: 4449 case notcategoryspec:
4522 { 4522 {
4523 DEBUG_PRINT1 (" End of pattern: fast loop.\n"); 4523 DEBUG_PRINT1 (" End of pattern: fast loop.\n");
4524 return 1; 4524 return 1;
4525 } 4525 }
4526 break; 4526 break;
4527 4527
4528 case endline: 4528 case endline:
4529 case exactn: 4529 case exactn:
4530 { 4530 {
4531 register re_wchar_t c 4531 register re_wchar_t c
4532 = (re_opcode_t) *p2 == endline ? '\n' 4532 = (re_opcode_t) *p2 == endline ? '\n'
4632 } 4632 }
4633 } 4633 }
4634 } 4634 }
4635 } 4635 }
4636 break; 4636 break;
4637 4637
4638 case charset_not: 4638 case charset_not:
4639 switch (SWITCH_ENUM_CAST (*p1)) 4639 switch (SWITCH_ENUM_CAST (*p1))
4640 { 4640 {
4641 case exactn: 4641 case exactn:
4642 case charset: 4642 case charset:
5316 case stop_memory: 5316 case stop_memory:
5317 DEBUG_PRINT2 ("EXECUTING stop_memory %d:\n", *p); 5317 DEBUG_PRINT2 ("EXECUTING stop_memory %d:\n", *p);
5318 5318
5319 assert (!REG_UNSET (regstart[*p])); 5319 assert (!REG_UNSET (regstart[*p]));
5320 /* Strictly speaking, there should be code such as: 5320 /* Strictly speaking, there should be code such as:
5321 5321
5322 assert (REG_UNSET (regend[*p])); 5322 assert (REG_UNSET (regend[*p]));
5323 PUSH_FAILURE_REGSTOP ((unsigned int)*p); 5323 PUSH_FAILURE_REGSTOP ((unsigned int)*p);
5324 5324
5325 But the only info to be pushed is regend[*p] and it is known to 5325 But the only info to be pushed is regend[*p] and it is known to
5326 be UNSET, so there really isn't anything to push. 5326 be UNSET, so there really isn't anything to push.
5733 UPDATE_SYNTAX_TABLE (charpos); 5733 UPDATE_SYNTAX_TABLE (charpos);
5734 #endif 5734 #endif
5735 PREFETCH (); 5735 PREFETCH ();
5736 c2 = RE_STRING_CHAR (d, dend - d); 5736 c2 = RE_STRING_CHAR (d, dend - d);
5737 s2 = SYNTAX (c2); 5737 s2 = SYNTAX (c2);
5738 5738
5739 /* Case 2: S2 is not Sword. */ 5739 /* Case 2: S2 is not Sword. */
5740 if (s2 != Sword) 5740 if (s2 != Sword)
5741 goto fail; 5741 goto fail;
5742 5742
5743 /* Case 3: D is not at the beginning of string ... */ 5743 /* Case 3: D is not at the beginning of string ... */