williamr/convert_to_eula.pl
author Chetan Kapoor <chetank@symbian.org>
Tue, 06 Oct 2009 17:09:32 +0100
changeset 88 d22c49c5048f
parent 74 df789c4e291d
child 115 5bbdda50c091
permissions -rw-r--r--
Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
#!/usr/bin/perl
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
#
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
# 
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
# Contributors:
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
#
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
# Description:
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
# Map the SFL license to the EULA license, keeping a copy of the original file
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
# in a parallel tree for creation of a "repair" kit to reinstate the SFL
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
use strict;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
use File::Copy;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
use File::Path;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    22
my $debug = 0;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    24
my @oldtext = (
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    25
  'terms of the License "Symbian Foundation License v1.0"',
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    26
  'the URL "http://www.symbianfoundation.org/legal/sfl-v10.html"'
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    27
);
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    28
my @newtext = (
62
7cd69ef87d2a Clarify what sort of "members" are using the SFL
William Roberts <williamr@symbian.org>
parents: 60
diff changeset
    29
  'terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members',
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    30
  'the URL "http://www.symbianfoundation.org/legal/licencesv10.html"'
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    31
);
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    32
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    33
my @errorfiles = ();
74
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    34
my @multinoticefiles = ();
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    35
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    36
sub map_eula($$$)
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    37
  {
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
  my ($file,$shadowdir,$name) = @_;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    39
  
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    40
  open FILE, "<$file" or print "ERROR: Cannot open $file: $!\n" and return "Cannot open";
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    41
  my @lines = <FILE>;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    42
  close FILE;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    43
  
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
  my $updated = 0;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    45
  my @newlines = ();
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    46
  while (my $line = shift @lines)
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    47
    { 
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    48
    # under the terms of the License "Symbian Foundation License v1.0"
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    49
    # which accompanies this distribution, and is available
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    50
    # at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    51
    my $pos1 = index $line, $oldtext[0];
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    52
    if ($pos1 >= 0)
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    53
      {
74
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    54
      # be careful - oldtext is a prefix of newtext!
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    55
      if (index($line, $newtext[0]) >= 0)
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    56
        {
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    57
        # line already converted - nothing to do
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    58
        push @newlines, $line;
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    59
        next;
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    60
        }
88
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    61
	  my @midlines = ();
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    62
      my $nextline;
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    63
	  my $midlinecount = 1;
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    64
	  while ($nextline = shift @lines)
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    65
		{
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    66
		if ($nextline !~ /^\s$/)
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    67
		  {
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    68
		  # non-blank line
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    69
		  last if ($midlinecount == 0);
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    70
		  $midlinecount -= 1;
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    71
		  # keep going
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    72
		  }
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    73
		push @midlines, $nextline;
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    74
		}
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    75
      my $urlline = $nextline;
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    76
      my $pos2 = index $urlline, $oldtext[1];
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    77
      if ($pos2 >= 0)
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    78
        {
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    79
        # Found it - assume that there's only one instance
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    80
        substr $line, $pos1, length($oldtext[0]), $newtext[0];
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
    81
        substr $urlline, $pos2, length($oldtext[1]), $newtext[1];
88
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    82
        push @newlines, $line, @midlines, $urlline;
74
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    83
        $updated += 1;
71
59ba21437bf0 Modified convert_to_eula.pl to parse multiple instances of the SFL licence.
Chetan Kapoor <chetank@symbian.org>
parents: 62
diff changeset
    84
        next;
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    85
        }
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    86
      else
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    87
        {
74
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    88
        if(!$updated)
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    89
          {
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    90
          my $lineno = 1 + (scalar @newlines);
88
d22c49c5048f Fixed "white-spaces" in licence text issue in convert_to_eula.pl
Chetan Kapoor <chetank@symbian.org>
parents: 74
diff changeset
    91
          print STDERR "Problem in $file at $lineno: incorrectly formatted >\n$line", join("",@midlines), "$urlline\n";
74
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    92
          push @errorfiles, $file;
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
    93
          }	
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    94
        last;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    95
        }
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    96
      }
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    97
    push @newlines, $line;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    98
    }
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
    99
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   100
  return if (!$updated);
74
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   101
  
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   102
  if ($updated > 1)
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   103
    {
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   104
    push @multinoticefiles, $file;
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   105
    print "! found $updated SFL notices in $file\n";
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   106
    }
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   107
 
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   108
  mkpath($shadowdir, {verbose=>0});
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   109
  move($file, "$shadowdir/$name") or die("Cannot move $file to $shadowdir/$name: $!\n");
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   110
  open NEWFILE, ">$file" or die("Cannot overwrite $file: $!\n");
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
   111
  print NEWFILE @newlines, @lines;
59
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   112
  close NEWFILE or die("Failed to update $file: $!\n");
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   113
  print "* updated $file\n";
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   114
  }
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   115
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   116
# Process tree
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   117
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   118
sub scan_directory($$)
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   119
  {
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   120
  my ($path, $shadow) = @_;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   121
  
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   122
  opendir DIR, $path;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   123
  my @files = grep !/^\.\.?$/, readdir DIR;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   124
  closedir DIR;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   125
  
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   126
  foreach my $file (@files)
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   127
    {
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   128
    my $newpath = "$path/$file";
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   129
    my $newshadow = "$shadow/$file";
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   130
    
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   131
    if (-d $newpath)
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   132
      {
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   133
      scan_directory($newpath, $newshadow);
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   134
      next;
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   135
      }
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   136
    next if (-B $newpath);  # ignore binary files
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   137
    
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   138
    map_eula($newpath, $shadow, $file);
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   139
    }
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   140
  }
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   141
69e9b8ca3ae9 Simple utility to change perfectly-formed SFL copyright notices to something else
William Roberts <williamr@symbian.org>
parents:
diff changeset
   142
scan_directory("/epoc32", "/sfl_epoc32");
60
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
   143
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
   144
printf "%d problem files\n", scalar @errorfiles;
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
   145
print "\t", join("\n\t", @errorfiles), "\n";
e86c659b78a0 Fix Bug 387 - full newline processing as per "perlport" guidance
William Roberts <williamr@symbian.org>
parents: 59
diff changeset
   146
74
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   147
printf "%d files with multiple notices\n", scalar @multinoticefiles;
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   148
print "\t", join("\n\t", @multinoticefiles), "\n";
df789c4e291d Move the "already converted notice" line check to a more efficient place, report files with multiple notices, repair formatting.
William Roberts <williamr@symbian.org>
parents: 71
diff changeset
   149