| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
# lccnorm by Paul Hoffman (nkuitse AT nkuitse DOT com). |
| 4 |
# Copyright 2007 Paul M. Hoffman. |
| 5 |
# This software is made available under the same terms as Perl; |
| 6 |
# see below for details. |
| 7 |
|
| 8 |
use strict; |
| 9 |
|
| 10 |
# -------------------------------- Required modules |
| 11 |
|
| 12 |
use Biblio::LCC; |
| 13 |
use File::Basename qw(basename); |
| 14 |
use Getopt::Long |
| 15 |
qw(:config posix_default gnu_compat require_order bundling no_ignore_case); |
| 16 |
|
| 17 |
# -------------------------------- Variables |
| 18 |
|
| 19 |
use vars qw($PROGRAM $VERSION $AUTHOR $COPYRIGHT $PAGER); |
| 20 |
|
| 21 |
$PROGRAM = basename($0); |
| 22 |
$VERSION = '0.08'; |
| 23 |
$AUTHOR = 'Paul Hoffman (nkuitse AT nkuitse DOT com)'; |
| 24 |
$COPYRIGHT = "Copyright 2007 Paul M. Hoffman"; |
| 25 |
|
| 26 |
my $action = \&run; |
| 27 |
my $verbose; |
| 28 |
|
| 29 |
my $in_delim = "\t"; |
| 30 |
my $out_join; |
| 31 |
my ($i, $j) = (0, 0); # Field(s) that contain the call no. (or range) |
| 32 |
my ($output_pos, $copy, $at_beginning, $at_end, $input_is_ranges, $errors_are_fatal); |
| 33 |
|
| 34 |
# -------------------------------- Setup |
| 35 |
|
| 36 |
$| = 1; |
| 37 |
|
| 38 |
# -------------------------------- Read command-line options and arguments |
| 39 |
|
| 40 |
GetOptions( |
| 41 |
|
| 42 |
'f|fields=s' => sub { |
| 43 |
my $field_spec = $_[1]; |
| 44 |
if ($field_spec =~ /^(\d+)-(\d+)$/) { |
| 45 |
($i, $j) = ($1 - 1, $2 - 1); |
| 46 |
exit usage("Invalid field spec: end must be greater than beginning") |
| 47 |
unless $i < $j; |
| 48 |
exit usage("Invalid field spec: must be 1, 2, 3, or 4 fields") |
| 49 |
unless $j - $i < 4; |
| 50 |
} |
| 51 |
elsif ($field_spec =~ /^(\d+)$/) { |
| 52 |
($i, $j) = ($1 - 1, $1 - 1); |
| 53 |
} |
| 54 |
}, |
| 55 |
'r|ranges' => \$input_is_ranges, |
| 56 |
|
| 57 |
'd|delimiter=s' => \$in_delim, |
| 58 |
'j|join=s' => \$out_join, |
| 59 |
|
| 60 |
'c|copy' => \$copy, |
| 61 |
'b|beginning' => \$at_beginning, |
| 62 |
'e|end' => \$at_end, |
| 63 |
|
| 64 |
'D|die-on-error' => \$errors_are_fatal, |
| 65 |
'v|verbose' => \$verbose, |
| 66 |
|
| 67 |
'h|help' => sub { $action = \&help }, |
| 68 |
'V|version' => sub { $action = \&version }, |
| 69 |
'M|manual' => sub { $action = \&manual }, |
| 70 |
'L|license' => sub { $action = \&license }, |
| 71 |
|
| 72 |
) or exit usage(); |
| 73 |
|
| 74 |
$out_join = $in_delim unless defined $out_join; |
| 75 |
$in_delim = qr/\Q$in_delim\E/ if defined $in_delim; |
| 76 |
|
| 77 |
if ($copy) { |
| 78 |
exit usage("Must specify -b|--beginning or -e|--end when using option -c|--copy") |
| 79 |
unless $at_beginning or $at_end; |
| 80 |
} |
| 81 |
|
| 82 |
# -------------------------------- Perform the desired action |
| 83 |
|
| 84 |
$action->(); |
| 85 |
|
| 86 |
# -------------------------------- Action functions |
| 87 |
|
| 88 |
sub run { |
| 89 |
|
| 90 |
# --- Figure out how to convert fields to a range string |
| 91 |
|
| 92 |
# Number of fields that hold the call number or range |
| 93 |
my $n = $j - $i + 1; |
| 94 |
|
| 95 |
# Function to construct an (unnormalized) call number or range from the input fields |
| 96 |
my $field2str; |
| 97 |
|
| 98 |
if ($n == 1) { |
| 99 |
# Ranges: ("E184-E184.5") --> "E184-E184.5" |
| 100 |
# Call #: ("Z699.22 .H54 1982") |
| 101 |
$field2str = sub { $_[0] }; |
| 102 |
} |
| 103 |
elsif ($n == 2) { |
| 104 |
# Ranges: ("E184", "E184.5") --> "E184-E184.5" |
| 105 |
# Call #: ("Z", "699.22 .H54 1982") or some such |
| 106 |
$field2str = $input_is_ranges |
| 107 |
? sub { join('-', @_) } |
| 108 |
: sub { join(' ', @_) }; |
| 109 |
} |
| 110 |
elsif ($n == 3) { |
| 111 |
# ("E", "184", "184.5") --> "E184-E184.5" |
| 112 |
# Call #: ("Z", "699.22", ".H54 1982") or some such |
| 113 |
$field2str = $input_is_ranges |
| 114 |
? sub { "$_[0] $_[1]-$_[0] $_[2]" } |
| 115 |
: sub { join(' ', @_) }; |
| 116 |
} |
| 117 |
elsif ($n == 4) { |
| 118 |
# ("E", "184", "E", "184.5") --> "E184-E184.5" |
| 119 |
# Call #: ("Z", "699.22", ".H54", "1982") or some such |
| 120 |
$field2str = $input_is_ranges |
| 121 |
? sub { "$_[0] $_[1]-$_[2] $_[3]" } |
| 122 |
: sub { join(' ', @_) }; |
| 123 |
} |
| 124 |
else { |
| 125 |
die "This can't happen, because we eliminated this possibility earlier"; |
| 126 |
} |
| 127 |
|
| 128 |
# --- Process the input (finally!) |
| 129 |
|
| 130 |
my $line_num = 1; |
| 131 |
while (<>) { |
| 132 |
chomp; |
| 133 |
my $line = $_; |
| 134 |
|
| 135 |
# --- Split the line up into fields |
| 136 |
my @fields = split /$in_delim/; |
| 137 |
|
| 138 |
# --- Isolate the fields that hold the call number (or range) from |
| 139 |
# those (if any) that precede and follow them |
| 140 |
my (@before, @callnum, @after); |
| 141 |
@before = splice @fields, 0, $i |
| 142 |
if $i > 0; |
| 143 |
@callnum = splice @fields, 0, $n; |
| 144 |
@after = @fields; |
| 145 |
|
| 146 |
my @result; |
| 147 |
|
| 148 |
# --- Normalize the call number or range |
| 149 |
if ($input_is_ranges) { |
| 150 |
my $range = $field2str->(@callnum); |
| 151 |
eval { |
| 152 |
@result = Biblio::LCC->normalize_range($range); |
| 153 |
}; |
| 154 |
} |
| 155 |
else { |
| 156 |
my $callnum = $field2str->(@callnum); |
| 157 |
eval { |
| 158 |
@result = (Biblio::LCC->normalize($callnum)); |
| 159 |
}; |
| 160 |
} |
| 161 |
if ($@) { |
| 162 |
print STDERR "Error in input line $line_num: $line\n"; |
| 163 |
exit 2 if $errors_are_fatal; |
| 164 |
next; |
| 165 |
} |
| 166 |
my @output; |
| 167 |
if ($copy) { |
| 168 |
@output = $at_beginning |
| 169 |
? (@result, @before, @callnum, @after) |
| 170 |
: ( @before, @callnum, @after, @result) |
| 171 |
; |
| 172 |
} |
| 173 |
else { |
| 174 |
@output = $at_beginning |
| 175 |
? (@result, @before, @after) |
| 176 |
: $at_end |
| 177 |
? ( @before, @after, @result ) |
| 178 |
: ( @before, @result, @after ) |
| 179 |
; |
| 180 |
} |
| 181 |
print join($out_join, @output), "\n"; |
| 182 |
} |
| 183 |
continue { |
| 184 |
$line_num++; |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
sub help { |
| 189 |
usage(); |
| 190 |
options(); |
| 191 |
exit 0; |
| 192 |
} |
| 193 |
|
| 194 |
sub version { |
| 195 |
print "This is $PROGRAM " if $verbose; |
| 196 |
print $VERSION; |
| 197 |
print <<"EOS" if $verbose; |
| 198 |
by $AUTHOR. |
| 199 |
$COPYRIGHT. |
| 200 |
This is free software, made available under the same terms as Perl itself. |
| 201 |
EOS |
| 202 |
print "\n" unless $verbose; |
| 203 |
exit 0; |
| 204 |
} |
| 205 |
|
| 206 |
sub manual { |
| 207 |
system(podder()) == 0 |
| 208 |
or print STDERR "I can't find a way to print the manual page for $PROGRAM.\n"; |
| 209 |
} |
| 210 |
|
| 211 |
sub license { |
| 212 |
my $pager = pager(); |
| 213 |
if ($pager and which('sed')) { |
| 214 |
system(qq{sed '/^This software is made available/,/^The End/!d' "$0" | "$pager"}); |
| 215 |
} else { |
| 216 |
print STDERR "I can't find a way to print the license for $PROGRAM\n"; |
| 217 |
} |
| 218 |
} |
| 219 |
|
| 220 |
# -------------------------------- Other functions |
| 221 |
|
| 222 |
sub options { |
| 223 |
print <<"EOS"; |
| 224 |
Options: |
| 225 |
-f|--fields RANGE Field(s) containing the call number (or range) |
| 226 |
-r|--ranges Input is ranges |
| 227 |
|
| 228 |
-d|--delimiter STR Input delimiter (default: tab) |
| 229 |
-j|--join STR Output delimiter (default: same as for input) |
| 230 |
|
| 231 |
-c|--copy Don't delete source fields |
| 232 |
-b|--beginning Put normalized string at beginning of line |
| 233 |
-e|--end Put normalized string at end of line |
| 234 |
|
| 235 |
-D|--die-on-error Exit with an error as soon as an error is encountered |
| 236 |
-v|--verbose Be verbose |
| 237 |
|
| 238 |
-h|--help Print help and exit |
| 239 |
-V|--version Print version and exit |
| 240 |
-M|--manual Print manual (using pager) and exit |
| 241 |
-L|--license Print license (using pager) and exit |
| 242 |
EOS |
| 243 |
} |
| 244 |
|
| 245 |
sub usage { |
| 246 |
print STDERR "$_\n" foreach @_; |
| 247 |
print <<"EOS"; |
| 248 |
Usage: |
| 249 |
$PROGRAM [OPTION...] [FILE...] |
| 250 |
EOS |
| 251 |
return 1; |
| 252 |
} |
| 253 |
|
| 254 |
sub pager { |
| 255 |
return $PAGER if defined $PAGER; |
| 256 |
$PAGER = $ENV{'PAGER'} || which(qw(less more)) || which('cat') || 0; |
| 257 |
return $PAGER; |
| 258 |
} |
| 259 |
|
| 260 |
sub podder { |
| 261 |
return "cat $0 | pod2man -n $PROGRAM -s 1 -r $VERSION -c '' | nroff -man | " . pager() |
| 262 |
if pager() and which('pod2man') and which('nroff'); |
| 263 |
return "man 1 $PROGRAM" |
| 264 |
if manpage($PROGRAM); |
| 265 |
return "perldoc -F $0" |
| 266 |
if which('perldoc'); |
| 267 |
return undef; |
| 268 |
} |
| 269 |
|
| 270 |
sub which { |
| 271 |
my $out; |
| 272 |
no warnings; |
| 273 |
foreach my $prog (@_) { |
| 274 |
$out = `which $prog 2>/dev/null`; |
| 275 |
if (defined $out) { |
| 276 |
chomp $out; |
| 277 |
return $out if -x $out; |
| 278 |
} |
| 279 |
} |
| 280 |
return undef; |
| 281 |
} |
| 282 |
|
| 283 |
sub manpage { |
| 284 |
return unless which('man'); |
| 285 |
my $out = `man -w 1 $PROGRAM 2>/dev/null`; |
| 286 |
return unless defined $out; |
| 287 |
chomp $out; |
| 288 |
return $out; |
| 289 |
} |
| 290 |
|
| 291 |
=head1 NAME |
| 292 |
|
| 293 |
lccnorm - normalize Library of Congress Classification call numbers |
| 294 |
|
| 295 |
=head1 SYNOPSIS |
| 296 |
|
| 297 |
B<lccnorm> [I<option>...] [I<file>...] |
| 298 |
|
| 299 |
B<lccnorm> B<-h>|B<--help> |
| 300 |
|
| 301 |
B<lccnorm> B<-V>|B<--version> |
| 302 |
|
| 303 |
=head1 DESCRIPTION |
| 304 |
|
| 305 |
B<lccnorm> transforms LC-style call numbers into a form that may be used in a |
| 306 |
straight ASCII sort. |
| 307 |
|
| 308 |
By default, each line of input is assumed to consist of a number of |
| 309 |
tab-delimited fields, of which the first contains an LC-style call number or |
| 310 |
class. |
| 311 |
|
| 312 |
If no file is specified, or if the file name C<-> is specified, standard input |
| 313 |
will be processed. |
| 314 |
|
| 315 |
Normalization of call number ranges is a special challenge, because ranges are |
| 316 |
not normally specified using the exact endpoint. Consider the range C<B708-B713>; while |
| 317 |
C<B708> does indicate the beginning point -- a no call number that comes before B 708 can |
| 318 |
fall within the range -- the end point is only a guide, not a strict limit, since the intent |
| 319 |
is that call numbers such as C<B 713 .H94> and C<B 713 .W55 L86> B<do> fall within the |
| 320 |
range. Unfortunately, ranges are often specified ambiguously; for example, the call number |
| 321 |
C<B 713.14 G92> might or might not be considered to fall within this range. |
| 322 |
|
| 323 |
=head1 OPTIONS |
| 324 |
|
| 325 |
=over 4 |
| 326 |
|
| 327 |
=item B<-d>, B<--delimiter> I<string> |
| 328 |
|
| 329 |
Specify a string other than a single tab (ASCII character 9) to delimit the |
| 330 |
fields in a line of input. This also provides the default for joining fields |
| 331 |
in the output; see option B<-j> below. |
| 332 |
|
| 333 |
=item B<-f>, B<--field> I<range> |
| 334 |
|
| 335 |
The call number (or range) is found in the given range of fields. Fields are |
| 336 |
1-based (the first field is field 1, not field 0) and are separated by a single |
| 337 |
tab character (unless option B<-d> is used to specify an alternate delimiter). |
| 338 |
|
| 339 |
When parsing call numbers (not ranges), all fields are concatenated using a |
| 340 |
single space to form the call number that will be normalized. |
| 341 |
|
| 342 |
When parsing ranges, there are four possibilities: |
| 343 |
|
| 344 |
=over 4 |
| 345 |
|
| 346 |
=item 1 field |
| 347 |
|
| 348 |
The field contains a range in the form I<prefix> (e.g., C<J80>), I<closed |
| 349 |
range> (e.g., C<ML566-566.6> or C<ML566-ML566.6>) or I<half-open range> (e.g., |
| 350 |
C<< KME451E<lt>KME500 >>). |
| 351 |
|
| 352 |
=item 2 fields |
| 353 |
|
| 354 |
The first field is the beginning of the (closed) range, and the second is the |
| 355 |
end. |
| 356 |
|
| 357 |
=item 3 fields |
| 358 |
|
| 359 |
The first field is a prefix common to both the beginning and end of the range, |
| 360 |
and the second and third fields are the remainders. |
| 361 |
|
| 362 |
=item 4 fields |
| 363 |
|
| 364 |
The first and third fields together are the beginning of the range, and the |
| 365 |
second and fourth are the end. |
| 366 |
|
| 367 |
=back |
| 368 |
|
| 369 |
For example, the following all produce identical output: |
| 370 |
|
| 371 |
$ echo 'PL4501-4509' | lccnorm -d: -f1 |
| 372 |
$ echo 'PL4501:PL4509' | lccnorm -d: -f1-2 |
| 373 |
$ echo 'PL:4501:4509' | lccnorm -d: -f1-3 |
| 374 |
$ echo 'PL:4501:PL:4509' | lccnorm -d: -f1-4 |
| 375 |
|
| 376 |
=item B<-j>, B<--join> I<string> |
| 377 |
|
| 378 |
Specify a character to use when joining fields for output. The default is to use the same |
| 379 |
string specified in option B<-d>, or a single tab if B<-d> was not given. |
| 380 |
|
| 381 |
=item B<-c> |
| 382 |
|
| 383 |
Don't delete the input fields from which call numbers (or ranges) were obtained. |
| 384 |
Either the B<-b> and B<-e> option must be provided to specify where the normalized |
| 385 |
string is to be placed. |
| 386 |
|
| 387 |
=item B<-b>, B<--begin> |
| 388 |
|
| 389 |
Place normalized strings at the beginning of output lines. |
| 390 |
|
| 391 |
=item B<-e>, B<--end> |
| 392 |
|
| 393 |
Place normalized strings at the end of output lines. |
| 394 |
|
| 395 |
=item B<-D>, B<--die-on-error> |
| 396 |
|
| 397 |
Exit with a non-zero status as soon as an unnormalizable input is encountered. |
| 398 |
The default is to issue a warning and normalize to the empty string. |
| 399 |
|
| 400 |
=item B<-v>, B<--verbose> |
| 401 |
|
| 402 |
Be verbose. This currently has no effect unless used with the B<-V> or |
| 403 |
B<--version> option. |
| 404 |
|
| 405 |
=item B<-h>, B<--help> |
| 406 |
|
| 407 |
Print help information and exit. |
| 408 |
|
| 409 |
=item B<-V>, B<--version> |
| 410 |
|
| 411 |
Print the version number and exit. If the B<-v> or B<--verbose> option is |
| 412 |
specified, print out additional information. |
| 413 |
|
| 414 |
=item B<-M>, B<--manual> |
| 415 |
|
| 416 |
View the manual page for B<lccnorm>. |
| 417 |
|
| 418 |
=item B<-L>, B<--license> |
| 419 |
|
| 420 |
View the license under which B<lccnorm> is distributed. |
| 421 |
|
| 422 |
=back |
| 423 |
|
| 424 |
=head1 AUTHOR |
| 425 |
|
| 426 |
Paul Hoffman (nkuitse AT nkuitse DOT com) |
| 427 |
|
| 428 |
=head1 COPYRIGHT |
| 429 |
|
| 430 |
Copyright 2007 Paul M. Hoffman. |
| 431 |
|
| 432 |
This module is free software; you can redistribute it and/or modify it |
| 433 |
under the same terms as Perl: |
| 434 |
|
| 435 |
=over 4 |
| 436 |
|
| 437 |
=item a) |
| 438 |
|
| 439 |
the GNU General Public License as published by the Free Software |
| 440 |
Foundation; either version 1, or (at your option) any later version; |
| 441 |
|
| 442 |
B<or> |
| 443 |
|
| 444 |
=item b) |
| 445 |
|
| 446 |
the "Artistic License". |
| 447 |
|
| 448 |
For the full text of these licenses, see the script file itself or |
| 449 |
enter the command B<lccnorm -L>. |
| 450 |
|
| 451 |
=back |
| 452 |
|
| 453 |
=head1 SEE ALSO |
| 454 |
|
| 455 |
L<Biblio::LCC|Biblio::LCC> |
| 456 |
|
| 457 |
=begin license |
| 458 |
|
| 459 |
This software is made available under the same terms as Perl: |
| 460 |
|
| 461 |
a) the GNU General Public License as published by the Free |
| 462 |
Software Foundation; either version 1, or (at your option) any |
| 463 |
later version; |
| 464 |
|
| 465 |
or (at your option) |
| 466 |
|
| 467 |
b) the "Artistic License" |
| 468 |
|
| 469 |
---------------------------------------------------------------------------- |
| 470 |
|
| 471 |
The General Public License (GPL) |
| 472 |
Version 2, June 1991 |
| 473 |
|
| 474 |
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, |
| 475 |
MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of |
| 476 |
this license document, but changing it is not allowed. |
| 477 |
|
| 478 |
Preamble |
| 479 |
|
| 480 |
The licenses for most software are designed to take away your freedom to share |
| 481 |
and change it. By contrast, the GNU General Public License is intended to |
| 482 |
guarantee your freedom to share and change free software--to make sure the |
| 483 |
software is free for all its users. This General Public License applies to most |
| 484 |
of the Free Software Foundation's software and to any other program whose |
| 485 |
authors commit to using it. (Some other Free Software Foundation software is |
| 486 |
covered by the GNU Library General Public License instead.) You can apply it to |
| 487 |
your programs, too. |
| 488 |
|
| 489 |
When we speak of free software, we are referring to freedom, not price. Our |
| 490 |
General Public Licenses are designed to make sure that you have the freedom to |
| 491 |
distribute copies of free software (and charge for this service if you wish), |
| 492 |
that you receive source code or can get it if you want it, that you can change |
| 493 |
the software or use pieces of it in new free programs; and that you know you can |
| 494 |
do these things. |
| 495 |
|
| 496 |
To protect your rights, we need to make restrictions that forbid anyone to deny |
| 497 |
you these rights or to ask you to surrender the rights. These restrictions |
| 498 |
translate to certain responsibilities for you if you distribute copies of the |
| 499 |
software, or if you modify it. |
| 500 |
|
| 501 |
For example, if you distribute copies of such a program, whether gratis or for a |
| 502 |
fee, you must give the recipients all the rights that you have. You must make |
| 503 |
sure that they, too, receive or can get the source code. And you must show them |
| 504 |
these terms so they know their rights. |
| 505 |
|
| 506 |
We protect your rights with two steps: (1) copyright the software, and (2) offer |
| 507 |
you this license which gives you legal permission to copy, distribute and/or |
| 508 |
modify the software. |
| 509 |
|
| 510 |
Also, for each author's protection and ours, we want to make certain that |
| 511 |
everyone understands that there is no warranty for this free software. If the |
| 512 |
software is modified by someone else and passed on, we want its recipients to |
| 513 |
know that what they have is not the original, so that any problems introduced by |
| 514 |
others will not reflect on the original authors' reputations. |
| 515 |
|
| 516 |
Finally, any free program is threatened constantly by software patents. We wish |
| 517 |
to avoid the danger that redistributors of a free program will individually |
| 518 |
obtain patent licenses, in effect making the program proprietary. To prevent |
| 519 |
this, we have made it clear that any patent must be licensed for everyone's free |
| 520 |
use or not licensed at all. |
| 521 |
|
| 522 |
The precise terms and conditions for copying, distribution and modification |
| 523 |
follow. |
| 524 |
|
| 525 |
GNU GENERAL PUBLIC LICENSE |
| 526 |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND |
| 527 |
MODIFICATION |
| 528 |
|
| 529 |
0. This License applies to any program or other work which contains a notice |
| 530 |
placed by the copyright holder saying it may be distributed under the terms of |
| 531 |
this General Public License. The "Program", below, refers to any such program or |
| 532 |
work, and a "work based on the Program" means either the Program or any |
| 533 |
derivative work under copyright law: that is to say, a work containing the |
| 534 |
Program or a portion of it, either verbatim or with modifications and/or |
| 535 |
translated into another language. (Hereinafter, translation is included without |
| 536 |
limitation in the term "modification".) Each licensee is addressed as "you". |
| 537 |
|
| 538 |
Activities other than copying, distribution and modification are not covered by |
| 539 |
this License; they are outside its scope. The act of running the Program is not |
| 540 |
restricted, and the output from the Program is covered only if its contents |
| 541 |
constitute a work based on the Program (independent of having been made by |
| 542 |
running the Program). Whether that is true depends on what the Program does. |
| 543 |
|
| 544 |
1. You may copy and distribute verbatim copies of the Program's source code as |
| 545 |
you receive it, in any medium, provided that you conspicuously and appropriately |
| 546 |
publish on each copy an appropriate copyright notice and disclaimer of warranty; |
| 547 |
keep intact all the notices that refer to this License and to the absence of any |
| 548 |
warranty; and give any other recipients of the Program a copy of this License |
| 549 |
along with the Program. |
| 550 |
|
| 551 |
You may charge a fee for the physical act of transferring a copy, and you may at |
| 552 |
your option offer warranty protection in exchange for a fee. |
| 553 |
|
| 554 |
2. You may modify your copy or copies of the Program or any portion of it, thus |
| 555 |
forming a work based on the Program, and copy and distribute such modifications |
| 556 |
or work under the terms of Section 1 above, provided that you also meet all of |
| 557 |
these conditions: |
| 558 |
|
| 559 |
a) You must cause the modified files to carry prominent notices stating that you |
| 560 |
changed the files and the date of any change. |
| 561 |
|
| 562 |
b) You must cause any work that you distribute or publish, that in whole or in |
| 563 |
part contains or is derived from the Program or any part thereof, to be licensed |
| 564 |
as a whole at no charge to all third parties under the terms of this License. |
| 565 |
|
| 566 |
c) If the modified program normally reads commands interactively when run, you |
| 567 |
must cause it, when started running for such interactive use in the most |
| 568 |
ordinary way, to print or display an announcement including an appropriate |
| 569 |
copyright notice and a notice that there is no warranty (or else, saying that |
| 570 |
you provide a warranty) and that users may redistribute the program under these |
| 571 |
conditions, and telling the user how to view a copy of this License. (Exception: |
| 572 |
if the Program itself is interactive but does not normally print such an |
| 573 |
announcement, your work based on the Program is not required to print an |
| 574 |
announcement.) |
| 575 |
|
| 576 |
These requirements apply to the modified work as a whole. If identifiable |
| 577 |
sections of that work are not derived from the Program, and can be reasonably |
| 578 |
considered independent and separate works in themselves, then this License, and |
| 579 |
its terms, do not apply to those sections when you distribute them as separate |
| 580 |
works. But when you distribute the same sections as part of a whole which is a |
| 581 |
work based on the Program, the distribution of the whole must be on the terms of |
| 582 |
this License, whose permissions for other licensees extend to the entire whole, |
| 583 |
and thus to each and every part regardless of who wrote it. |
| 584 |
|
| 585 |
Thus, it is not the intent of this section to claim rights or contest your |
| 586 |
rights to work written entirely by you; rather, the intent is to exercise the |
| 587 |
right to control the distribution of derivative or collective works based on the |
| 588 |
Program. |
| 589 |
|
| 590 |
In addition, mere aggregation of another work not based on the Program with the |
| 591 |
Program (or with a work based on the Program) on a volume of a storage or |
| 592 |
distribution medium does not bring the other work under the scope of this |
| 593 |
License. |
| 594 |
|
| 595 |
3. You may copy and distribute the Program (or a work based on it, under Section |
| 596 |
2) in object code or executable form under the terms of Sections 1 and 2 above |
| 597 |
provided that you also do one of the following: |
| 598 |
|
| 599 |
a) Accompany it with the complete corresponding machine-readable source code, |
| 600 |
which must be distributed under the terms of Sections 1 and 2 above on a medium |
| 601 |
customarily used for software interchange; or, |
| 602 |
|
| 603 |
b) Accompany it with a written offer, valid for at least three years, to give |
| 604 |
any third party, for a charge no more than your cost of physically performing |
| 605 |
source distribution, a complete machine-readable copy of the corresponding |
| 606 |
source code, to be distributed under the terms of Sections 1 and 2 above on a |
| 607 |
medium customarily used for software interchange; or, |
| 608 |
|
| 609 |
c) Accompany it with the information you received as to the offer to distribute |
| 610 |
corresponding source code. (This alternative is allowed only for noncommercial |
| 611 |
distribution and only if you received the program in object code or executable |
| 612 |
form with such an offer, in accord with Subsection b above.) |
| 613 |
|
| 614 |
The source code for a work means the preferred form of the work for making |
| 615 |
modifications to it. For an executable work, complete source code means all the |
| 616 |
source code for all modules it contains, plus any associated interface |
| 617 |
definition files, plus the scripts used to control compilation and installation |
| 618 |
of the executable. However, as a special exception, the source code distributed |
| 619 |
need not include anything that is normally distributed (in either source or |
| 620 |
binary form) with the major components (compiler, kernel, and so on) of the |
| 621 |
operating system on which the executable runs, unless that component itself |
| 622 |
accompanies the executable. |
| 623 |
|
| 624 |
If distribution of executable or object code is made by offering access to copy |
| 625 |
from a designated place, then offering equivalent access to copy the source code |
| 626 |
from the same place counts as distribution of the source code, even though third |
| 627 |
parties are not compelled to copy the source along with the object code. |
| 628 |
|
| 629 |
4. You may not copy, modify, sublicense, or distribute the Program except as |
| 630 |
expressly provided under this License. Any attempt otherwise to copy, modify, |
| 631 |
sublicense or distribute the Program is void, and will automatically terminate |
| 632 |
your rights under this License. However, parties who have received copies, or |
| 633 |
rights, from you under this License will not have their licenses terminated so |
| 634 |
long as such parties remain in full compliance. |
| 635 |
|
| 636 |
5. You are not required to accept this License, since you have not signed it. |
| 637 |
However, nothing else grants you permission to modify or distribute the Program |
| 638 |
or its derivative works. These actions are prohibited by law if you do not |
| 639 |
accept this License. Therefore, by modifying or distributing the Program (or any |
| 640 |
work based on the Program), you indicate your acceptance of this License to do |
| 641 |
so, and all its terms and conditions for copying, distributing or modifying the |
| 642 |
Program or works based on it. |
| 643 |
|
| 644 |
6. Each time you redistribute the Program (or any work based on the Program), |
| 645 |
the recipient automatically receives a license from the original licensor to |
| 646 |
copy, distribute or modify the Program subject to these terms and conditions. |
| 647 |
You may not impose any further restrictions on the recipients' exercise of the |
| 648 |
rights granted herein. You are not responsible for enforcing compliance by third |
| 649 |
parties to this License. |
| 650 |
|
| 651 |
7. If, as a consequence of a court judgment or allegation of patent infringement |
| 652 |
or for any other reason (not limited to patent issues), conditions are imposed |
| 653 |
on you (whether by court order, agreement or otherwise) that contradict the |
| 654 |
conditions of this License, they do not excuse you from the conditions of this |
| 655 |
License. If you cannot distribute so as to satisfy simultaneously your |
| 656 |
obligations under this License and any other pertinent obligations, then as a |
| 657 |
consequence you may not distribute the Program at all. For example, if a patent |
| 658 |
license would not permit royalty-free redistribution of the Program by all those |
| 659 |
who receive copies directly or indirectly through you, then the only way you |
| 660 |
could satisfy both it and this License would be to refrain entirely from |
| 661 |
distribution of the Program. |
| 662 |
|
| 663 |
If any portion of this section is held invalid or unenforceable under any |
| 664 |
particular circumstance, the balance of the section is intended to apply and the |
| 665 |
section as a whole is intended to apply in other circumstances. |
| 666 |
|
| 667 |
It is not the purpose of this section to induce you to infringe any patents or |
| 668 |
other property right claims or to contest validity of any such claims; this |
| 669 |
section has the sole purpose of protecting the integrity of the free software |
| 670 |
distribution system, which is implemented by public license practices. Many |
| 671 |
people have made generous contributions to the wide range of software |
| 672 |
distributed through that system in reliance on consistent application of that |
| 673 |
system; it is up to the author/donor to decide if he or she is willing to |
| 674 |
distribute software through any other system and a licensee cannot impose that |
| 675 |
choice. |
| 676 |
|
| 677 |
This section is intended to make thoroughly clear what is believed to be a |
| 678 |
consequence of the rest of this License. |
| 679 |
|
| 680 |
8. If the distribution and/or use of the Program is restricted in certain |
| 681 |
countries either by patents or by copyrighted interfaces, the original copyright |
| 682 |
holder who places the Program under this License may add an explicit |
| 683 |
geographical distribution limitation excluding those countries, so that |
| 684 |
distribution is permitted only in or among countries not thus excluded. In such |
| 685 |
case, this License incorporates the limitation as if written in the body of this |
| 686 |
License. |
| 687 |
|
| 688 |
9. The Free Software Foundation may publish revised and/or new versions of the |
| 689 |
General Public License from time to time. Such new versions will be similar in |
| 690 |
spirit to the present version, but may differ in detail to address new problems |
| 691 |
or concerns. |
| 692 |
|
| 693 |
Each version is given a distinguishing version number. If the Program specifies |
| 694 |
a version number of this License which applies to it and "any later version", |
| 695 |
you have the option of following the terms and conditions either of that version |
| 696 |
or of any later version published by the Free Software Foundation. If the |
| 697 |
Program does not specify a version number of this License, you may choose any |
| 698 |
version ever published by the Free Software Foundation. |
| 699 |
|
| 700 |
10. If you wish to incorporate parts of the Program into other free programs |
| 701 |
whose distribution conditions are different, write to the author to ask for |
| 702 |
permission. For software which is copyrighted by the Free Software Foundation, |
| 703 |
write to the Free Software Foundation; we sometimes make exceptions for this. |
| 704 |
Our decision will be guided by the two goals of preserving the free status of |
| 705 |
all derivatives of our free software and of promoting the sharing and reuse of |
| 706 |
software generally. |
| 707 |
|
| 708 |
NO WARRANTY |
| 709 |
|
| 710 |
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS |
| 711 |
NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
| 712 |
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE |
| 713 |
COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM |
| 714 |
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR |
| 715 |
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 716 |
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
| 717 |
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE |
| 718 |
PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, |
| 719 |
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR |
| 720 |
CORRECTION. |
| 721 |
|
| 722 |
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED |
| 723 |
TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY |
| 724 |
WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS |
| 725 |
PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
| 726 |
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES |
| 727 |
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM |
| 728 |
(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
| 729 |
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
| 730 |
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY |
| 731 |
OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS |
| 732 |
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| 733 |
|
| 734 |
END OF TERMS AND CONDITIONS |
| 735 |
|
| 736 |
|
| 737 |
---------------------------------------------------------------------------- |
| 738 |
|
| 739 |
The Artistic License |
| 740 |
|
| 741 |
Preamble |
| 742 |
|
| 743 |
The intent of this document is to state the conditions under which a Package may |
| 744 |
be copied, such that the Copyright Holder maintains some semblance of artistic |
| 745 |
control over the development of the package, while giving the users of the |
| 746 |
package the right to use and distribute the Package in a more-or-less customary |
| 747 |
fashion, plus the right to make reasonable modifications. |
| 748 |
|
| 749 |
Definitions: |
| 750 |
|
| 751 |
- "Package" refers to the collection of files distributed by the Copyright |
| 752 |
Holder, and derivatives of that collection of files created through textual |
| 753 |
modification. |
| 754 |
- "Standard Version" refers to such a Package if it has not been modified, |
| 755 |
or has been modified in accordance with the wishes of the Copyright |
| 756 |
Holder. |
| 757 |
- "Copyright Holder" is whoever is named in the copyright or copyrights for |
| 758 |
the package. |
| 759 |
- "You" is you, if you're thinking about copying or distributing this Package. |
| 760 |
- "Reasonable copying fee" is whatever you can justify on the basis of |
| 761 |
media cost, duplication charges, time of people involved, and so on. (You |
| 762 |
will not be required to justify it to the Copyright Holder, but only to the |
| 763 |
computing community at large as a market that must bear the fee.) |
| 764 |
- "Freely Available" means that no fee is charged for the item itself, though |
| 765 |
there may be fees involved in handling the item. It also means that |
| 766 |
recipients of the item may redistribute it under the same conditions they |
| 767 |
received it. |
| 768 |
|
| 769 |
1. You may make and give away verbatim copies of the source form of the Standard |
| 770 |
Version of this Package without restriction, provided that you duplicate all of |
| 771 |
the original copyright notices and associated disclaimers. |
| 772 |
|
| 773 |
2. You may apply bug fixes, portability fixes and other modifications derived |
| 774 |
from the Public Domain or from the Copyright Holder. A Package modified in such |
| 775 |
a way shall still be considered the Standard Version. |
| 776 |
|
| 777 |
3. You may otherwise modify your copy of this Package in any way, provided that |
| 778 |
you insert a prominent notice in each changed file stating how and when you |
| 779 |
changed that file, and provided that you do at least ONE of the following: |
| 780 |
|
| 781 |
a) place your modifications in the Public Domain or otherwise |
| 782 |
make them Freely Available, such as by posting said modifications |
| 783 |
to Usenet or an equivalent medium, or placing the modifications on |
| 784 |
a major archive site such as ftp.uu.net, or by allowing the |
| 785 |
Copyright Holder to include your modifications in the Standard |
| 786 |
Version of the Package. |
| 787 |
|
| 788 |
b) use the modified Package only within your corporation or |
| 789 |
organization. |
| 790 |
|
| 791 |
c) rename any non-standard executables so the names do not |
| 792 |
conflict with standard executables, which must also be provided, |
| 793 |
and provide a separate manual page for each non-standard |
| 794 |
executable that clearly documents how it differs from the Standard |
| 795 |
Version. |
| 796 |
|
| 797 |
d) make other distribution arrangements with the Copyright Holder. |
| 798 |
|
| 799 |
4. You may distribute the programs of this Package in object code or executable |
| 800 |
form, provided that you do at least ONE of the following: |
| 801 |
|
| 802 |
a) distribute a Standard Version of the executables and library |
| 803 |
files, together with instructions (in the manual page or equivalent) |
| 804 |
on where to get the Standard Version. |
| 805 |
|
| 806 |
b) accompany the distribution with the machine-readable source of |
| 807 |
the Package with your modifications. |
| 808 |
|
| 809 |
c) accompany any non-standard executables with their |
| 810 |
corresponding Standard Version executables, giving the |
| 811 |
non-standard executables non-standard names, and clearly |
| 812 |
documenting the differences in manual pages (or equivalent), |
| 813 |
together with instructions on where to get the Standard Version. |
| 814 |
|
| 815 |
d) make other distribution arrangements with the Copyright Holder. |
| 816 |
|
| 817 |
5. You may charge a reasonable copying fee for any distribution of this Package. |
| 818 |
You may charge any fee you choose for support of this Package. You may not |
| 819 |
charge a fee for this Package itself. However, you may distribute this Package |
| 820 |
in aggregate with other (possibly commercial) programs as part of a larger |
| 821 |
(possibly commercial) software distribution provided that you do not advertise |
| 822 |
this Package as a product of your own. |
| 823 |
|
| 824 |
6. The scripts and library files supplied as input to or produced as output from |
| 825 |
the programs of this Package do not automatically fall under the copyright of |
| 826 |
this Package, but belong to whomever generated them, and may be sold |
| 827 |
commercially, and may be aggregated with this Package. |
| 828 |
|
| 829 |
7. C or perl subroutines supplied by you and linked into this Package shall not |
| 830 |
be considered part of this Package. |
| 831 |
|
| 832 |
8. The name of the Copyright Holder may not be used to endorse or promote |
| 833 |
products derived from this software without specific prior written permission. |
| 834 |
|
| 835 |
9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 836 |
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 837 |
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR |
| 838 |
PURPOSE. |
| 839 |
|
| 840 |
The End |
| 841 |
|
| 842 |
=end license |
| 843 |
|