diff options
author | vries <vries@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-22 12:53:12 +0000 |
---|---|---|
committer | vries <vries@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-22 12:53:12 +0000 |
commit | 3979f78787bdc6db3e1679b6015a1a403bb097ba (patch) | |
tree | 1ae3d197ce1099784db5d7f46d3bb7466904f7e1 /contrib | |
parent | 2fcf7a6575be1fd5ea64d747c6b3fe5b729841d1 (diff) | |
download | gcc-3979f78787bdc6db3e1679b6015a1a403bb097ba.tar.gz |
Add --inline option to contrib/mklog
2014-09-22 Tom de Vries <tom@codesourcery.com>
* mklog: Add --inline option.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215462 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/ChangeLog | 4 | ||||
-rwxr-xr-x | contrib/mklog | 48 |
2 files changed, 49 insertions, 3 deletions
diff --git a/contrib/ChangeLog b/contrib/ChangeLog index d9ab9015fc3..f7cb37e9aab 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,7 @@ +2014-09-22 Tom de Vries <tom@codesourcery.com> + + * mklog: Add --inline option. + 2014-09-19 Segher Boessenkool <segher@kernel.crashing.org> * dg-extract-results.py (Prog.result_re): Include options in test name. diff --git a/contrib/mklog b/contrib/mklog index 3d17dc54891..6ed4c6e8f51 100755 --- a/contrib/mklog +++ b/contrib/mklog @@ -26,6 +26,9 @@ # Author: Diego Novillo <dnovillo@google.com> and # Cary Coutant <ccoutant@google.com> +use File::Temp; +use File::Copy qw(cp mv); + # Change these settings to reflect your profile. $username = $ENV{'USER'}; $name = `finger $username | grep -o 'Name: .*'`; @@ -56,14 +59,22 @@ if (-d "$gcc_root/.git") { # Program starts here. You should not need to edit anything below this # line. #----------------------------------------------------------------------------- -if ($#ARGV != 0) { +$inline = 0; +if ($#ARGV == 1 && ("$ARGV[0]" eq "-i" || "$ARGV[0]" eq "--inline")) { + shift; + $inline = 1; +} elsif ($#ARGV != 0) { $prog = `basename $0`; chop ($prog); print <<EOF; -usage: $prog file.diff +usage: $prog [ -i | --inline ] file.diff Generate ChangeLog template for file.diff. It assumes that patch has been created with -up or -cp. +When -i is used, the ChangeLog template is followed by the contents of +file.diff. When file.diff is -, read standard input. +When -i is used and file.diff is not -, it writes to file.diff, otherwise it +writes to stdout. EOF exit 1; } @@ -273,8 +284,39 @@ foreach (@diff_lines) { # functions. $cl_entries{$clname} .= $change_msg ? "$change_msg\n" : ":\n"; +if ($inline && $diff ne "-") { + # Get a temp filename, rather than an open filehandle, because we use + # the open to truncate. + $tmp = mktemp("tmp.XXXXXXXX") or die "Could not create temp file: $!"; + + # Copy the permissions to the temp file (in File::Copy module version + # 2.15 and later). + cp $diff, $tmp or die "Could not copy patch file to temp file: $!"; + + # Open the temp file, clearing contents. + open (OUTPUTFILE, '>', $tmp) or die "Could not open temp file: $!"; +} else { + *OUTPUTFILE = STDOUT; +} + +# Print the log foreach my $clname (keys %cl_entries) { - print "$clname:\n\n$hdrline\n\n$cl_entries{$clname}\n"; + print OUTPUTFILE "$clname:\n\n$hdrline\n\n$cl_entries{$clname}\n"; +} + +if ($inline) { + # Append the patch to the log + foreach (@diff_lines) { + print OUTPUTFILE "$_\n"; + } +} + +if ($inline && $diff ne "-") { + # Close $tmp + close(OUTPUTFILE); + + # Write new contents to $diff atomically + mv $tmp, $diff or die "Could not move temp file to patch file: $!"; } exit 0; |