Fix references to the LGPL

Francois Gouget fgouget at free.fr
Wed Feb 29 05:03:17 CST 2012


So the problem is that start.rc (it's always about start) 
contains slightly incorrect references to the LGPL in its license 
message (no less):

$ ./wine start /L
[...]
modify it under the terms of the GNU Lesser Public License
[... 2 more instances ...]

This should be 'GNU Lesser General Public License' of course. The 
problem is that just fixing the resource file would cause lots of 
fuzzying and that a patch would touch every single PO file and thus be 
quite big and risk conflicts. So I propose to use the attached general 
purpose recursive string replacement tool to fix both:

wr --no-backup --file-match '\.(rc|po)$' \
   's/Lesser Public/Lesser General Public/'


It shows every file that it modifies and here it only modified the 
expected files. Inspecting the diff I did not see any case of it 
changing the wrong stuff. One can further do a futher grep to make sure 
nothing was missed due to line wrapping:

grep -r 'GNU Lesser' . | sed -e 's/Lesser General//' | grep 'GNU Lesser'


We are even pretty lucky in that the translations don't even need 
rewrapping, except for the Romansh one (po/ro.po) (I think the 
Slovenian one is a close fit but is ok).

So if we go ahead with this it can be run whenever the time is right 
(now, last thing before 1.4 or some time after 1.4).

-- 
Francois Gouget <fgouget at free.fr>              http://fgouget.free.fr/
     We are Pentium of Borg. You will be approximated. Division is futile.
-------------- next part --------------
#!/usr/bin/perl
use warnings;
use strict;

my $name0=$0;
$name0 =~ s+^.*/++;

sub error(@)
{
    print STDERR "$name0:error: ", @_;
}


# Parse the command line
my $opt_file_match;
my $opt_file_exclude;
my $opt_backup=1;
my $opt_verbose;
my $opt_cmd;
my $usage;
while (@ARGV > 0)
{
    my $arg=shift @ARGV;
    if ($arg eq "--file-match")
    {
        if (defined $opt_file_match)
        {
            error("$arg option already specified\n");
            $usage=2;
        }
        elsif (@ARGV == 0)
        {
            error("missing parameter for the $arg option\n");
            $usage=2;
        }
        else
        {
            $opt_file_match=shift @ARGV;
        }
    }
    elsif ($arg eq "--file-exclude")
    {
        if (defined $opt_file_exclude)
        {
            error("$arg option already specified\n");
            $usage=2;
        }
        elsif (@ARGV == 0)
        {
            error("missing parameter for the $arg option\n");
            $usage=2;
        }
        else
        {
            $opt_file_exclude=shift @ARGV;
        }
    }
    elsif ($arg eq "--backup")
    {
        $opt_backup=1;
    }
    elsif ($arg eq "--no-backup")
    {
        $opt_backup=0;
    }
    elsif ($arg eq "--verbose")
    {
        $opt_verbose=1;
    }
    elsif ($arg eq "--no-verbose")
    {
        $opt_verbose=0;
    }
    elsif ($arg eq "--help" or $arg eq "-h" or $arg eq "-?")
    {
        $usage=0;
	last;
    }
    elsif (defined $opt_cmd)
    {
        error("command already specified\n");
        $usage=2;
    }
    else
    {
        $opt_cmd=$arg;
    }
}

# Verify the parameters
my ($match_pattern, $subst);
if (!defined $usage)
{
    if (!defined $opt_cmd)
    {
	error("you must specify a command\n");
	$usage=2;
    }
    elsif ($opt_cmd =~ /^d(.)(.+)\1$/)
    {
	$match_pattern=$2;
    }
    elsif ($opt_cmd =~ /^s(.).+\1.*\1[a-z]*$/)
    {
	$subst=$opt_cmd;
    }
    else
    {
	error("invalid command '$opt_cmd'\n");
	$usage=2;
    }
}
if (defined $usage)
{
    if ($usage)
    {
        error("try '$name0 --help' for more information\n");
        exit $usage;
    }
    print "Usage: $name0 [--file-match MATCH] [--file-exclude SKIP] [--no-backup]\n";
    print "          [--verbose] [--help] s/regexp/string/opts|d/regexp/\n";

    print "\n";
    print "Performs string replacements or line deletions, recursively, on the matching\n";
    print "files.\n";

    print "\n";
    print "Options:\n";
    print "  s/regexp/string/opts A Perl string substitution expression. It can use\n";
    print "                 references such as '\$1' and options for case insensitive\n";
    print "                 operation for instance.\n";
    print "  d/regexp/      Deletes the line if the Perl regular expression matches.\n";
    print "  --file-match MATCH A perl regular expression selecting the files to work on.\n";
    print "  --file-exclude SKIP A perl regular expression specifying files to skip. This\n";
    print "                 takes precedence over the --file-match option.\n";
    print "  --no-backup    Do not make a backup of the original file if set. The default\n";
    print "                 is to make a copy of the unmodified file with the '.bak'\n";
    print "                 extension.\n";
    print "  --verbose      Output more information about what is going on.\n";
    print "  --help, -h     Shows this help message.\n";
    exit 0;
}


my @dirs=("./");
while (@dirs)
{
    my $dir=shift @dirs;
    my $dh;
    if (!opendir($dh, $dir))
    {
        error("unable to read '$dir': $!\n");
        next;
    }
    foreach my $entry (readdir $dh)
    {
        next if ($entry =~ /^\.\.?$/);
        next if ($entry =~ /(~|\.bak)$/);
        $entry="$dir$entry";
        if (!-l $entry and -d _)
        {
            push @dirs, "$entry/";
            next;
        }
        next if (defined $opt_file_exclude and $entry =~ /$opt_file_exclude/);
        next if (defined $opt_file_match and $entry !~ /$opt_file_match/);

        print "$entry\n" if ($opt_verbose);
	my ($in, $out);
        if (!open($in, "<", $entry))
        {
            error("unable to open '$entry' for reading: $!\n");
            next;
        }
        if (!open($out, ">", "$entry.$$"))
        {
            error("unable to open '$entry.$$' for writing: $!\n");
            close($in);
            next;
        }
        my $modified;
        while (<$in>)
        {
            if (defined $subst)
            {
                $modified=1 if (eval "$subst");
            }
            elsif (/$match_pattern/)
            {
                # Delete the line
                $modified=1;
                next;
            }
            print $out $_;
        }
        close($out);
        close($in);
        if ($modified)
        {
            my $mode=(stat($entry))[2];
            rename "$entry", "$entry.bak" if ($opt_backup and !-f "$entry.bak");
            rename "$entry.$$", "$entry";
            chmod $mode, $entry;
            if ($opt_verbose)
            {
                print " -> modified\n";
            }
            else
            {
                print "$entry\n";
            }
        }
        else
        {
            unlink "$entry.$$";
        }
    }
    closedir($dh);
}


More information about the wine-patches mailing list