[Freeswitch-svn] [commit] r7301 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Sat Jan 19 16:54:11 EST 2008


Author: anthm
Date: Sat Jan 19 16:54:11 2008
New Revision: 7301

Modified:
   freeswitch/trunk/src/switch_regex.c
   freeswitch/trunk/src/switch_utils.c

Log:
update

Modified: freeswitch/trunk/src/switch_regex.c
==============================================================================
--- freeswitch/trunk/src/switch_regex.c	(original)
+++ freeswitch/trunk/src/switch_regex.c	Sat Jan 19 16:54:11 2008
@@ -95,7 +95,7 @@
 					  &erroffset,	/* for error offset */
 					  NULL);	/* use default character tables */
 	if (error) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "COMPILE ERROR: %d [%s]\n", erroffset, error);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "COMPILE ERROR: %d [%s][%s]\n", erroffset, error, expression);
 		switch_regex_safe_free(re);
 		goto end;
 	}

Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c	(original)
+++ freeswitch/trunk/src/switch_utils.c	Sat Jan 19 16:54:11 2008
@@ -35,7 +35,7 @@
 #include <arpa/inet.h>
 #endif
 #include "private/switch_core_pvt.h"
-
+#define ESCAPE_META '\\'
 
 SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char close)
 {
@@ -1017,7 +1017,7 @@
 static char unescape_char(char escaped)
 {
 	char unescaped;
-	
+	printf("WTF [%c]\n", escaped);
 	switch (escaped) {
 		case 'n':
 			unescaped = '\n';
@@ -1052,16 +1052,25 @@
 	}
 
 	for (start = dest = ptr; *ptr; ++ptr) {
-		if (*ptr == '\\') {
-			++ptr;
-			*dest++ = unescape_char(*ptr);
-			end = dest;
-		} else if (*ptr == '\'') {
-			inside_quotes = (1 - inside_quotes);
-		} else {
-			*dest++ = *ptr;
-			if (*ptr != ' ' || inside_quotes) {
+		char e;
+		int esc = 0;
+
+		if (*ptr == ESCAPE_META) {
+			if ((e = unescape_char(*(ptr+1))) != e) {
+				++ptr;
+				*dest++ = e;
 				end = dest;
+				esc++;
+			}
+		}
+		if (!esc) {
+			if (*ptr == '\'') {
+				inside_quotes = (1 - inside_quotes);
+			} else {
+				*dest++ = *ptr;
+				if (*ptr != ' ' || inside_quotes) {
+					end = dest;
+				}
 			}
 		}
 	}
@@ -1093,7 +1102,7 @@
 
 			case FIND_DELIM:
 				/* escaped characters are copied verbatim to the destination string */
-				if (*ptr == '\\') {
+				if (*ptr == ESCAPE_META) {
 					++ptr;
 				} else if (*ptr == '\'') {
 					inside_quotes = (1 - inside_quotes);
@@ -1143,7 +1152,7 @@
 				break;
 
 			case FIND_DELIM:
-				if (*ptr == '\\') {
+				if (*ptr == ESCAPE_META) {
 					++ptr;
 				} else if (*ptr == '\'') {
 					inside_quotes = (1 - inside_quotes);



More information about the Freeswitch-svn mailing list