[lttng-dev] [LTTng-UST PATCH] lttng-gen-tp: Fix include guard name with file using non valid characters

Yannick Brosseau yannick.brosseau at gmail.com
Mon Jun 17 12:03:11 EDT 2013


Now, the include guard will be generated with all the non
alpha-numeric characters replace with an '_'

Fixes #511

Signed-off-by: Yannick Brosseau <yannick.brosseau at gmail.com>
---
 tools/lttng-gen-tp |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lttng-gen-tp b/tools/lttng-gen-tp
index 2f468cb..5937dfd 100755
--- a/tools/lttng-gen-tp
+++ b/tools/lttng-gen-tp
@@ -61,7 +61,9 @@ extern "C"{{
 
     def write(self):
         outputFile = open(self.outputFilename,"w")
-        includeGuard = self.outputFilename.upper().replace(".","_")
+        # Include guard macro will be created by uppercasing the filename and
+        # replacing all non alphanumeric characters with '_'
+        includeGuard = re.sub('[^0-9a-zA-Z]', '_', self.outputFilename.upper())
 
         outputFile.write(HeaderFile.HEADER_TPL.format(providerName=self.template.domain,
                                            includeGuard = includeGuard,
-- 
1.7.10.4




More information about the lttng-dev mailing list