tools for deleting the expanded $Log$ comments

2003-08-14 Thread David
Hello members,

I would like to know if there is a tools (in perl for example) that delete
all the $Log$ expanded comments. Sometimes it is usefull 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.

Do you have any suggestion about how to handle such situation. For example I
would like to replace the expanded comments by $Log$, becase I wanto to use
such source files on another project.

Thanks in advance,

David



___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs


RE: tools for deleting the expanded $Log$ comments

2003-08-07 Thread Zieg, Mark
> 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 <[EMAIL PROTECTED]>   #
#  #
#  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 =  )
{
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!" );
}
}


___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs


RE: tools for deleting the expanded $Log$ comments

2003-08-14 Thread Zieg, Mark
> 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.

It's because your log comments are in this form:

 begin snip 
//Source file: I:\\isf\\util\\DynamicInstance.java

/* CmIdentification

// Version History:
$Log: DynamicInstance.java,v $
Revision 1.5  2003/07/28 16:18:08  UF367151
Extension to the isf.util package, to be included on the kernel of SGCv10. Utility 
classes.



 */
 end snip 

My script was written for cases where the $Log$ tag is NOT flush left, but rather has 
some sort of character prefix to the left of the tag.  This is a sufficiently standard 
condition that RCS was designed to detect and re-insert those prefixes before every 
revision comment line.  That is, my script was designed to work for cases like this:

/*
 * Author:   $Author$
 * Revision: $Revision$
 * History:
 *   $Log$
 *   Revision 1.5  2003/07/28 16:18:08  UF36715
 *   Extension to the isf.util package, to be included 
 *   on the kernel of SGCv10. Utility classes.
 */

or this:

// Author:   $Author$
// Revision: $Revision$
// History:
//   $Log$
//   Revision 1.5  2003/07/28 16:18:08  UF36715
//   Extension to the isf.util package, to be included 
//   on the kernel of SGCv10. Utility classes.

...or something along those lines.

See, there needs to be some way of telling when the $Log$ comments STOP.  Given the 
variety of coding conventions in use, it's impossible to come up with a standard, 
failsafe way to do that.

If you want to pursue this, and if the Java source you sent was representative of your 
entire body of code, then try changing the middle block of the script from this:

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";
}
}

...to this:

elsif( $State eq "IN_LOG" )
{
if( $Line =~ /^\/\/+/ )
{
# looks like we hit one of those //... 
# separators, so assUme we've ended the log section
print $Line;
$State = "AFTER_LOG";
}
}

Beyond that, you need to find someone on your end who can help you with automated text 
processing (or order a used copy of this 
http://www.amazon.com/exec/obidos/asin/1565924622).  This has ceased to be a CVS 
discussion.


___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs


RE: tools for deleting the expanded $Log$ comments

2003-08-14 Thread David
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:[EMAIL PROTECTED]
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 <[EMAIL PROTECTED]>
#
#
#
#  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 =  )
{
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!" );
}
}


DynamicInstance.java
Description: Binary data
___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs