Browse Source

- re updates

Andrei Pelinescu-Onciul 22 years ago
parent
commit
267af5f1ad
2 changed files with 10 additions and 1 deletions
  1. 2 0
      TODO
  2. 8 1
      re.c

+ 2 - 0
TODO

@@ -5,6 +5,8 @@ $Id$
 - backport tcp conn id fix to stable
 - change len_gt into and expr (e.g msg:len).
 - sipit: uri == myself doesn't match tls port = 5061
+- sipit: fix check_self & *_alias to work with tcp & tls
+- sipit: fix ipv6 references in check_self
 - regex subst on uris?
 - port receive.c pre_script_cb fix from stable
 - extend alias to include port numbers :

+ 8 - 1
re.c

@@ -395,6 +395,7 @@ struct replace_lst* subst_run(struct subst_expr* se, char* input,
 	int r;
 	regmatch_t* pmatch;
 	int nmatch;
+	int eflags;
 	
 	
 	/* init */
@@ -408,11 +409,14 @@ struct replace_lst* subst_run(struct subst_expr* se, char* input,
 		LOG(L_ERR, "ERROR: subst_run_ out of mem. (pmatch)\n");
 		goto error;
 	}
+	eflags=0;
 	do{
-		r=regexec(se->re, p, nmatch, pmatch, 0);
+		r=regexec(se->re, p, nmatch, pmatch, eflags);
 		DBG("subst_run: running. r=%d\n", r);
 		/* subst */
 		if (r==0){ /* != REG_NOMATCH */
+			/* change eflags, not to match any more at string start */
+			eflags|=REG_NOTBOL;
 			*crt=pkg_malloc(sizeof(struct replace_lst));
 			if (*crt==0){
 				LOG(L_ERR, "ERROR: subst_run: out of mem (crt)\n");
@@ -425,6 +429,9 @@ struct replace_lst* subst_run(struct subst_expr* se, char* input,
 			}
 			(*crt)->offset=pmatch[0].rm_so+(int)(p-input);
 			(*crt)->size=pmatch[0].rm_eo-pmatch[0].rm_so;
+			DBG("subst_run: matched (%d, %d): [%.*s]\n",
+					(*crt)->offset, (*crt)->size, 
+					(*crt)->size, input+(*crt)->offset);
 			/* create subst. string */
 			/* construct the string from replace[] */
 			if (replace_build(p, nmatch, pmatch, se, msg, &((*crt)->rpl))<0){