~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to scripts/fixdiff.pl

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl 
 
2
 
 
3
# NAME
 
4
#   fixdiff.pl - fix line endings in svn diff to match lineending of existing files
 
5
# SYNOPSIS
 
6
#   perl fixdiff.pl a.diff | patch -p0 ...
 
7
# DESCRIPTION:
 
8
#   parse diff and modify the hunks to match the line ending of the target files
 
9
#   This is useful, when the compared trees to generate the diff are on a
 
10
#   different architecture than that of the one where the patch is to be
 
11
#   applied.
 
12
# LICENSE:
 
13
#   Copyright 2008 J�rgen E. Fischer <jef@norbit.de>
 
14
#   GPL2
 
15
 
 
16
use strict;
 
17
use warnings;
 
18
 
 
19
my $dos;
 
20
 
 
21
while(<>) {
 
22
   if( /^Index: (.*)\n/ ) {
 
23
      my $file=$1;
 
24
      $dos=0;
 
25
 
 
26
      if(-f $file) {
 
27
        open F, $file;
 
28
        binmode(F);
 
29
        $dos=1 if scalar(<F>) =~ /\r\n$/;
 
30
        close F;
 
31
 
 
32
        #warn "$file in DOS mode!" if $dos;
 
33
      } else {
 
34
          warn "$file not found.";
 
35
      }
 
36
   } elsif(/^$/) {
 
37
      # skip empty lines
 
38
      next;
 
39
   } elsif(/^===================================================================/ ||
 
40
           /^---/ ||
 
41
           /^\+\+\+/ ||
 
42
           /^@@/) {
 
43
      print;
 
44
   } elsif($dos && !/\r\n$/) {
 
45
      chop;
 
46
      print "$_\r\n";
 
47
   } elsif(!$dos && /\r\n$/) {
 
48
      chop;
 
49
      chop;
 
50
      print "$_\n";
 
51
   } else {
 
52
      print;
 
53
   }
 
54
}