@@ -1545,19 +1545,20 @@ def reorder_(self,resolvable,x_requires,orig_x_requires,fnptr_types):
15451545 # intersect the original x_requires[o] with current resolvable set
15461546 # if this is empty, add it because we have no direct uses and any typedef'd struct is fwd declared
15471547 direct_unresolved = list (resolvable & reduced_x_requires [o ])
1548- using_others = any ([x in reduced_x_requires [o ] for x in (not_o )]) if not_o is not None else False
1549- dprint (f"DEBUG: CHECK(0): direct_unresolved=> { direct_unresolved } " )
1548+ dprint (f"DEBUG: CHECK(0) for { o } : direct_unresolved=> { direct_unresolved } [reduced_x_requires: { reduced_x_requires [o ]} ]" )
15501549 if o in reduced_x_requires [o ]:
15511550 if o in direct_unresolved and o in initial_x_requires [o ]:
1552- # let's put self-referencing type declarations at the end
1553- dprint (f"DEBUG: FOURTH: { o } [{ x_requires [o ]} ] => { direct_unresolved } [{ initial_x_requires [o ]} ]" )
1551+ if len (direct_unresolved )> 1 :
1552+ # let's put self-referencing type declarations that depend on other unresolved types at the end
1553+ dprint (f"DEBUG: FOURTH(1): { o } [{ x_requires [o ]} ] => { direct_unresolved } [{ initial_x_requires [o ]} ]" )
15541554 fourth .append (o )
1555- elif not using_others :
1556- first .insert (0 ,o )
1557- dprint (f"DEBUG: FIRST(1): { o } [{ x_requires [o ]} ] => { direct_unresolved } [{ initial_x_requires [o ]} ]" )
1555+ else :
1556+ dprint (f"DEBUG: FOURTH(2): { o } [{ x_requires [o ]} ] => { direct_unresolved } [{ initial_x_requires [o ]} ]" )
1557+ fourth .insert (0 ,o )
1558+
15581559 else :
15591560 first .append (o )
1560- dprint (f"DEBUG: FIRST(2) : { o } [{ x_requires [o ]} ] => { direct_unresolved } [{ initial_x_requires [o ]} ]" )
1561+ dprint (f"DEBUG: FIRST: { o } [{ x_requires [o ]} ] => { direct_unresolved } [{ initial_x_requires [o ]} ]" )
15611562
15621563 elif len (direct_unresolved )== 0 :
15631564 dprint (f"DEBUG: SECOND: { o } [{ x_requires [o ]} ] => { direct_unresolved } [{ initial_x_requires [o ]} ]" )
@@ -2380,10 +2381,11 @@ def replace_stubs(self, output, stubMap):
23802381 return output
23812382
23822383 def prevent_glibc_collision (self ,inlines ,glibc_funcs ):
2383- stdio_fns = '|' .join (glibc_funcs )
2384+ stdio_fns = '|' .join ([ re .escape (g ) for g in glibc_funcs ])
2385+
23842386 #print(f"STDIO_FNS: ({stdio_fns})")
23852387 #GLIBC_XFORM_PREFIX
2386- stdio_re = re .compile (r"\b" + f"({ stdio_fns } )" + r"\b" )
2388+ stdio_re = re .compile (r'\b' + f"({ stdio_fns } )" + r'\b' )
23872389
23882390 return [
23892391 re .sub (r"(?<!->)\b" + f"(?<!\.)({ stdio_fns } )" + r"\b" ,GLIBC_XFORM_PREFIX + r"\1" ,i )
0 commit comments