diff options
Diffstat (limited to 'tools/mhmake/addstdafxh.py')
-rwxr-xr-x | tools/mhmake/addstdafxh.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/mhmake/addstdafxh.py b/tools/mhmake/addstdafxh.py new file mode 100755 index 000000000..45413a474 --- /dev/null +++ b/tools/mhmake/addstdafxh.py @@ -0,0 +1,33 @@ +import sys,re,os
+
+try:
+ InputFile=sys.argv[1]
+except:
+ print "No input file specified"
+ sys.exit(1)
+
+try:
+ InputFile=sys.argv[1]
+ pIN=open(InputFile,"r")
+ data=pIN.read()
+ pIN.close()
+except:
+ print "Error reading input file",InputFile
+ sys.exit(1)
+
+try:
+ pOUT=open(InputFile,"w")
+except:
+ print "Error opening",InputFile,"for writing"
+ sys.exit(1)
+
+pOUT.write("""#include "stdafx.h"\n""")
+#since we are going to add one line we need to update all line statements
+def IncrementLine(matchobj):
+ return "#line %d%s"%(int(matchobj.group(1))+1,matchobj.group(2))
+
+data=re.sub(r"#\s*line\s+(\d+)(.*%s)"%os.path.split(InputFile)[1],IncrementLine,data)
+
+pOUT.write(data)
+pOUT.close()
+
|