public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Improve extraction of changed file in contrib/mklog
@ 2017-07-09 19:03 Yuri Gribov
  2017-07-26 17:11 ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri Gribov @ 2017-07-09 19:03 UTC (permalink / raw)
  To: GCC Patches; +Cc: Trevor Saunders

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

Hi,

Currently mklog will fail to analyze lines like this in patches:
diff -rupN gcc/gcc/testsuite/lib/profopt.exp
gcc-compare-checks/gcc/testsuite/lib/profopt.exp
(it fails with "Error: failed to parse diff for ... and ...").

This patch fixes it. Ok for trunk?

-Y

[-- Attachment #2: mklog-filename-fix-1.patch --]
[-- Type: application/octet-stream, Size: 1114 bytes --]

2017-07-09  Yury Gribov  <tetra2005@gmail.com>

contrib/
        * mklog: Fix extraction of changed file name.

diff -rupN gcc/contrib/mklog gcc-compare-checks/contrib/mklog
--- gcc/contrib/mklog	2017-07-07 09:47:37.000000000 +0200
+++ gcc-compare-checks/contrib/mklog	2017-07-09 20:43:41.000000000 +0200
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2017 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 #
@@ -195,8 +195,20 @@ foreach (@diff_lines) {
 	} elsif($right eq '/dev/null') {
 		$filename = $left;
 	} else {
-		print STDERR "Error: failed to parse diff for $left and $right\n";
-		exit 1;
+		my @ldirs = split /[\/\\]/, $left;
+		my @rdirs = split /[\/\\]/, $right;
+
+		$filename = '';
+		while ((my $l = pop @ldirs) && (my $r = pop @rdirs)) {
+			last if ($l ne $r);
+			$filename = "$l/$filename";
+		}
+		$filename =~ s/\/$//;
+
+		if (!$filename) {
+			print STDERR "Error: failed to parse diff for $left and $right\n";
+			exit 1;
+		}
 	}
 	$left = $right = undef;
 	($clname, $relname) = get_clname ($filename);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Improve extraction of changed file in contrib/mklog
  2017-07-09 19:03 [PATCH] Improve extraction of changed file in contrib/mklog Yuri Gribov
@ 2017-07-26 17:11 ` Jeff Law
  2017-07-28  2:33   ` Yuri Gribov
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2017-07-26 17:11 UTC (permalink / raw)
  To: Yuri Gribov, GCC Patches; +Cc: Trevor Saunders

On 07/09/2017 01:03 PM, Yuri Gribov wrote:
> Hi,
> 
> Currently mklog will fail to analyze lines like this in patches:
> diff -rupN gcc/gcc/testsuite/lib/profopt.exp
> gcc-compare-checks/gcc/testsuite/lib/profopt.exp
> (it fails with "Error: failed to parse diff for ... and ...").
> 
> This patch fixes it. Ok for trunk?
> 
> -Y
> 
> 
> mklog-filename-fix-1.patch
> 
> 
> 2017-07-09  Yury Gribov  <tetra2005@gmail.com>
> 
> contrib/
>         * mklog: Fix extraction of changed file name.
One could argue that given general directions python would be a better
match than perl, but I don't think it's reasonable to require a rewrite
to move forward.

OK.

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Improve extraction of changed file in contrib/mklog
  2017-07-26 17:11 ` Jeff Law
@ 2017-07-28  2:33   ` Yuri Gribov
  2017-08-02 15:38     ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri Gribov @ 2017-07-28  2:33 UTC (permalink / raw)
  To: Jeff Law; +Cc: GCC Patches, Trevor Saunders

On Wed, Jul 26, 2017 at 6:11 PM, Jeff Law <law@redhat.com> wrote:
> On 07/09/2017 01:03 PM, Yuri Gribov wrote:
>> Hi,
>>
>> Currently mklog will fail to analyze lines like this in patches:
>> diff -rupN gcc/gcc/testsuite/lib/profopt.exp
>> gcc-compare-checks/gcc/testsuite/lib/profopt.exp
>> (it fails with "Error: failed to parse diff for ... and ...").
>>
>> This patch fixes it. Ok for trunk?
>>
>> -Y
>>
>>
>> mklog-filename-fix-1.patch
>>
>>
>> 2017-07-09  Yury Gribov  <tetra2005@gmail.com>
>>
>> contrib/
>>         * mklog: Fix extraction of changed file name.
> One could argue that given general directions python would be a better
> match than perl, but I don't think it's reasonable to require a rewrite
> to move forward.

Jeff,

Is this to make script more accessible for hacking by others?
Otherwise from technical standpoint there probly isn't much
difference.

I'm fine with rewriting it in Python once I get some time later this month.

> OK.
>
> jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Improve extraction of changed file in contrib/mklog
  2017-07-28  2:33   ` Yuri Gribov
@ 2017-08-02 15:38     ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2017-08-02 15:38 UTC (permalink / raw)
  To: Yuri Gribov; +Cc: GCC Patches, Trevor Saunders

On 07/27/2017 08:33 PM, Yuri Gribov wrote:
> On Wed, Jul 26, 2017 at 6:11 PM, Jeff Law <law@redhat.com> wrote:
>> On 07/09/2017 01:03 PM, Yuri Gribov wrote:
>>> Hi,
>>>
>>> Currently mklog will fail to analyze lines like this in patches:
>>> diff -rupN gcc/gcc/testsuite/lib/profopt.exp
>>> gcc-compare-checks/gcc/testsuite/lib/profopt.exp
>>> (it fails with "Error: failed to parse diff for ... and ...").
>>>
>>> This patch fixes it. Ok for trunk?
>>>
>>> -Y
>>>
>>>
>>> mklog-filename-fix-1.patch
>>>
>>>
>>> 2017-07-09  Yury Gribov  <tetra2005@gmail.com>
>>>
>>> contrib/
>>>         * mklog: Fix extraction of changed file name.
>> One could argue that given general directions python would be a better
>> match than perl, but I don't think it's reasonable to require a rewrite
>> to move forward.
> 
> Jeff,
> 
> Is this to make script more accessible for hacking by others?
Precisely.  In general I think folks here are more adept at python than
perl.

> Otherwise from technical standpoint there probly isn't much
> difference.
Agreed.

> 
> I'm fine with rewriting it in Python once I get some time later this month.
Thanks.  Saw that fly by, it's in the queue.

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-02 15:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-09 19:03 [PATCH] Improve extraction of changed file in contrib/mklog Yuri Gribov
2017-07-26 17:11 ` Jeff Law
2017-07-28  2:33   ` Yuri Gribov
2017-08-02 15:38     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).