Browse code

- changed to named union to allow compilation on older compilers

Andrei Pelinescu-Onciul authored on 20/08/2003 11:46:07
Showing 2 changed files
... ...
@@ -132,25 +132,25 @@ found_re:
132 132
 					rw[rw_no].size=2;
133 133
 					rw[rw_no].offset=(p-1)-repl;
134 134
 					rw[rw_no].type=REPLACE_CHAR;
135
-					rw[rw_no].c='\\';
135
+					rw[rw_no].u.c='\\';
136 136
 					break;
137 137
 				case 'n':
138 138
 					rw[rw_no].size=2;
139 139
 					rw[rw_no].offset=(p-1)-repl;
140 140
 					rw[rw_no].type=REPLACE_CHAR;
141
-					rw[rw_no].c='\n';
141
+					rw[rw_no].u.c='\n';
142 142
 					break;
143 143
 				case 'r':
144 144
 					rw[rw_no].size=2;
145 145
 					rw[rw_no].offset=(p-1)-repl;
146 146
 					rw[rw_no].type=REPLACE_CHAR;
147
-					rw[rw_no].c='\r';
147
+					rw[rw_no].u.c='\r';
148 148
 					break;
149 149
 				case 't':
150 150
 					rw[rw_no].size=2;
151 151
 					rw[rw_no].offset=(p-1)-repl;
152 152
 					rw[rw_no].type=REPLACE_CHAR;
153
-					rw[rw_no].c='\t';
153
+					rw[rw_no].u.c='\t';
154 154
 					break;
155 155
 				/* special sip msg parts escapes */
156 156
 				case 'u':
... ...
@@ -172,9 +172,9 @@ found_re:
172 172
 					rw[rw_no].size=2;
173 173
 					rw[rw_no].offset=(p-1)-repl;
174 174
 					rw[rw_no].type=REPLACE_NMATCH;
175
-					rw[rw_no].nmatch=(*p)-'0'; /* 0 is the whole matched str*/
176
-					if (max_pmatch<rw[rw_no].nmatch) 
177
-						max_pmatch=rw[rw_no].nmatch;
175
+					rw[rw_no].u.nmatch=(*p)-'0';/* 0 is the whole matched str*/
176
+					if (max_pmatch<rw[rw_no].u.nmatch) 
177
+						max_pmatch=rw[rw_no].u.nmatch;
178 178
 					break;
179 179
 				default: /* just print current char */
180 180
 					if (*p!=c){
... ...
@@ -184,7 +184,7 @@ found_re:
184 184
 					rw[rw_no].size=2;
185 185
 					rw[rw_no].offset=(p-1)-repl;
186 186
 					rw[rw_no].type=REPLACE_CHAR;
187
-					rw[rw_no].c=*p;
187
+					rw[rw_no].u.c=*p;
188 188
 					break;
189 189
 			}
190 190
 			rw_no++;
... ...
@@ -280,11 +280,11 @@ static int replace_len(char* match, int nmatch, regmatch_t* pmatch,
280 280
 		switch(se->replace[r].type){
281 281
 			case REPLACE_NMATCH:
282 282
 				len-=se->replace[r].size;
283
-				if ((se->replace[r].nmatch<nmatch)&&(
284
-						pmatch[se->replace[r].nmatch].rm_so!=-1)){
283
+				if ((se->replace[r].u.nmatch<nmatch)&&(
284
+						pmatch[se->replace[r].u.nmatch].rm_so!=-1)){
285 285
 						/* do the replace */
286
-						len+=pmatch[se->replace[r].nmatch].rm_eo-
287
-								pmatch[se->replace[r].nmatch].rm_so;
286
+						len+=pmatch[se->replace[r].u.nmatch].rm_eo-
287
+								pmatch[se->replace[r].u.nmatch].rm_so;
288 288
 				};
289 289
 				break;
290 290
 			case REPLACE_CHAR:
... ...
@@ -345,18 +345,19 @@ static int replace_build(char* match, int nmatch, regmatch_t* pmatch,
345 345
 		dest+=size;
346 346
 		switch(se->replace[r].type){
347 347
 			case REPLACE_NMATCH:
348
-				if ((se->replace[r].nmatch<nmatch)&&(
349
-						pmatch[se->replace[r].nmatch].rm_so!=-1)){
348
+				if ((se->replace[r].u.nmatch<nmatch)&&(
349
+						pmatch[se->replace[r].u.nmatch].rm_so!=-1)){
350 350
 						/* do the replace */
351
-						size=pmatch[se->replace[r].nmatch].rm_eo-
352
-								pmatch[se->replace[r].nmatch].rm_so;
353
-						memcpy(dest, match+pmatch[se->replace[r].nmatch].rm_so,
351
+						size=pmatch[se->replace[r].u.nmatch].rm_eo-
352
+								pmatch[se->replace[r].u.nmatch].rm_so;
353
+						memcpy(dest, 
354
+								match+pmatch[se->replace[r].u.nmatch].rm_so,
354 355
 								size);
355 356
 						dest+=size;
356 357
 				};
357 358
 				break;
358 359
 			case REPLACE_CHAR:
359
-				*dest=se->replace[r].c;
360
+				*dest=se->replace[r].u.c;
360 361
 				dest++;
361 362
 				break;
362 363
 			case REPLACE_URI:
... ...
@@ -49,7 +49,7 @@ struct replace_with{
49 49
 	union{
50 50
 		int nmatch;
51 51
 		char c;
52
-	};
52
+	}u;
53 53
 };
54 54
 
55 55
 struct subst_expr{