3 # This script generates licence.h (containing the PuTTY licence in the
4 # form of macros expanding to C string literals) from the LICENCE
5 # master file. It also regenerates the licence-related Halibut input
10 # Read the input file.
12 open my $in, $infile or die "$infile: open: $!\n";
20 # Format into paragraphs.
23 for my $line (@lines) {
26 } elsif (!defined $para) {
28 $para = \$paras[$#paras];
30 $$para .= " " . $line;
34 # Get the copyright years and short form of copyright holder.
35 die "bad format of first paragraph\n"
36 unless $paras[0] =~ m!copyright ([^\.]*)\.!i;
39 # Write out licence.h.
41 $outfile = "licence.h";
42 open my $out, ">", $outfile or die "$outfile: open: $!\n";
46 print " * $outfile - macro definitions for the PuTTY licence.\n";
48 print " * Generated by @{[basename __FILE__]} from $infile.\n";
49 print " * You should edit those files rather than editing this one.\n";
53 print "#define LICENCE_TEXT(parsep) \\\n";
54 for my $i (0..$#paras) {
55 my $lit = &stringlit($paras[$i]);
56 print " parsep \\\n" if $i > 0;
58 print " \\" if $i < $#paras;
63 printf "#define SHORT_COPYRIGHT_DETAILS \"%s\"\n", &stringlit($shortdetails);
74 # Write out doc/licence.but.
76 $outfile = "doc/licence.but";
77 open $out, ">", $outfile or die "$outfile: open: $!\n";
80 print "\\# Generated by @{[basename __FILE__]} from $infile.\n";
81 print "\\# You should edit those files rather than editing this one.\n\n";
83 print "\\A{licence} PuTTY \\ii{Licence}\n\n";
85 for my $i (0..$#paras) {
86 my $para = &halibutescape($paras[$i]);
88 $para =~ s!copyright!\\i{copyright}!; # index term in paragraph 1
95 # And write out doc/copy.but, which defines a macro used in the manual
98 $outfile = "doc/copy.but";
99 open $out, ">", $outfile or die "$outfile: open: $!\n";
102 print "\\# Generated by @{[basename __FILE__]} from $infile.\n";
103 print "\\# You should edit those files rather than editing this one.\n\n";
105 printf "\\define{shortcopyrightdetails} %s\n\n",
106 &halibutescape($shortdetails);
112 $text =~ s![\\{}]!\\$&!g; # Halibut escaping
113 $text =~ s!"([^"]*)"!\\q{$1}!g; # convert quoted strings to \q{}