From 6313308d7e61d4e89a520081f7103da7a39cd90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Lebrun?= Date: Fri, 4 Oct 2024 11:11:39 +0200 Subject: [PATCH] script.sh: parse-defs: C: index defs that have a CONFIG_ in their line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Take the pm_ptr() macro as example: ⟩ ctags -x --kinds-c=+p+x --extras='-{anonymous}' include/linux/pm.h | grep pm_ptr pm_ptr macro 475 include/linux/pm.h #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr)) The previous grep would remove the pm_ptr() line because it contains CONFIG_. We only want to remove a line if it starts with CONFIG_. Testing this commit: ⟩ export LXR_REPO_DIR=... ⟩ hash=97b0e23363c8283f53c361d8129ef90d7a2b9350 ⟩ ./script.sh parse-defs $hash pm.h C | sort > /tmp/defs-pm-before.txt ⟩ # TODO: apply commit ⟩ ./script.sh parse-defs $hash pm.h C | sort > /tmp/defs-pm-after.txt ⟩ comm -13 /tmp/defs-pm-before.txt /tmp/defs-pm-after.txt pm_ptr macro 475 pm_sleep_ptr macro 476 Signed-off-by: Théo Lebrun --- script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.sh b/script.sh index 011e0956..7f2cef07 100755 --- a/script.sh +++ b/script.sh @@ -166,7 +166,7 @@ parse_defs_C() # Use ctags to parse most of the defs ctags -x --kinds-c=+p+x --extras='-{anonymous}' "$full_path" | - grep -avE "^operator |CONFIG_" | + grep -avE -e "^operator " -e "^CONFIG_" | awk '{print $1" "$2" "$3}' # Parse function macros, e.g., in .S files