[gs-cvs] rev 6975 - trunk/gs/src

alexcher at ghostscript.com alexcher at ghostscript.com
Mon Aug 7 10:26:15 PDT 2006


Author: alexcher
Date: 2006-08-07 10:26:14 -0700 (Mon, 07 Aug 2006)
New Revision: 6975

Modified:
   trunk/gs/src/interp.c
   trunk/gs/src/zcontrol.c
Log:
Makes ifelse and if operators check the type of the topmost argument before
checking other arguments.



Modified: trunk/gs/src/interp.c
===================================================================
--- trunk/gs/src/interp.c	2006-08-07 08:38:34 UTC (rev 6974)
+++ trunk/gs/src/interp.c	2006-08-07 17:26:14 UTC (rev 6975)
@@ -1012,11 +1012,11 @@
 	    next_either();
 	case plain_exec(tx_op_if):
 x_if:	    INCR(x_if);
+	    if (!r_is_proc(iosp))
+		return_with_error_tx_op(check_proc_failed(iosp));
 	    if (!r_has_type(iosp - 1, t_boolean))
 		return_with_error_tx_op((iosp <= osbot ?
 					e_stackunderflow : e_typecheck));
-	    if (!r_is_proc(iosp))
-		return_with_error_tx_op(check_proc_failed(iosp));
 	    if (!iosp[-1].value.boolval) {
 		iosp -= 2;
 		next_either();
@@ -1029,13 +1029,13 @@
 	    goto ifup;
 	case plain_exec(tx_op_ifelse):
 x_ifelse:   INCR(x_ifelse);
+	    if (!r_is_proc(iosp))
+		return_with_error_tx_op(check_proc_failed(iosp));
+	    if (!r_is_proc(iosp - 1))
+		return_with_error_tx_op(check_proc_failed(iosp - 1));
 	    if (!r_has_type(iosp - 2, t_boolean))
 		return_with_error_tx_op((iosp < osbot + 2 ?
 					e_stackunderflow : e_typecheck));
-	    if (!r_is_proc(iosp - 1))
-		return_with_error_tx_op(check_proc_failed(iosp - 1));
-	    if (!r_is_proc(iosp))
-		return_with_error_tx_op(check_proc_failed(iosp));
 	    if (iesp >= estop)
 		return_with_error_tx_op(e_execstackoverflow);
 	    store_state_either(iesp);

Modified: trunk/gs/src/zcontrol.c
===================================================================
--- trunk/gs/src/zcontrol.c	2006-08-07 08:38:34 UTC (rev 6974)
+++ trunk/gs/src/zcontrol.c	2006-08-07 17:26:14 UTC (rev 6975)
@@ -264,8 +264,8 @@
 {
     os_ptr op = osp;
 
+    check_proc(*op);
     check_type(op[-1], t_boolean);
-    check_proc(*op);
     if (op[-1].value.boolval) {
 	check_estack(1);
 	++esp;
@@ -282,9 +282,9 @@
 {
     os_ptr op = osp;
 
+    check_proc(*op);
+    check_proc(op[-1]);
     check_type(op[-2], t_boolean);
-    check_proc(op[-1]);
-    check_proc(*op);
     check_estack(1);
     ++esp;
     if (op[-2].value.boolval) {
@@ -475,8 +475,8 @@
 zrepeat(i_ctx_t *i_ctx_p)
 {
     os_ptr op = osp;
+    check_proc(*op);
     check_type(op[-1], t_integer);
-    check_proc(*op);
     if (op[-1].value.intval < 0)
 	return_error(e_rangecheck);
     check_estack(5);



More information about the gs-cvs mailing list