codeformat: Do search&replace without sed

This commit is contained in:
Jeff Epler 2021-03-15 19:22:48 -05:00
parent d3bf1fe15d
commit b9a973c8e0
1 changed files with 4 additions and 2 deletions

View File

@ -99,6 +99,10 @@ def fixup_c(filename):
# Get next line.
l = lines.pop(0)
# Revert "// |" back to "//| "
if l.startswith("// |"):
l = "//|" + l[4:]
# Dedent #'s to match indent of following line (not previous line).
m = re.match(r"( +)#(if |ifdef |ifndef |elif |else|endif)", l)
if m:
@ -167,8 +171,6 @@ def main():
batch(command, lang_files(C_EXTS))
for file in lang_files(C_EXTS):
fixup_c(file)
# Revert "// |" back to "//|"
batch(["sed", "-i", "s,^// |,//|,"], lang_files(C_EXTS))
# Format Python files with black.
if format_py: