script.sh: parse-defs: C: index defs that have a CONFIG_ in their line

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 <theo.lebrun@bootlin.com>
This commit is contained in:
Théo Lebrun 2024-10-04 11:11:39 +02:00 committed by tleb
parent fc8106d520
commit 0e846ccd6e

View file

@ -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