[Scipy-svn] r2972 - trunk/Lib/sandbox/numexpr

scipy-svn@scip... scipy-svn@scip...
Mon May 7 11:24:39 CDT 2007


Author: cookedm
Date: 2007-05-07 11:24:37 -0500 (Mon, 07 May 2007)
New Revision: 2972

Modified:
   trunk/Lib/sandbox/numexpr/interpreter.c
Log:
[numexpr] fix #407: Wrong assumption of char signedness in Numexpr

Modified: trunk/Lib/sandbox/numexpr/interpreter.c
===================================================================
--- trunk/Lib/sandbox/numexpr/interpreter.c	2007-05-07 16:19:10 UTC (rev 2971)
+++ trunk/Lib/sandbox/numexpr/interpreter.c	2007-05-07 16:24:37 UTC (rev 2972)
@@ -103,7 +103,8 @@
 };
 
 /* returns the sig of the nth op, '\0' if no more ops -1 on failure */
-static int op_signature(int op, int n) {
+static int
+op_signature(int op, int n) {
     switch (op) {
         case OP_NOOP:
             break;
@@ -432,7 +433,8 @@
 
 static char
 get_return_sig(PyObject* program) {
-    char last_opcode, sig;
+    int sig;
+    char last_opcode;
     int end = PyString_Size(program);
     do {
         end -= 4;
@@ -440,8 +442,11 @@
     }
     while ((last_opcode = PyString_AS_STRING(program)[end]) == OP_NOOP);
     sig = op_signature(last_opcode, 0);
-    if (sig <= 0) return 'X';
-    return sig;
+    if (sig <= 0) {
+        return 'X';
+    } else {
+        return (char)sig;
+    }
 }
 
 static int



More information about the Scipy-svn mailing list