unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* GPL v3
@ 2007-07-12 21:05 Mathias Megyei
  2007-07-12 22:54 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mathias Megyei @ 2007-07-12 21:05 UTC (permalink / raw)
  To: emacs-devel

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();
        }
    }
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-07-14 18:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-12 21:05 GPL v3 Mathias Megyei
2007-07-12 22:54 ` Andreas Schwab
2007-07-12 23:46 ` Richard Stallman
2007-07-13  4:12   ` Mathias Megyei
2007-07-14 18:00     ` Richard Stallman
2007-07-14 14:29 ` Randal L. Schwartz

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).