diff -r 69e9b8ca3ae9 -r e86c659b78a0 williamr/convert_to_eula.pl --- a/williamr/convert_to_eula.pl Tue Sep 22 17:01:01 2009 +0100 +++ b/williamr/convert_to_eula.pl Wed Sep 23 17:01:55 2009 +0100 @@ -21,6 +21,17 @@ my $debug = 0; +my @oldtext = ( + 'terms of the License "Symbian Foundation License v1.0"', + 'the URL "http://www.symbianfoundation.org/legal/sfl-v10.html"' +); +my @newtext = ( + 'terms of the License "Symbian Foundation License v1.0" to members and "Symbian Foundation End User License Agreement v1.0" to non-members', + 'the URL "http://www.symbianfoundation.org/legal/licencesv10.html"' +); + +my @errorfiles = (); + sub map_eula($$$) { my ($file,$shadowdir,$name) = @_; @@ -32,26 +43,34 @@ my $updated = 0; my @newlines = (); while (my $line = shift @lines) - { + { + if (index($line,$newtext[0]) >= 0) + { + # file already converted - nothing to do + last; + } # under the terms of the License "Symbian Foundation License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". - if ($line =~ /terms of the License "Symbian Foundation License v1.0"/) + my $pos1 = index $line, $oldtext[0]; + if ($pos1 >= 0) { my $midline = shift @lines; - my $nextline = shift @lines; - if ($nextline =~ /the URL "http:\/\/www.symbianfoundation.org\/legal\/sfl-v10.html"/) + my $urlline = shift @lines; + my $pos2 = index $urlline, $oldtext[1]; + if ($pos2 >= 0) { # Found it - assume that there's only one instance - $line =~ s/Symbian Foundation License v1.0/Symbian End User License v1.0/; - $nextline =~ s/legal\/sfl-v10.html/legal\/eula-v10.html/; - push @newlines, $line, $midline, $nextline, @lines; + substr $line, $pos1, length($oldtext[0]), $newtext[0]; + substr $urlline, $pos2, length($oldtext[1]), $newtext[1]; + push @newlines, $line, $midline, $urlline; $updated = 1; last; } else { - print STDERR "Problem in $file: incorrectly formatted >\n$line$nextline\n"; + print STDERR "Problem in $file: incorrectly formatted >\n$line$midline$urlline\n"; + push @errorfiles, $file; last; } } @@ -63,7 +82,7 @@ mkpath($shadowdir, {verbose=>0}); move($file, "$shadowdir/$name") or die("Cannot move $file to $shadowdir/$name: $!\n"); open NEWFILE, ">$file" or die("Cannot overwrite $file: $!\n"); - print NEWFILE @newlines; + print NEWFILE @newlines, @lines; close NEWFILE or die("Failed to update $file: $!\n"); print "* updated $file\n"; } @@ -95,3 +114,7 @@ } scan_directory("/epoc32", "/sfl_epoc32"); + +printf "%d problem files\n", scalar @errorfiles; +print "\t", join("\n\t", @errorfiles), "\n"; +