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

* Re: GPL v3
  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-14 14:29 ` Randal L. Schwartz
  2 siblings, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2007-07-12 22:54 UTC (permalink / raw)
  To: mathias; +Cc: emacs-devel

Mathias Megyei <mathias@mnet-mail.de> writes:

> 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.

We don't need no Perl, we have Emacs. :-)

(copyright-update is specifically designed to handle that.)

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: GPL v3
  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 14:29 ` Randal L. Schwartz
  2 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2007-07-12 23:46 UTC (permalink / raw)
  To: mathias; +Cc: emacs-devel

Thanks.

Just running this script is not enough -- we need someone to
check the results, catch any spurious changes, and fix any
files that were missed.  But the script can certainly help.

If its matching criteria were more strict, it would make
false matches less likely.

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

* Re: GPL v3
  2007-07-12 23:46 ` Richard Stallman
@ 2007-07-13  4:12   ` Mathias Megyei
  2007-07-14 18:00     ` Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Mathias Megyei @ 2007-07-13  4:12 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

On Thu, 2007-07-12 at 19:46 -0400, Richard Stallman wrote:
> Thanks.
> 
> Just running this script is not enough -- we need someone to
> check the results, catch any spurious changes, and fix any
> files that were missed.  But the script can certainly help.
> 
> If its matching criteria were more strict, it would make
> false matches less likely.

I just checked all changed files, there were no false matches.
I can post the file with all diffs (created with
'git diff > ~/emacs22base-changedgpl-diff') if somebody is 
interested. The site of the gzipped file is ~60 kB.

It is possible that not all files were changed. I can look
for the missing files at the weekend.

Mathias

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

* Re: GPL v3
  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-14 14:29 ` Randal L. Schwartz
  2 siblings, 0 replies; 6+ messages in thread
From: Randal L. Schwartz @ 2007-07-14 14:29 UTC (permalink / raw)
  To: emacs-devel

>>>>> "Mathias" == Mathias Megyei <mathias@mnet-mail.de> writes:

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

In the future, take a look at File::Find for this.  No need
to rewrite treewalking... it's part of the core libs.

Mathias>     my $fh = new FileHandle $file, "r";

Indirect Object syntax is officially discouraged.  And in all
modern Perl versions, you can write this as:

       open my $fh, "r", $file or die "Cannot open $file for read: $!";

Those were the two errors that I would flag as "must fix" in a code
review. Sorry, but I presume people might stumble across your suboptimal code
in a google search, so I have to put my comment publicly as well.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

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

* Re: GPL v3
  2007-07-13  4:12   ` Mathias Megyei
@ 2007-07-14 18:00     ` Richard Stallman
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2007-07-14 18:00 UTC (permalink / raw)
  To: mathias; +Cc: emacs-devel

    I just checked all changed files, there were no false matches.
    I can post the file with all diffs (created with
    'git diff > ~/emacs22base-changedgpl-diff') if somebody is 
    interested. The site of the gzipped file is ~60 kB.

There is no need to post the diff, as anyone else can reconstruct
it by running the script.  What we need is for someone to do that
and check in the changes, also putting GPLv3 into the COPYING files
and the manuals which have copies of the GPL.

^ 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).