info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: tools for deleting the expanded $Log$ comments


From: David
Subject: RE: tools for deleting the expanded $Log$ comments
Date: Thu, 7 Aug 2003 09:57:17 +0200

Zieg,

Thanks for your code, I have tested we the example file I am sending to you,
but it prints me the followin message: "No RCS-formatted logs were found!" I
don't know why because I have such logs comments.

I have tested it under:

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 631 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 17:16:22 Jan  2 2002

Thanks in advance for any help,

David


-----Mensaje original-----
De: Zieg, Mark [mailto:address@hidden
Enviado el: miƩrcoles, 06 de agosto de 2003 15:08
Para: David; Info-Cvs
Asunto: RE: tools for deleting the expanded $Log$ comments


> I would like to know if there is a tools (in perl for example)
> that delete all the $Log$ expanded comments. Sometimes it is
> useful because your classes have revisions for a given project,
> but if you decide to eliminate from all your code the inserted
> log comments for a given new revision, or because your are using
> your class on another project.

Yuck...but I've been there.  It's an ugly situation, but sometimes
management comes up with pretty ugly mandates.

You may need to tweak this to work on your coding/comment conventions, but
it worked on a bit of C code I ran it against:

#!/usr/bin/perl -w
############################################################################
####
#
#
#                               StripRcsLog.pl
#
#
#
############################################################################
####
#
#
#  Description:    Attempts to strip RCS/CVS-inserted "$Log$" comments from
a  #
#                  text file.
#
#
#
#  Author:         Mark Zieg <address@hidden>
#
#
#
#  Usage:          StripRcsLog.pl < commented.c > stripped.c
#
#
#
#  WARNING:        THIS IS DANGEROUS.  The algorithm is not foolproof.
#
#                  Manual verification of cleaned code is highly
recommended!  #
#                  (Of course, you'd only be using this script if you kept
#
#                  all your code under revision-control...:-)
#
#
#
############################################################################
####

MAIN:
{
    my $State = "BEFORE_LOG";
    my $Prefix;
    while( my $Line = <STDIN> )
    {
        if( $State eq "BEFORE_LOG" )
        {
            if( $Line =~ /^(.*)\$Log.*\$/ )
            {
                $State = "IN_LOG";
                $Prefix = $1;
                $Prefix =~ s/\*/\\*/g;  # If you understand the need for
this,
            }                           # you get your Perl badge for the
day!
            else
            {
                print $Line;
            }
        }
        elsif( $State eq "IN_LOG" )
        {
            if( $Line =~ /^$Prefix/ )
            {
                # looks like a follow-on log line;
                # do nothing, and thus delete line
            }
            else
            {
                # looks like the prefix has changed, so
                # assUme we've ended the log section
                print $Line;
                $State = "AFTER_LOG";
            }
        }
        elsif( $State eq "AFTER_LOG" )
        {
            print $Line;
        }
        else
        {
            die( "Invalid state: $State\n" );
        }
    }
    if( $State eq "BEFORE_LOG" )
    {
        warn( "No RCS-formatted logs were found!" );
    }
    elsif( $State eq "IN_LOG" )
    {
        warn( "The log parser consumed the entire file!  Probable script
error!" );
    }
}

Attachment: DynamicInstance.java
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]