Commits

Takafumi Arakaki  committed 0440aa3

cdata.cddec_idx_parse can parse array index with evil spaces now

  • Participants
  • Parent commits b443cbe

Comments (0)

Files changed (2)

File railgun/cdata.py

     else:
         stripped = idxtr.strip('[]')  # "i][j][k" or "i,j,k"
         if "," in stripped:
-            return (tuple(stripped.split(",")), "flat")
+            return (tuple(s.strip() for s in stripped.split(",")), "flat")
         else:
-            return (tuple(stripped.split('][')), "iliffe")
+            return (tuple(s.strip() for s in stripped.split('][')), "iliffe")
 
 
 cddec_parse = _CDataDeclaration.from_string

File tests/test_cdata.py

     ("int aA1", dict_cdec_parse('int', 'aA1')),
     ("int a[i]", dict_cdec_parse('int', 'a', tuple('i'), 1)),
     ("int a[i][j]", dict_cdec_parse('int', 'a', tuple('ij'), 2)),
+    ("int a[ i ][ j][k ]", dict_cdec_parse('int', 'a', tuple('ijk'), 3)),
     ("int a = 1", dict_cdec_parse('int', 'a', default=1)),
     ("int a[i] =2", dict_cdec_parse('int', 'a', tuple('i'), 1, 2)),
     ("int a[i][j]=3", dict_cdec_parse('int', 'a', tuple('ij'), 2, 3)),
                                    carrtype="flat")),
     ("int a[i,j]=3", dict_cdec_parse('int', 'a', tuple('ij'), 2, 3,
                                      carrtype="flat")),
+    ("int a[ i , j,k ]", dict_cdec_parse('int', 'a', tuple('ijk'), 3,
+                                         carrtype="flat")),
     ('num_i = 10', dict_cdec_parse('int', 'num_i', default=10)),
     (cmem(DmyCDT, 'obj'), dict_cdec_parse(DmyCDT, 'obj', valtype='object')),
     ]