Browse code

- fix to allow hosts with '-' outside double quotes: listen=foo-bar.com will work now (before only listen="foo-bar.com" would have worked)

Andrei Pelinescu-Onciul authored on 09/09/2004 15:21:49
Showing 2 changed files
... ...
@@ -154,6 +154,8 @@ MATCH	=~
154 154
 NOT		!|"not"
155 155
 AND		"and"|"&&"|"&"
156 156
 OR		"or"|"||"|"|"
157
+PLUS	"+"
158
+MINUS	"-"
157 159
 
158 160
 /* config vars. */
159 161
 DEBUG	debug
... ...
@@ -406,6 +408,8 @@ EAT_ABLE	[\ \t\b\r]
406 408
 <INITIAL>{NOT}		{ count(); return NOT; }
407 409
 <INITIAL>{AND}		{ count(); return AND; }
408 410
 <INITIAL>{OR}		{ count(); return OR;  }
411
+<INITIAL>{PLUS}		{ count(); return PLUS; }
412
+<INITIAL>{MINUS}	{ count(); return MINUS; }
409 413
 
410 414
 
411 415
 
... ...
@@ -262,6 +262,8 @@ static struct id_list* mk_listen_id(char*, int, int);
262 262
 %left OR
263 263
 %left AND
264 264
 %left NOT
265
+%left PLUS
266
+%left MINUS
265 267
 
266 268
 /* values */
267 269
 %token <intval> NUMBER
... ...
@@ -296,6 +298,7 @@ static struct id_list* mk_listen_id(char*, int, int);
296 298
 %type <idlst>  phostport
297 299
 %type <intval> proto port
298 300
 %type <intval> equalop strop intop
301
+%type <strval> host_sep
299 302
 /*%type <route_el> rules;
300 303
   %type <route_el> rule;
301 304
 */
... ...
@@ -974,16 +977,22 @@ ipnet:	ip SLASH ip	{ $$=mk_net($1, $3); }
974 977
 						}
975 978
 	;
976 979
 
980
+
981
+
982
+host_sep:	DOT {$$=".";}
983
+		|	MINUS {$$="-"; }
984
+		;
985
+
977 986
 host:	ID				{ $$=$1; }
978
-	| host DOT ID		{ $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
987
+	| host host_sep ID	{ $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
979 988
 						  if ($$==0){
980 989
 						  	LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
981 990
 										" failure while parsing host\n");
982 991
 						  }else{
983
-						  	memcpy($$, $1, strlen($1));
984
-						  	$$[strlen($1)]='.';
985
-						  	memcpy($$+strlen($1)+1, $3, strlen($3));
986
-						  	$$[strlen($1)+1+strlen($3)]=0;
992
+							memcpy($$, $1, strlen($1));
993
+							$$[strlen($1)]=*$2;
994
+							memcpy($$+strlen($1)+1, $3, strlen($3));
995
+							$$[strlen($1)+1+strlen($3)]=0;
987 996
 						  }
988 997
 						  pkg_free($1); pkg_free($3);
989 998
 						}