[RFC] Ignore source code comments in scripts/check-installed-headers.sh
Commit Message
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(-)
@@ -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