开发者

Removing Keyword Substitution comments from source files?

开发者 https://www.devze.com 2023-02-11 01:53 出处:网络
Note: For wont of a better word I call the fluff at the start of source files -- /* @(#) $Id: file.c,v 1.9 2011/01/05 11:55:00 user Exp $

Note: For wont of a better word I call the fluff at the start of source files --

/* @(#) $Id: file.c,v 1.9 2011/01/05 11:55:00 user Exp $
   **************************************************************************
   * COPYRIGHT, 2005-2011                                                   *
   ...
 */

-- Keyword Substitution comments, although I do not know if this is just a subve开发者_运维技巧rsion term.

Anyway, now to the question: We have a 3rd party supplier that we get source code from. These c source all have these keyword subst comments, and every time we get a new version from the supplier, all (1000+) files are changed because they update these comments for every release they send us, even if no source code changes whatsover are made in these files, so the only change is the comments. Now, before we compile and use these sources, we would be interested in doing a cursory code review to see the areas that have been changed. (Never trust the release history). However, this is rather difficult, as doing a simple folder diff will obviously list all files.

What I'm looking for now is whether there already exist any simple tools to strip these special multi line comments from the source files. Maybe anyone has a link to a grep or sed script that will scratch that stuff from the files?


Something like:

perl -ne 'if(m+/\*.*\$Id: +) $c = 1; print unless $c; if($c && m+\*/+) $c = 0;'

Note that this will work only if

  • such comments are delimited with /*...*/
  • on the first line there is $Id:
  • there is nothing after the */
  • there is no */ before the /*

And that it will strip all lines that are between start of comment and end of comment.

I have not tested it!


First, I would try to convince them to review either their version control system (looks as if they use RCS, still?) or if that is not possible to have them hook up to a svn or git server for submitting their changes. But perhaps you already did?

If nothing in that sense is possible, I would try to set up a git repository to hold the versions that they supply to you. Git allows you to have filters when you are importing or exporting and also has support for ignoring such tags for deltas between versions.

0

精彩评论

暂无评论...
验证码 换一张
取 消