prepare-ChangeLog.pl revision 9243
12251N/A# -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 2 -*- 12248N/A# Perl script to create a ChangeLog entry with names of files 12248N/A# and functions from a cvs diff. 12248N/A# Darin Adler <darin@eazel.com>, started 20 April 2000 12248N/A# Java support added by Maciej Stachowiak <mjs@eazel.com> 12248N/A# Multiple ChangeLog support added by Laszlo (Laca) Peter <laca@sun.com> 12248N/A# (Someone put a license in here, like maybe GPL.) 12248N/A# Provide option to put new ChangeLog into a separate file 12248N/A# instead of editing the ChangeLog. 12248N/A# For new files, just say "New file" instead of listing 12248N/A# List functions that have been removed too. 12248N/A# Decide what a good logical order is for the changed files 12248N/A# other than a normal text "sort" (top level first?) 12248N/A# (group directories?) (.h before .c?) 12248N/A# Leave a diff file behind if asked, but in unified format. 12248N/A# Handle C++ and yacc source files too (other languages?). 12248N/A# Help merge when there are ChangeLog conflicts or if there's 12248N/A# already a partly written ChangeLog entry. 12248N/A# Add command line option to put the ChangeLog into a separate 12248N/A# file or just spew it out stdout. 12248N/A# Figure out how to allow -z options from .cvsrc to work without 12248N/A# letting other bad options work. Currently the -f disables 12248N/A# Add CVS version numbers for each file too (can't do that until 12248N/A# the changes are checked in, though). 12248N/A# Work around diff stupidity where deleting a function that starts 12248N/A# with a comment makes diff think that the following function 12251N/A# has been changed (if the following function starts with a comment 12251N/A# with the same first line, such as /**) 12248N/A# Work around diff stupidity where deleting an entire function and 12248N/A# the blank lines before it makes diff think you've changed the 12248N/A die "There is not known revision system.\n" 12248N/A open ERRORS,
"cvs update $logname |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
12248N/A open ERRORS,
"svn update $logname |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
12248N/A# For each file, build a list of modified lines. 12248N/A# Use line numbers from the "after" side of each diff. 12248N/A open DIFF,
"cvs -fq diff -N |" or die "The cvs diff failed: $OS_ERROR.\n";
12248N/A open DIFF,
"svn --non-interactive diff --diff-cmd diff -x \"-b\" |" or die "The cvs diff failed: $OS_ERROR.\n";
12248N/A# For each ".c" file, convert line range to function list. 12248N/Aprint STDERR " Extracting affected function names from C source files.\n";
12248N/A # An empty function list still indicates that something changed. 12248N/A # Only look for function names in .c files. 12248N/A # Find all the functions in the file. 12248N/A # Find all the modified functions. 12248N/A # Advance to successive change ranges. 12248N/A # If past this function, move on to the next one. 12248N/A # If an overlap with this function range, record the function name. 12248N/A # Format the list of functions now. 12248N/A# Write out a new ChangeLog file. 12248N/A ||
"set REAL_NAME environment variable";
12248N/A ||
"set EMAIL_ADDRESS environment variable";
12248N/A # It's less efficient to read the whole thing into memory than it would be 12248N/A # to read it while we prepend to it later, but I like doing this part first. print STDERR " Done editing ${chlog}/ChangeLog.\n";
#FIXME write a function to extract from .cs files # Read a file and get all the line ranges of the things that look like C functions. # A function name is the last word before an open parenthesis before the outer # level open brace. A function starts at the first character after the last close # brace or semicolon before the function name and ends at the close brace. # Comment handling is simple-minded but will work for all but pathological cases. # Result is a list of triples: [ start_line, end_line, function_name ]. # Handle continued multi-line comment. # Handle continued macro. # Handle start of macro (or any preprocessor directive). # Handle comments and quoted text. while (m-(/\*|//|\
'|\")-) # \' and \" keep emacs perl mode happy warn "mismatched quotes at line $INPUT_LINE_NUMBER in $file_name\n";
while (m-(\w+|[(){};])-g)
# Promote potiential name to real function name at the # start of the outer level set of braces (function body?). # End of an outer level set of braces. # This could be a function body. warn "mismatched braces in $file_name\n" if $
in_braces;
# Read a file and get all the line ranges of the things that look like Java # classes, interfaces and methods. # A class or interface name is the word that immediately follows # `class' or `interface' when followed by an open curly brace and not # a semicolon. It can appear at the top level, or inside another class # or interface block, but not inside a function block # A class or interface starts at the first character after the first close # brace or after the function name and ends at the close brace. # A function name is the last word before an open parenthesis before # an open brace rather than a semicolon. It can appear at top level or # inside a class or interface block, but not inside a function block. # A function starts at the first character after the first close # brace or after the function name and ends at the close brace. # Comment handling is simple-minded but will work for all but pathological cases. # Result is a list of triples: [ start_line, end_line, function_name ]. # Handle continued multi-line comment. # Handle continued macro. # Handle start of macro (or any preprocessor directive). # Handle comments and quoted text. while (m-(/\*|//|\
'|\")-) # \' and \" keep emacs perl mode happy warn "mismatched quotes at line $INPUT_LINE_NUMBER in $file_name\n";
while (m-(\w+|[(){};])-g)
# Promote potiential name to real function name at the # End of an outer level set of braces. # This could be a function body. if ($
1 eq "class" or $
1 eq "interface") {
warn "mismatched braces in $file_name\n" if $
in_braces;