external tool to remove embedded filenames

From: Joe Perches
Date: Thu Oct 01 2020 - 14:47:17 EST


It's rather unnecessary for files to contain their
path/filename in source code comments.

Here's a trivial little script that can remove
embedded filenames in c90 style comments from files.

This requires git.

It does the following types of removals:

remove individual lines like /* filename */ completely
remove filename from /* filename -- comment */, leave /* comment */
remove filename and any trailing ' *\n' from /* filename, leave /*
remove filename from /* filename, leave /*
remove filename from continuation ' * filename -- comment' leave ' * comment'
remove filename and any trailing ' *\n' from continuation ' * filename\n *\n'

It seems to work well enough.

It does not handle c99 comments.
No // filename variants are removed.

Running it on today's -next gives:

$ perl remove_embedded_filenames.pl
$ git diff --shortstat
2310 files changed, 354 insertions(+), 4239 deletions(-)

It's also possible to give any filename or path
as an argument to the script

For instance:

$ perl remove_embedded_filenames.pl drivers/net

Attachment: remove_embedded_filenames.pl
Description: Perl program