]> Frank Brehm's Git Trees - my-stuff/python.git/commitdiff
Some changes in klammerkomma.py
authorFrank Brehm <frank@brehm-online.com>
Tue, 18 Jun 2013 05:34:58 +0000 (07:34 +0200)
committerFrank Brehm <frank@brehm-online.com>
Tue, 18 Jun 2013 05:34:58 +0000 (07:34 +0200)
klammerkomma.py

index 9c0203884a0cd5169f0a9c734d6aa1547c11177c..ab3f4b2e785744b23872998f54e9b14a12f6c567 100755 (executable)
@@ -7,7 +7,7 @@ import re
 import shutil
 
 re_komma = re.compile(r',(\s*[\)\]\}])')
-re_cpp_comment = re.compile(r'//(.*)$')
+re_cpp_comment = re.compile(r'//(.*)([\n\r]*)$')
 
 i = 0
 for fname in sys.argv:
@@ -24,7 +24,9 @@ for fname in sys.argv:
             ifile = open(fname)
             lines = ifile.read()
             nlines = re_komma.sub(r'\1', lines)
-            os.write(ofd, nlines)
+            for single_line in nlines.splitlines(True):
+                sline = re_cpp_comment.sub(r'/*\1*/\2', single_line)
+                os.write(ofd, sline)
         finally:
             os.close(ofd)
             ifile.close()