This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix patch mangling with --inline option in mklog


Diego,

I noticed that a patch processed with mklog --inline got mangled.

In mklog, first we read the .diff file into array diff_lines. Then, in the case of --inline, at the end we expect diff_lines still to contain the .diff file. That's not the case however, and that causes the mangling.

The patch fixes this by copying the diff_lines before processing, and using the copy at the end to reproduce the .diff file.

Committed as obvious.

Thanks,
- Tom
2014-11-14  Tom de Vries  <tom@codesourcery.com>

	* mklog: Move reading of .diff file up and add comment.  Copy diff_lines
	to orig_diff_lines.  Use orig_diff_lines when appending patch.
---
 contrib/mklog | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/contrib/mklog b/contrib/mklog
index 8412d38..840f6f8 100755
--- a/contrib/mklog
+++ b/contrib/mklog
@@ -132,15 +132,23 @@ sub is_top_level {
 	return $function && $function !~ /^[\s{]/;
 }
 
+# Read contents of .diff file
+open (DFILE, $diff) or die "Could not open file $diff for reading";
+chomp (my @diff_lines = <DFILE>);
+close (DFILE);
+
+# Array diff_lines is modified by the log generation, so save a copy in
+# orig_diff_lines if needed.
+if ($inline) {
+    @orig_diff_lines = @diff_lines;
+}
+
 # For every file in the .diff print all the function names in ChangeLog
 # format.
 %cl_entries = ();
 $change_msg = undef;
 $look_for_funs = 0;
 $clname = get_clname('');
-open (DFILE, $diff) or die "Could not open file $diff for reading";
-chomp (my @diff_lines = <DFILE>);
-close (DFILE);
 $line_idx = 0;
 foreach (@diff_lines) {
     # Stop processing functions if we found a new file.
@@ -313,7 +321,7 @@ foreach my $clname (keys %cl_entries) {
 
 if ($inline) {
 	# Append the patch to the log
-	foreach (@diff_lines) {
+	foreach (@orig_diff_lines) {
 		print OUTPUTFILE "$_\n";
 	}
 }
-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]