Browse Source

- changed to named union to allow compilation on older compilers

Andrei Pelinescu-Onciul 22 years ago
parent
commit
e6e049efe5
2 changed files with 20 additions and 19 deletions
  1. 19 18
      re.c
  2. 1 1
      re.h

+ 19 - 18
re.c

@@ -132,25 +132,25 @@ found_re:
 					rw[rw_no].size=2;
 					rw[rw_no].size=2;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].type=REPLACE_CHAR;
 					rw[rw_no].type=REPLACE_CHAR;
-					rw[rw_no].c='\\';
+					rw[rw_no].u.c='\\';
 					break;
 					break;
 				case 'n':
 				case 'n':
 					rw[rw_no].size=2;
 					rw[rw_no].size=2;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].type=REPLACE_CHAR;
 					rw[rw_no].type=REPLACE_CHAR;
-					rw[rw_no].c='\n';
+					rw[rw_no].u.c='\n';
 					break;
 					break;
 				case 'r':
 				case 'r':
 					rw[rw_no].size=2;
 					rw[rw_no].size=2;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].type=REPLACE_CHAR;
 					rw[rw_no].type=REPLACE_CHAR;
-					rw[rw_no].c='\r';
+					rw[rw_no].u.c='\r';
 					break;
 					break;
 				case 't':
 				case 't':
 					rw[rw_no].size=2;
 					rw[rw_no].size=2;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].type=REPLACE_CHAR;
 					rw[rw_no].type=REPLACE_CHAR;
-					rw[rw_no].c='\t';
+					rw[rw_no].u.c='\t';
 					break;
 					break;
 				/* special sip msg parts escapes */
 				/* special sip msg parts escapes */
 				case 'u':
 				case 'u':
@@ -172,9 +172,9 @@ found_re:
 					rw[rw_no].size=2;
 					rw[rw_no].size=2;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].type=REPLACE_NMATCH;
 					rw[rw_no].type=REPLACE_NMATCH;
-					rw[rw_no].nmatch=(*p)-'0'; /* 0 is the whole matched str*/
-					if (max_pmatch<rw[rw_no].nmatch) 
-						max_pmatch=rw[rw_no].nmatch;
+					rw[rw_no].u.nmatch=(*p)-'0';/* 0 is the whole matched str*/
+					if (max_pmatch<rw[rw_no].u.nmatch) 
+						max_pmatch=rw[rw_no].u.nmatch;
 					break;
 					break;
 				default: /* just print current char */
 				default: /* just print current char */
 					if (*p!=c){
 					if (*p!=c){
@@ -184,7 +184,7 @@ found_re:
 					rw[rw_no].size=2;
 					rw[rw_no].size=2;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].offset=(p-1)-repl;
 					rw[rw_no].type=REPLACE_CHAR;
 					rw[rw_no].type=REPLACE_CHAR;
-					rw[rw_no].c=*p;
+					rw[rw_no].u.c=*p;
 					break;
 					break;
 			}
 			}
 			rw_no++;
 			rw_no++;
@@ -280,11 +280,11 @@ static int replace_len(char* match, int nmatch, regmatch_t* pmatch,
 		switch(se->replace[r].type){
 		switch(se->replace[r].type){
 			case REPLACE_NMATCH:
 			case REPLACE_NMATCH:
 				len-=se->replace[r].size;
 				len-=se->replace[r].size;
-				if ((se->replace[r].nmatch<nmatch)&&(
-						pmatch[se->replace[r].nmatch].rm_so!=-1)){
+				if ((se->replace[r].u.nmatch<nmatch)&&(
+						pmatch[se->replace[r].u.nmatch].rm_so!=-1)){
 						/* do the replace */
 						/* do the replace */
-						len+=pmatch[se->replace[r].nmatch].rm_eo-
-								pmatch[se->replace[r].nmatch].rm_so;
+						len+=pmatch[se->replace[r].u.nmatch].rm_eo-
+								pmatch[se->replace[r].u.nmatch].rm_so;
 				};
 				};
 				break;
 				break;
 			case REPLACE_CHAR:
 			case REPLACE_CHAR:
@@ -345,18 +345,19 @@ static int replace_build(char* match, int nmatch, regmatch_t* pmatch,
 		dest+=size;
 		dest+=size;
 		switch(se->replace[r].type){
 		switch(se->replace[r].type){
 			case REPLACE_NMATCH:
 			case REPLACE_NMATCH:
-				if ((se->replace[r].nmatch<nmatch)&&(
-						pmatch[se->replace[r].nmatch].rm_so!=-1)){
+				if ((se->replace[r].u.nmatch<nmatch)&&(
+						pmatch[se->replace[r].u.nmatch].rm_so!=-1)){
 						/* do the replace */
 						/* do the replace */
-						size=pmatch[se->replace[r].nmatch].rm_eo-
-								pmatch[se->replace[r].nmatch].rm_so;
-						memcpy(dest, match+pmatch[se->replace[r].nmatch].rm_so,
+						size=pmatch[se->replace[r].u.nmatch].rm_eo-
+								pmatch[se->replace[r].u.nmatch].rm_so;
+						memcpy(dest, 
+								match+pmatch[se->replace[r].u.nmatch].rm_so,
 								size);
 								size);
 						dest+=size;
 						dest+=size;
 				};
 				};
 				break;
 				break;
 			case REPLACE_CHAR:
 			case REPLACE_CHAR:
-				*dest=se->replace[r].c;
+				*dest=se->replace[r].u.c;
 				dest++;
 				dest++;
 				break;
 				break;
 			case REPLACE_URI:
 			case REPLACE_URI:

+ 1 - 1
re.h

@@ -49,7 +49,7 @@ struct replace_with{
 	union{
 	union{
 		int nmatch;
 		int nmatch;
 		char c;
 		char c;
-	};
+	}u;
 };
 };
 
 
 struct subst_expr{
 struct subst_expr{