[C++-sig] Pyste: Thinko in CppParser.py + bug when bool(tail) == True

Christian Hudon chrish at debian.org
Tue Jul 27 20:57:32 CEST 2004


Hi,

the following patch fixes a small thinko in Pyste's CppParser.py

--- src/Pyste/CppParser.py      18 Jul 2004 15:50:10 -0000      1.11
+++ src/Pyste/CppParser.py      27 Jul 2004 16:40:17 -0000
@@ -153,7 +153,7 @@
          '''
          if tail is None:
              tail = ''
-        tail.strip()
+        tail = tail.strip()
          declarations = self.GetCache(header, interface, tail)
          if declarations is None:
              declarations = self.ParseWithGCCXML(header, tail)

The reason I found out about this is because of another bug. I'm not 
sure how best to fix it (actually, I'm not sure I understand the reason 
for the whole tail thing), so I'll just describe the bug here and let 
better minds than mine think about how best to solve it.

The problem is triggered when bool(tail) (after stripping) evaluates to 
True. Then the contents of the input C++ file is copied over to a 
temporary file (in /tmp), with the contents of tail appendede to it, and 
gccxml then works on that file. The problem is, this breaks things if 
the file does #include "someotherstuff.h". Before invoking gccxml, the 
name of the directory containing the C++ file being processed is 
prepended to the list of include directories. When bool(tail) == False 
this isn't necessary, because gccxml is working on the actual C++ file, 
not a copy in another directory. When bool(tail) == True this doesn't 
work because it adds -I /tmp, which is useless because the include files 
that were in the same directory as the C++ file being parsed weren't 
copied over to /tmp.

I can see two possible fixes. Not sure which one is better. Tell me if 
I'm missing something...

1. Prepend the directory of the original C++ file to the include path, 
not that of the copy being made in /tmp. (Unless I'm mistaken, there 
shouldn't be any need to modify the include path when we're not copying 
the file to /tmp.)

2. When bool(tail) == True, instead of copying the contents of the C++ 
file to a temporary file, create a new .h file in /tmp that contains 
#include "/full/path/to/original/cpp_file" followed then by the contents 
of tail. That way you shouldn't need to add directories to the include path.

Hope this is useful...

   Christian

PS Thanks for a great tool.



More information about the Cplusplus-sig mailing list