2
0
Эх сурвалжийг харах

- fixed statements in ifs w/o {} (now if (cond) a(); else b(); should work)
- fixed debug config printing
(backports from unstable)

Andrei Pelinescu-Onciul 20 жил өмнө
parent
commit
2e789c7078
3 өөрчлөгдсөн 27 нэмэгдсэн , 6 устгасан
  1. 1 1
      Makefile.defs
  2. 8 4
      cfg.y
  3. 18 1
      route_struct.c

+ 1 - 1
Makefile.defs

@@ -59,7 +59,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 9
 SUBLEVEL = 5
-EXTRAVERSION = -pre2
+EXTRAVERSION = -pre3
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 8 - 4
cfg.y

@@ -58,6 +58,7 @@
  *              (andrei)
  * 2004-10-19  added FROM_URI, TO_URI (andrei)
  * 2004-11-30  added force_send_socket (andrei)
+ * 2005-11-16  fixed if (cond) cmd; (andrei)
  */
 
 
@@ -288,7 +289,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
 
 /*non-terminals */
 %type <expr> exp exp_elem /*, condition*/
-%type <action> action actions cmd if_cmd stm
+%type <action> action actions cmd if_cmd stm exp_stm
 %type <ipaddr> ipv4 ipv6 ipv6addr ip
 %type <ipnet> ipnet
 %type <strval> host
@@ -321,7 +322,6 @@ statement:	assign_stm
 		| {rt=REQUEST_ROUTE;} route_stm 
 		| {rt=FAILURE_ROUTE;} failure_route_stm
 		| {rt=ONREPLY_ROUTE;} onreply_route_stm
-
 		| CR	/* null statement*/
 	;
 
@@ -960,7 +960,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem(	$2, STRING_ST,
 		| MYSELF error	{ $$=0; 
 							yyerror ("invalid operator, == or != expected");
 						}
-		| stm				{ $$=mk_elem( NO_OP, ACTIONS_ST, ACTION_O, $1 ); }
+		| exp_stm			{ $$=mk_elem( NO_OP, ACTIONS_ST, ACTION_O, $1 );  }
 		| NUMBER		{$$=mk_elem( NO_OP, NUMBER_ST, NUMBER_O, (void*)$1 ); }
 	;
 
@@ -1005,11 +1005,15 @@ host:	ID				{ $$=$1; }
 	;
 
 
-stm:		cmd						{ $$=$1; }
+exp_stm:	cmd						{ $$=$1; }
 		|	if_cmd					{ $$=$1; }
 		|	LBRACE actions RBRACE	{ $$=$2; }
 	;
 
+stm:		action					{ $$=$1; }
+		|	LBRACE actions	RBRACE	{ $$=$2; }
+	;
+
 actions:	actions action	{$$=append_action($1, $2); }
 		| action			{$$=$1;}
 		| actions error { $$=0; yyerror("bad command"); }

+ 18 - 1
route_struct.c

@@ -162,10 +162,12 @@ void print_expr(struct expr* exp)
 			case DSTIP_O:
 				DBG("dstip");
 				break;
+			case DSTPORT_O:
+				DBG("dstport");
+				break;
 			case NUMBER_O:
 				break;
 			case ACTION_O:
-				print_action((struct action*) exp->r.param);
 				break;
 			default:
 				DBG("UNKNOWN");
@@ -179,6 +181,21 @@ void print_expr(struct expr* exp)
 				break;
 			case NO_OP:
 				break;
+			case GT_OP:
+				DBG(">");
+				break;
+			case GTE_OP:
+				DBG(">=");
+				break;
+			case LT_OP:
+				DBG("<");
+				break;
+			case LTE_OP:
+				DBG("<=");
+				break;
+			case DIFF_OP:
+				DBG("!=");
+				break;
 			default:
 				DBG("<UNKNOWN>");
 		}