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