[clang] Fix filename parsing in clang-format-diff.py for paths with spaces (PR #135779)

Selim Keles via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 17 23:04:25 PDT 2025


https://github.com/selimkeles updated https://github.com/llvm/llvm-project/pull/135779

>From 92e47b84df20351e644deb38c8fc4c5d56a7e73f Mon Sep 17 00:00:00 2001
From: "selim.keles" <Selim.Keles at landisgyr.com>
Date: Fri, 18 Apr 2025 09:01:59 +0300
Subject: [PATCH] Fix filename parsing in clang-format-diff.py for paths with
 spaces

---
 clang/tools/clang-format/clang-format-diff.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py
index c82b41e8bd031..3059982ba231f 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -102,7 +102,7 @@ def main():
     filename = None
     lines_by_file = {}
     for line in sys.stdin:
-        match = re.search(r"^\+\+\+\ (.*?/){%s}(\S*)" % args.p, line)
+        match = re.search(r"^\+\+\+\ (.*?/){%s}(.+)" % args.p, line.rstrip())
         if match:
             filename = match.group(2)
         if filename is None:



More information about the cfe-commits mailing list