summaryrefslogtreecommitdiff
path: root/src/engine/SCons/cpp.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/cpp.py')
-rw-r--r--src/engine/SCons/cpp.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py
index 60484f7..ff750c2 100644
--- a/src/engine/SCons/cpp.py
+++ b/src/engine/SCons/cpp.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -21,12 +21,11 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/cpp.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/cpp.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
__doc__ = """
SCons C Pre-Processor module
"""
-#TODO 2.3 and before has no sorted()
import SCons.compat
import os
@@ -87,7 +86,7 @@ del op_list
override = {
'if' : 'if(?!def)',
}
-l = [override.get(x, x) for x in Table.keys()]
+l = [override.get(x, x) for x in list(Table.keys())]
# Turn the list of expressions into one big honkin' regular expression
@@ -130,7 +129,7 @@ CPP_to_Python_Ops_Sub = lambda m: CPP_to_Python_Ops_Dict[m.group(0)]
# re module, as late as version 2.2.2, empirically matches the
# "!" in "!=" first, instead of finding the longest match.
# What's up with that?
-l = sorted(CPP_to_Python_Ops_Dict.keys(), key=lambda a: len(a), reverse=True)
+l = sorted(list(CPP_to_Python_Ops_Dict.keys()), key=lambda a: len(a), reverse=True)
# Turn the list of keys into one regular expression that will allow us
# to substitute all of the operators at once.
@@ -266,7 +265,7 @@ class PreProcessor(object):
d = {
'scons_current_file' : self.scons_current_file
}
- for op in Table.keys():
+ for op in list(Table.keys()):
d[op] = getattr(self, 'do_' + op)
self.default_table = d
@@ -312,7 +311,7 @@ class PreProcessor(object):
t = self.tuples.pop(0)
# Uncomment to see the list of tuples being processed (e.g.,
# to validate the CPP lines are being translated correctly).
- #print t
+ #print(t)
self.dispatch_table[t[0]](t)
return self.finalize_result(fname)
@@ -379,7 +378,8 @@ class PreProcessor(object):
return None
def read_file(self, file):
- return open(file).read()
+ with open(file) as f:
+ return f.read()
# Start and stop processing include lines.
@@ -510,7 +510,7 @@ class PreProcessor(object):
t = self.resolve_include(t)
include_file = self.find_include_file(t)
if include_file:
- #print "include_file =", include_file
+ #print("include_file =", include_file)
self.result.append(include_file)
contents = self.read_file(include_file)
new_tuples = [('scons_current_file', include_file)] + \
@@ -542,12 +542,14 @@ class PreProcessor(object):
This handles recursive expansion of values without "" or <>
surrounding the name until an initial " or < is found, to handle
+
#include FILE
- where FILE is a #define somewhere else.
- """
+
+ where FILE is a #define somewhere else."""
+
s = t[1]
while not s[0] in '<"':
- #print "s =", s
+ #print("s =", s)
try:
s = self.cpp_namespace[s]
except KeyError: