emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GPL v3


From: Mathias Megyei
Subject: GPL v3
Date: Thu, 12 Jul 2007 23:05:30 +0200

Hi,

I wrote a little perl script to change the gpl version to 3.
It looks for the strings "Free\s+Software\s+Foundation" and
"version\s+2" in the same line and replaces 2 by 3.

I started the script on EMACS_22_BASE branch. It has changed 1617
files.
Perhaps somebody finds it useful.

Mathias

#!/usr/bin/perl

use strict;
use FileHandle;

use vars qw($dir
            $file
            @list
          );

sub change_gpl($);

# start in current directory
@list = glob("./*");
foreach my $d (@list) {
    $fhtest->print("$d\n");
    if (-d $d and ! -l $d) {
        # if directory, append to @list and look into it later
        push(@list, glob($d . "/*"));
    } elsif (-f $d) {
        # file found, update it to gpl3
        change_gpl($d);
    } else {
        # not file and not directory, should never happen
        print("of unknown type: $d\n");
    }
}

sub change_gpl($)
{
    my ($file, $fhtes) = @_;
    my $fh = new FileHandle $file, "r";
    my $gplfound = 0;

    if (! defined($fh)) {
        die "Couldn't open file $file for reading!";
    } else {
        my @thefile;
        my $linenr = 0;
        while (my $line = $fh->getline()) {
            $linenr++;
            chomp($line);
            if ($line =~ m/Free\s+Software\s+Foundation/) {
                if ($line =~ m/version\s+2/) {
                    $line =~ s/(version)\s+2/$1 3/;
                    $gplfound = 1;
                }
            }
            push(@thefile, $line);
        }
        $fh->close();
        # write $file only when the gpl version has been changed
        if ($gplfound) {
            $fh->open($file, "w");
            if (! defined($fh)) {
                die "Couldn't open file $file for writing!";
            }
            foreach my $l (@thefile) {
                $fh->print($l . "\n");
            }
            $fh->close();
        }
    }
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]