[PATCH] Don't use args to XINT_OR_CHAR where multiple evaluation is possible; revise X_I_O_C to not multiply evaluate

Aidan Kehoe kehoea at parhasard.net
Tue Aug 21 16:32:24 EDT 2007




src/ChangeLog addition:

2007-08-21  Aidan Kehoe  <kehoea at parhasard.net>

	* mule-ccl.c (ccl_driver):
	Don't pass XCHAR_OR_INT an argument of which the evaluation has 
	side effects; thank you Mike Fabian. 
	* lisp.h: 
	Redundantly, don't multiply evaluate the argument to XCHAR_OR_INT; 
	this should prevent the same error in the future. 


XEmacs Trunk source patch:
Diff command:   cvs -q diff -Nu
Files affected: src/lisp.h
===================================================================
RCS src/mule-ccl.c
===================================================================
RCS

Index: src/mule-ccl.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/mule-ccl.c,v
retrieving revision 1.33
diff -u -u -r1.33 mule-ccl.c
--- src/mule-ccl.c	2007/07/26 11:15:08	1.33
+++ src/mule-ccl.c	2007/08/21 20:28:29
@@ -1578,7 +1578,7 @@
 		Lisp_Object map, content, attrib, value;
 		int point, size, fin_ic;
 
-		j = XCHAR_OR_INT (ccl_prog[ic++]); /* number of maps. */
+		j = XCHAR_OR_INT (ccl_prog[ic]); ic++; /* number of maps. */
 		fin_ic = ic + j;
 		op = reg[rrr];
 		if ((j > reg[RRR]) && (j >= 0))
@@ -1693,7 +1693,7 @@
 		stack_idx_of_map_multiple = 0;
 
 		map_set_rest_length =
-		  XCHAR_OR_INT (ccl_prog[ic++]); /* number of maps and separators. */
+		  XCHAR_OR_INT (ccl_prog[ic]); ic++; /* number of maps and separators. */
 		fin_ic = ic + map_set_rest_length;
 		op = reg[rrr];
 
@@ -1880,7 +1880,7 @@
 	      {
 		Lisp_Object map, attrib, value, content;
 		int size, point;
-		j = XCHAR_OR_INT (ccl_prog[ic++]); /* map_id */
+		j = XCHAR_OR_INT (ccl_prog[ic]); ic++;/* map_id */
 		op = reg[rrr];
 		if (j >= XVECTOR (Vcode_conversion_map_vector)->size)
 		  {
Index: src/lisp.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/lisp.h,v
retrieving revision 1.147
diff -u -u -r1.147 lisp.h
--- src/lisp.h	2007/08/17 08:04:27	1.147
+++ src/lisp.h	2007/08/21 20:28:31
@@ -2890,7 +2890,15 @@
 
 #else /* no error checking */
 
-#define XCHAR_OR_INT(obj) (CHARP (obj) ? XCHAR (obj) : XINT (obj))
+/* obj is multiply eval'ed and not an lvalue; use an inline function instead
+   of a macro. */
+DECLARE_INLINE_HEADER (
+EMACS_INT
+XCHAR_OR_INT (Lisp_Object obj)
+)
+{
+  return CHARP (obj) ? XCHAR (obj) : XINT (obj);
+}
 
 #endif /* no error checking */
 

-- 
On the quay of the little Black Sea port, where the rescued pair came once
more into contact with civilization, Dobrinton was bitten by a dog which was
assumed to be mad, though it may only have been indiscriminating. (Saki)



More information about the XEmacs-Patches mailing list