toolsandutils/productionbldtools/differ.pl
author Shabe Razvi <shaber@symbian.org>
Tue, 18 May 2010 14:32:52 +0100
changeset 43 e04be45adff8
parent 0 83f4b4db085c
child 10 d4b442d23379
permissions -rw-r--r--
Remerge featuredatabase.xml, to address Bug 2049, plus remerge fixes for Bug 476, Bug 1895, Bug 2149, Bug 2049, Bug 2509 and Bug 2539

#!\usr\bin\perl
# Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
# All rights reserved.
# This component and the accompanying materials are made available
# under the terms of "Eclipse Public License v1.0"
# which accompanies this distribution, and is available
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
#
# Initial Contributors:
# Nokia Corporation - initial contribution.
#
# Contributors:
#
# Description:
# Treates the output of diff -q to list common parts of filenames of differing
# files
# 
#

while (my $line=<STDIN>)
	{
	chomp($line);
	
	if ($line =~ /^Files .* differ$/)
		{
		if ($line =~ /^Files ([^\s]+) and ([^\s]+) differ$/)
			{
			# Files present but differing
			my @one = reverse(split(/[\/\\]/,$1));
			my @two = reverse(split(/[\/\\]/,$2));
			my @common; # Shared RHS of path/filename

			my $index = 0;

			while
			  (  ($index < scalar(@one))
			  && ($index < scalar(@two))
			  )
				{
				# If path section is identical, copy to @common
				if ($one[$index] eq $two[$index])
					{ unshift @common, $one[$index]; }
				else
					{ last; }
				$index++;
				}

			print join("\\",@common)."\n";
			}
		else
			{
			die "Could not parse \"$line\"\n";
			}
		}
	}