[RFC] Ignore source code comments in scripts/check-installed-headers.sh

Message ID 20190116230545.8745-1-tuliom@linux.ibm.com
State New
Headers show
Series
  • [RFC] Ignore source code comments in scripts/check-installed-headers.sh
Related show

Commit Message

Tulio Magno Quites Machado Filho Jan. 16, 2019, 11:05 p.m.
DJ Delorie <dj@redhat.com> writes:

> I think ignoring comments is the right way to go, else we can't allow a

> comment like:

>

>   /* Don't use ulong here, it's obsolete.  */

>

> I don't ever think it's a good idea for commentary to limit technical

> choice.

>

> I won't comment on how hard expanding a regex might be ;-)


Or we could reuse the preprocessor to do that for us... ;-)

Carlos, could you test if this works in the case you found, please?

---8<---

Use the preprocessor to remove source code comments from header files
before testing if they have any obsolete type.

2019-01-16  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>

	* scripts/check-installed-headers.sh: Pre-process header files
	before checking for obsolete types.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

---
 scripts/check-installed-headers.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.14.5

Patch

diff --git a/scripts/check-installed-headers.sh b/scripts/check-installed-headers.sh
index 8e7beffd82..291774c696 100644
--- a/scripts/check-installed-headers.sh
+++ b/scripts/check-installed-headers.sh
@@ -158,7 +158,9 @@  EOF
                     # Don't repeat work.
                     eval 'case "$h" in ('"$already"') continue;; esac'
 
-                    if grep -qE "$obsolete_type_re" "$h"; then
+                    # Use the preprocessor to remove comments in the source.
+                    if $cc_cmd -E -fpreprocessed "$h" -o - \
+                               | grep -qE "$obsolete_type_re"; then
                         echo "*** Obsolete types detected:"
                         grep -HE "$obsolete_type_re" "$h"
                         failed=1