[Numpy-svn] r3326 - trunk/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Oct 13 13:45:55 CDT 2006


Author: oliphant
Date: 2006-10-13 13:45:44 -0500 (Fri, 13 Oct 2006)
New Revision: 3326

Modified:
   trunk/numpy/core/src/multiarraymodule.c
Log:
Add fix so that '()type' is detected

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-10-13 18:18:18 UTC (rev 3325)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-10-13 18:45:44 UTC (rev 3326)
@@ -4686,22 +4686,35 @@
 	return NULL;
 }
 
+#define _chk_byteorder(arg) (arg == '>' || arg == '<' ||        \
+                             arg == '|' || arg == '=')
+
 static int
 _check_for_commastring(char *type, int len)
 {
 	int i;
 
+        /* Check for ints at start of string */
 	if ((type[0] >= '0' && type[0] <= '9') ||
-            ((len > 1) && (type[0] == '>' || type[0] == '<' ||  \
-                           type[0] == '|' || type[0] == '=') && \
+            ((len > 1) && _chk_byteorder(type[0]) && 
              (type[1] >= '0' && type[1] <= '9')))
                 return 1;
+
+        /* Check for empty tuple */
+        if (((len > 1) && (type[0] == '(' && type[1] == ')')) ||
+            ((len > 3) && _chk_byteorder(type[0]) && 
+             (type[1] == '(' && type[2] == ')')))
+                return 1;
+             
+        /* Check for presence of commas */
 	for (i=1;i<len;i++)
 		if (type[i] == ',') return 1;
 
         return 0;
 }
 
+#undef _chk_byteorder
+
 /*
    any object with
    the .fields attribute and/or .itemsize attribute



More information about the Numpy-svn mailing list