Skip to contentSkip to conversation

lttng-gen-tp: Fix include guard name with file using non valid characters

PATCH Mathieu Desnoyers 1 participant 1 message Jun 17, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 2 lines · * Yannick Brosseau ([email protected]) wrote:

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

merged in:
- master
- stable 2.2, 2.1, 2.0.

I also merged that commit into stable-2.0 so the current commit applies:

commit f1d29bdce822f8432965b2db23d46ef79d2691a9

Author: Mathieu Desnoyers <[email protected]>
Date:   Thu Dec 13 15:05:26 2012 -0500

Cleanup lttng-gen-tp: remove leading underscore before include guard

Fixes #298

Thanks,

Mathieu

Quoted 26 lines

Fixes #511

---
 tools/lttng-gen-tp |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lttng-gen-tp +3 -1
index 2f468cb..5937dfd 100755
@@ -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,
Signature · 1 line
1.7.10.4
Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com