You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							137 lines
						
					
					
						
							3.8 KiB
						
					
					
				
			
		
		
	
	
							137 lines
						
					
					
						
							3.8 KiB
						
					
					
				| Fri Mar 16 19:18:02 EET 2007  Ville Laurikari <[email protected]> | |
|   * Refactoring. | |
| diff -rN -u old-stable/lib/tre-compile.c new-stable/lib/tre-compile.c | |
| --- old-stable/lib/tre-compile.c	2007-11-04 20:27:45.000000000 +0200 | |
| +++ new-stable/lib/tre-compile.c	2007-11-04 20:27:45.000000000 +0200 | |
| @@ -1,7 +1,7 @@ | |
|  /* | |
|    tre-compile.c - TRE regex compiler | |
|   | |
| -  Copyright (c) 2001-2006 Ville Laurikari <[email protected]> | |
| +  Copyright (c) 2001-2007 Ville Laurikari <[email protected]> | |
|   | |
|    This library is free software; you can redistribute it and/or | |
|    modify it under the terms of the GNU Lesser General Public | |
| @@ -127,6 +127,30 @@ | |
|    int next_tag; | |
|  } tre_tag_states_t; | |
|   | |
| + | |
| +/* Go through `regset' and set submatch data for submatches that are | |
| +   using this tag. */ | |
| +static void | |
| +tre_purge_regset(int *regset, tre_tnfa_t *tnfa, int tag) | |
| +{ | |
| +  int i; | |
| + | |
| +  for (i = 0; regset[i] >= 0; i++) | |
| +    { | |
| +      int id = regset[i] / 2; | |
| +      int start = !(regset[i] % 2); | |
| +      DPRINT(("  Using tag %d for %s offset of " | |
| +	      "submatch %d\n", tag, | |
| +	      start ? "start" : "end", id)); | |
| +      if (start) | |
| +	tnfa->submatch_data[id].so_tag = tag; | |
| +      else | |
| +	tnfa->submatch_data[id].eo_tag = tag; | |
| +    } | |
| +  regset[0] = -1; | |
| +} | |
| + | |
| + | |
|  /* Adds tags to appropriate locations in the parse tree in `tree', so that | |
|     subexpressions marked for submatch addressing can be traced. */ | |
|  static reg_errcode_t | |
| @@ -281,20 +305,7 @@ | |
|  				minimal_tag = -1; | |
|  				num_minimals++; | |
|  			      } | |
| -			    /* Go through the regset and set submatch data for | |
| -			       submatches that are using this tag. */ | |
| -			    for (i = 0; regset[i] >= 0; i++) | |
| -			      { | |
| -				int id = regset[i] / 2; | |
| -				int start = !(regset[i] % 2); | |
| -				DPRINT(("  Using tag %d for %s offset of " | |
| -					"submatch %d\n", tag, | |
| -					start ? "start" : "end", id)); | |
| -				if (start) | |
| -				  tnfa->submatch_data[id].so_tag = tag; | |
| -				else | |
| -				  tnfa->submatch_data[id].eo_tag = tag; | |
| -			      } | |
| +			    tre_purge_regset(regset, tnfa, tag); | |
|  			  } | |
|  			else | |
|  			  { | |
| @@ -394,20 +405,7 @@ | |
|  			    minimal_tag = -1; | |
|  			    num_minimals++; | |
|  			  } | |
| -			/* Go through the regset and set submatch data for | |
| -			   submatches that are using this tag. */ | |
| -			for (i = 0; regset[i] >= 0; i++) | |
| -			  { | |
| -			    int id = regset[i] / 2; | |
| -			    int start = !(regset[i] % 2); | |
| -			    DPRINT(("  Using tag %d for %s offset of " | |
| -				    "submatch %d\n", tag, | |
| -				    start ? "start" : "end", id)); | |
| -			    if (start) | |
| -			      tnfa->submatch_data[id].so_tag = tag; | |
| -			    else | |
| -			      tnfa->submatch_data[id].eo_tag = tag; | |
| -			  } | |
| +			tre_purge_regset(regset, tnfa, tag); | |
|  		      } | |
|   | |
|  		    DPRINT(("  num_tags++\n")); | |
| @@ -479,20 +477,7 @@ | |
|  			    minimal_tag = -1; | |
|  			    num_minimals++; | |
|  			  } | |
| -			/* Go through the regset and set submatch data for | |
| -			   submatches that are using this tag. */ | |
| -			for (i = 0; regset[i] >= 0; i++) | |
| -			  { | |
| -			    int id = regset[i] / 2; | |
| -			    int start = !(regset[i] % 2); | |
| -			    DPRINT(("  Using tag %d for %s offset of " | |
| -				    "submatch %d\n", tag, | |
| -				    start ? "start" : "end", id)); | |
| -			    if (start) | |
| -			      tnfa->submatch_data[id].so_tag = tag; | |
| -			    else | |
| -			      tnfa->submatch_data[id].eo_tag = tag; | |
| -			  } | |
| +			tre_purge_regset(regset, tnfa, tag); | |
|  		      } | |
|   | |
|  		    DPRINT(("  num_tags++\n")); | |
| @@ -640,23 +625,7 @@ | |
|      } /* end while(tre_stack_num_objects(stack) > bottom) */ | |
|   | |
|    if (!first_pass) | |
| -    { | |
| -      int i; | |
| -      /* Go through the regset and set submatch data for | |
| -	 submatches that are using this tag. */ | |
| -      for (i = 0; regset[i] >= 0; i++) | |
| -	{ | |
| -	  int id = regset[i] / 2; | |
| -	  int start = !(regset[i] % 2); | |
| -	  DPRINT(("  Using tag %d for %s offset of " | |
| -		  "submatch %d\n", num_tags, | |
| -		  start ? "start" : "end", id)); | |
| -	  if (start) | |
| -	    tnfa->submatch_data[id].so_tag = num_tags; | |
| -	  else | |
| -	    tnfa->submatch_data[id].eo_tag = num_tags; | |
| -	} | |
| -    } | |
| +    tre_purge_regset(regset, tnfa, tag); | |
|   | |
|    if (!first_pass && minimal_tag >= 0) | |
|      { | |
| 
 | |
| 
 |