diff mbox series

[2/2] contrib: Fix 'invalid escape sequence' warnings in header-tools

Message ID 20240605202207.163176-2-jwakely@redhat.com
State New
Headers show
Series [1/2] contrib: Fix KeyError errors in header-tools/gcc-order-headers | expand

Commit Message

Jonathan Wakely June 5, 2024, 8:21 p.m. UTC
OK for trunk?

-- >8 --

Use raw strings so that backslashes don't need to be escaped. Otherwise
the Python interpreter warns.

contrib/header-tools/ChangeLog:

	* headerutils.py (is_pound_if, is_pound_endif): Use raw strings
	for strings containing backslashes.
	* included-by: Likewise.
---
 contrib/header-tools/headerutils.py | 6 +++---
 contrib/header-tools/included-by    | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/contrib/header-tools/headerutils.py b/contrib/header-tools/headerutils.py
index 1fb02214414..966892ad382 100755
--- a/contrib/header-tools/headerutils.py
+++ b/contrib/header-tools/headerutils.py
@@ -35,15 +35,15 @@  def find_pound_define (line):
   return ""
 
 def is_pound_if (line):
-  inc = re.findall ("^\s*#\s*if\s", line)
+  inc = re.findall (r"^\s*#\s*if\s", line)
   if not inc:
-    inc = re.findall ("^\s*#\s*if[n]?def\s", line)
+    inc = re.findall (r"^\s*#\s*if[n]?def\s", line)
   if inc:
     return True
   return False
 
 def is_pound_endif (line):
-  inc = re.findall ("^\s*#\s*endif", line)
+  inc = re.findall (r"^\s*#\s*endif", line)
   if inc:
     return True
   return False
diff --git a/contrib/header-tools/included-by b/contrib/header-tools/included-by
index b953825f0b1..f0c8eaa600c 100755
--- a/contrib/header-tools/included-by
+++ b/contrib/header-tools/included-by
@@ -61,10 +61,10 @@  if len(src) == 0:
 if not usage:
   if scanfiles:
     if process_h:
-      file_list = find_gcc_files ("\*.h", current, deeper)
+      file_list = find_gcc_files (r"\*.h", current, deeper)
     if process_c:
-      file_list = file_list + find_gcc_files ("\*.c", current, deeper)
-      file_list = file_list + find_gcc_files ("\*.cc", current, deeper)
+      file_list = file_list + find_gcc_files (r"\*.c", current, deeper)
+      file_list = file_list + find_gcc_files (r"\*.cc", current, deeper)
   else:
     newlist = list()
     for x in file_list: