]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Stop copying the licence text into C source code.
authorSimon Tatham <anakin@pobox.com>
Tue, 22 Dec 2015 12:43:31 +0000 (12:43 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 22 Dec 2015 13:33:42 +0000 (13:33 +0000)
Now all the uses of the licence text or the short copyright notice get
it from a new header "licence.h", which in turn is built by a Perl
script licence.pl invoked by mkfiles.pl, using LICENCE itself as the
source.

Hence, I can completely remove a whole section from the list of
licence locations in CHECKLST.txt :-)

.gitignore
CHECKLST.txt
licence.pl [new file with mode: 0644]
mkfiles.pl
unix/gtkdlg.c
windows/version.rc2
windows/windlg.c
windows/winpgen.c
windows/winpgnt.c

index a0ec6001873c4d0350e22d58152e820e74b13f0e..df31c030ee6aa0aa5b8f95d9f27f8de4b440cb6d 100644 (file)
@@ -63,6 +63,7 @@
 /missing
 /uxconfig.in
 /uxconfig.h
+/licence.h
 /*.a
 /charset/sbcsdat.c
 /contrib/cygtermd/cygtermd.exe
index 2cf15dc7251dc0472e636c85e12eaf657ae437ca..034f570863fb57385806cc42ef7ee874b023bd09 100644 (file)
@@ -4,7 +4,7 @@ Checklists for PuTTY administrative procedures
 Locations of the licence
 ------------------------
 
-The PuTTY copyright notice and licence are stored in quite a few
+The PuTTY copyright notice and licence are stored in multiple
 places. At the start of a new year, the copyright year needs
 updating in all of them; and when someone sends a massive patch,
 their name needs adding in all of them too.
@@ -13,23 +13,6 @@ The LICENCE file in the main source distribution:
 
  - putty/LICENCE
 
-The various About and Licence boxes:
-
- - putty/windows/winpgnt.c
-    + the copyright date appears twice, once in the About box and
-      once in the Licence box. Don't forget to change both!
- - putty/windows/winpgen.c
-    + the copyright date appears twice, once in the About box and
-      once in the Licence box. Don't forget to change both!
- - putty/windows/windlg.c
-    + the copyright date appears twice, once in the About box and
-      once in the Licence box. Don't forget to change both!
- - putty/windows/version.rc2
-    + the copyright date appears once only.
- - putty/unix/gtkdlg.c
-    + the copyright date appears twice, once in the About box and
-      once in the Licence box. Don't forget to change both!
-
 The documentation (both the preamble blurb and the licence appendix):
 
  - putty/doc/blurb.but
diff --git a/licence.pl b/licence.pl
new file mode 100644 (file)
index 0000000..12d38a5
--- /dev/null
@@ -0,0 +1,64 @@
+#!/usr/bin/env perl -w
+
+# This script generates licence.h (containing the PuTTY licence in the
+# form of macros expanding to C string literals) from the LICENCE
+# master file.
+
+use File::Basename;
+
+$infile = "LICENCE";
+$outfile = "licence.h";
+open my $in, $infile or die "$infile: open: $!\n";
+open my $out, ">", $outfile or die "$outfile: open: $!\n";
+select $out;
+
+print "/*\n";
+print " * $outfile - macro definitions for the PuTTY licence.\n";
+print " *\n";
+print " * Generated by @{[basename __FILE__]} from $infile.\n";
+print " * You should edit those files rather than editing this one.\n";
+print " */\n";
+print "\n";
+
+my @lines = ();
+while (<$in>) {
+    chomp;
+    push @lines, $_;
+}
+close $in;
+
+# Format into paragraphs.
+my @paras = ();
+my $para = undef;
+for my $line (@lines) {
+    if ($line eq "") {
+        $para = undef;
+    } elsif (!defined $para) {
+        push @paras, $line;
+        $para = \$paras[$#paras];
+    } else {
+        $$para .= " " . $line;
+    }
+}
+
+print "#define LICENCE_TEXT(parsep) \\\n";
+for my $i (0..$#paras) {
+    my $lit = &stringlit($paras[$i]);
+    print "    parsep \\\n" if $i > 0;
+    print "    \"$lit\"";
+    print " \\" if $i < $#paras;
+    print "\n";
+}
+print "\n";
+
+die "bad format of first paragraph\n"
+    unless $paras[0] =~ m!copyright ([^\.]*)\.!i;
+
+printf "#define SHORT_COPYRIGHT_DETAILS \"%s\"\n", &stringlit($1);
+
+sub stringlit {
+    my ($lit) = @_;
+    $lit =~ s!\\!\\\\!g;
+    $lit =~ s!"!\\"!g;
+    return $lit;
+}
index 51fa6c18dcfeeaeb3ac816b6b7af644c2da99f7c..0e7484889e20244466b7d64fd1dbd497cf6f4645 100755 (executable)
@@ -45,9 +45,10 @@ open IN, "Recipe" or do {
 };
 
 # HACK: One of the source files in `charset' is auto-generated by
-# sbcsgen.pl. We need to generate that _now_, before attempting
-# dependency analysis.
+# sbcsgen.pl, and licence.h is likewise generated by licence.pl. We
+# need to generate those _now_, before attempting dependency analysis.
 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."; select STDOUT;';
+eval 'require "licence.pl"; select STDOUT;';
 
 @srcdirs = ("./");
 
index 5f79fc71a69354cfe29dde311080595ddcb8a0af..7058c6e18e02628e37dbbe31c8606c63c5dbf774 100644 (file)
@@ -33,6 +33,7 @@
 #include "storage.h"
 #include "dialog.h"
 #include "tree234.h"
+#include "licence.h"
 
 #if GTK_CHECK_VERSION(2,0,0)
 /* Decide which of GtkFileChooserDialog and GtkFileSelection to use */
@@ -3626,39 +3627,9 @@ static void licence_clicked(GtkButton *button, gpointer data)
 {
     char *title;
 
-    const char *licence =
-       "Copyright 1997-2015 Simon Tatham.\n\n"
-
-       "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
-       "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas "
-       "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, "
-       "Markus Kuhn, Colin Watson, Christopher Staite, and CORE SDI S.A.\n\n"
-
-       "Permission is hereby granted, free of charge, to any person "
-       "obtaining a copy of this software and associated documentation "
-       "files (the ""Software""), to deal in the Software without restriction, "
-       "including without limitation the rights to use, copy, modify, merge, "
-       "publish, distribute, sublicense, and/or sell copies of the Software, "
-       "and to permit persons to whom the Software is furnished to do so, "
-       "subject to the following conditions:\n\n"
-
-       "The above copyright notice and this permission notice shall be "
-       "included in all copies or substantial portions of the Software.\n\n"
-
-       "THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT "
-       "WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, "
-       "INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF "
-       "MERCHANTABILITY, FITNESS FOR A PARTICULAR "
-       "PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE "
-       "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES "
-       "OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, "
-       "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN "
-       "CONNECTION WITH THE SOFTWARE OR THE USE OR "
-       "OTHER DEALINGS IN THE SOFTWARE.";
-
     title = dupcat(appname, " Licence", NULL);
     assert(aboutbox != NULL);
-    messagebox(aboutbox, title, licence,
+    messagebox(aboutbox, title, LICENCE_TEXT("\n\n"),
               string_width("LONGISH LINE OF TEXT SO THE LICENCE"
                            " BOX ISN'T EXCESSIVELY TALL AND THIN"),
                TRUE, "OK", 'o', 1, 1, NULL);
@@ -3702,7 +3673,7 @@ void about_box(void *window)
         char *label_text = dupprintf
             ("%s\n\n%s\n\n%s",
              appname, ver,
-             "Copyright 1997-2015 Simon Tatham. All rights reserved");
+             "Copyright " SHORT_COPYRIGHT_DETAILS ". All rights reserved");
         w = gtk_label_new(label_text);
         gtk_label_set_justify(GTK_LABEL(w), GTK_JUSTIFY_CENTER);
 #if GTK_CHECK_VERSION(2,0,0)
index f3c002df59d912145d35e3ca689839ef54a7a434..500f9002cbb2cea5c846f9b6a89223ededd55f18 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "version.h"
+#include "licence.h"
 
 /*
  * The actual VERSIONINFO resource.
@@ -44,7 +45,7 @@ BEGIN
            VALUE "OriginalFilename",   APPNAME
            VALUE "FileVersion",        TEXTVER
            VALUE "ProductVersion",     TEXTVER
-           VALUE "LegalCopyright",     "Copyright \251 1997-2015 Simon Tatham."
+           VALUE "LegalCopyright",     "Copyright \251 " SHORT_COPYRIGHT_DETAILS "."
 #if (!defined SNAPSHOT) && (!defined RELEASE) && (!defined PRERELEASE)
            /* Only if VS_FF_PRIVATEBUILD. */
            VALUE "PrivateBuild",       TEXTVER /* NBI */
index 826876e3cbd30bc713ae02b106187b2d65afe4a4..8248ce835974fd8ffdc3142da7d118ea0f8f0913 100644 (file)
@@ -14,6 +14,7 @@
 #include "win_res.h"
 #include "storage.h"
 #include "dialog.h"
+#include "licence.h"
 
 #include <commctrl.h>
 #include <commdlg.h>
@@ -170,37 +171,7 @@ static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
            char *str = dupprintf("%s Licence", appname);
            SetWindowText(hwnd, str);
            sfree(str);
-
-            SetDlgItemText(hwnd, IDA_TEXT,
-       "Copyright 1997-2015 Simon Tatham.\r\n\r\n"
-
-       "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
-       "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas "
-       "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, "
-       "Markus Kuhn, Colin Watson, Christopher Staite, and CORE SDI S.A.\r\n\r\n"
-
-       "Permission is hereby granted, free of charge, to any person "
-       "obtaining a copy of this software and associated documentation "
-       "files (the ""Software""), to deal in the Software without restriction, "
-       "including without limitation the rights to use, copy, modify, merge, "
-       "publish, distribute, sublicense, and/or sell copies of the Software, "
-       "and to permit persons to whom the Software is furnished to do so, "
-       "subject to the following conditions:\r\n\r\n"
-
-       "The above copyright notice and this permission notice shall be "
-       "included in all copies or substantial portions of the Software.\r\n\r\n"
-
-       "THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT "
-       "WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, "
-       "INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF "
-       "MERCHANTABILITY, FITNESS FOR A PARTICULAR "
-       "PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE "
-       "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES "
-       "OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, "
-       "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN "
-       "CONNECTION WITH THE SOFTWARE OR THE USE OR "
-       "OTHER DEALINGS IN THE SOFTWARE."
-);
+            SetDlgItemText(hwnd, IDA_TEXT, LICENCE_TEXT("\r\n\r\n"));
        }
        return 1;
       case WM_COMMAND:
@@ -232,7 +203,7 @@ static int CALLBACK AboutProc(HWND hwnd, UINT msg,
             char *text = dupprintf
                 ("%s\r\n\r\n%s\r\n\r\n%s",
                  appname, ver,
-                 "\251 1997-2015 Simon Tatham. All rights reserved.");
+                 "\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
             SetDlgItemText(hwnd, IDA_TEXT, text);
             sfree(text);
         }
index 612692b4e669c1e77a5216f1e538720eda1e1a48..db55145c15561afe65a0252a80b8ed0228d32287 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "putty.h"
 #include "ssh.h"
+#include "licence.h"
 
 #include <commctrl.h>
 
@@ -253,36 +254,7 @@ static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg,
                           rd.right - rd.left, rd.bottom - rd.top, TRUE);
        }
 
-            SetDlgItemText(hwnd, 1000,
-       "Copyright 1997-2015 Simon Tatham.\r\n\r\n"
-
-       "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
-       "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas "
-       "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, "
-       "Markus Kuhn, Colin Watson, Christopher Staite, and CORE SDI S.A.\r\n\r\n"
-
-       "Permission is hereby granted, free of charge, to any person "
-       "obtaining a copy of this software and associated documentation "
-       "files (the ""Software""), to deal in the Software without restriction, "
-       "including without limitation the rights to use, copy, modify, merge, "
-       "publish, distribute, sublicense, and/or sell copies of the Software, "
-       "and to permit persons to whom the Software is furnished to do so, "
-       "subject to the following conditions:\r\n\r\n"
-
-       "The above copyright notice and this permission notice shall be "
-       "included in all copies or substantial portions of the Software.\r\n\r\n"
-
-       "THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT "
-       "WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, "
-       "INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF "
-       "MERCHANTABILITY, FITNESS FOR A PARTICULAR "
-       "PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE "
-       "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES "
-       "OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, "
-       "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN "
-       "CONNECTION WITH THE SOFTWARE OR THE USE OR "
-       "OTHER DEALINGS IN THE SOFTWARE."
-);
+        SetDlgItemText(hwnd, 1000, LICENCE_TEXT("\r\n\r\n"));
        return 1;
       case WM_COMMAND:
        switch (LOWORD(wParam)) {
@@ -326,7 +298,7 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
             char *text = dupprintf
                 ("Pageant\r\n\r\n%s\r\n\r\n%s",
                  ver,
-                 "\251 1997-2015 Simon Tatham. All rights reserved.");
+                 "\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
             SetDlgItemText(hwnd, 1000, text);
             sfree(text);
         }
index 04b58bb23a318084830889c331ffd261b46625c7..2109d1c6feb94c56f243da497aa8a0512f1468da 100644 (file)
@@ -16,6 +16,7 @@
 #include "tree234.h"
 #include "winsecur.h"
 #include "pageant.h"
+#include "licence.h"
 
 #include <shellapi.h>
 
@@ -125,36 +126,7 @@ static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg,
 {
     switch (msg) {
       case WM_INITDIALOG:
-            SetDlgItemText(hwnd, 1000,
-       "Copyright 1997-2015 Simon Tatham.\r\n\r\n"
-
-       "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
-       "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas "
-       "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, "
-       "Markus Kuhn, Colin Watson, Christopher Staite, and CORE SDI S.A.\r\n\r\n"
-
-       "Permission is hereby granted, free of charge, to any person "
-       "obtaining a copy of this software and associated documentation "
-       "files (the ""Software""), to deal in the Software without restriction, "
-       "including without limitation the rights to use, copy, modify, merge, "
-       "publish, distribute, sublicense, and/or sell copies of the Software, "
-       "and to permit persons to whom the Software is furnished to do so, "
-       "subject to the following conditions:\r\n\r\n"
-
-       "The above copyright notice and this permission notice shall be "
-       "included in all copies or substantial portions of the Software.\r\n\r\n"
-
-       "THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT "
-       "WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, "
-       "INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF "
-       "MERCHANTABILITY, FITNESS FOR A PARTICULAR "
-       "PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE "
-       "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES "
-       "OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, "
-       "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN "
-       "CONNECTION WITH THE SOFTWARE OR THE USE OR "
-       "OTHER DEALINGS IN THE SOFTWARE."
-);
+        SetDlgItemText(hwnd, 1000, LICENCE_TEXT("\r\n\r\n"));
        return 1;
       case WM_COMMAND:
        switch (LOWORD(wParam)) {
@@ -183,7 +155,7 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
             char *text = dupprintf
                 ("Pageant\r\n\r\n%s\r\n\r\n%s",
                  ver,
-                 "\251 1997-2015 Simon Tatham. All rights reserved.");
+                 "\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
             SetDlgItemText(hwnd, 1000, text);
             sfree(text);
         }