X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2Fupdate-info-plist.pl;h=dd2d4569453c1019ceb1b91e7867d8e2a1b958bf;hb=5f9c47ca98dd43d8f59b7c27d3fde6edfde4fe21;hp=aac1f48c860694c8fc3944ccfec86c8fe3bd6d1a;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/OSX/update-info-plist.pl b/OSX/update-info-plist.pl index aac1f48c..dd2d4569 100755 --- a/OSX/update-info-plist.pl +++ b/OSX/update-info-plist.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright © 2006-2008 Jamie Zawinski +# Copyright © 2006-2011 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -23,7 +23,10 @@ require 5; use strict; my $progname = $0; $progname =~ s@.*/@@g; -my $version = q{ $Revision: 1.9 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; +my $version = q{ $Revision: 1.15 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; + +$ENV{PATH} = "/usr/local/bin:$ENV{PATH}"; # for seticon + my $verbose = 1; @@ -72,17 +75,19 @@ sub update_saver_xml($$) { $desc =~ s/\s*$//s; # in case it's done already... + $desc =~ s@@@gs; $desc =~ s/^.* version \d[^\n]*\n//s; $desc =~ s/^From the XScreenSaver.*\n//m; $desc =~ s@^http://www\.jwz\.org/xscreensaver.*\n@@m; - $desc =~ s/^Copyright [^ \r\n\t]+ (\d{4})(-\d{4})? (.*)\.$/Written $3; $1./m; + $desc =~ + s/\nCopyright [^ \r\n\t]+ (\d{4})(-\d{4})? (.*)\.$/\nWritten $3; $1./s; $desc =~ s/^\n+//s; error ("$filename: description contains bad characters") if ($desc =~ m/([^\t\n -~]|[<>])/); error ("$filename: can't extract authors") - unless ($desc =~ m@^(.*)\nWritten by[ \t]+([^\n]+)$@s); + unless ($desc =~ m@^(.*)\nWritten by[ \t]+(.+)$@s); $desc = $1; my $authors = $2; $desc =~ s/\s*$//s; @@ -93,6 +98,7 @@ sub update_saver_xml($$) { $year = $2; } + error ("$filename: can't extract year") unless $year; my $cyear = 1900 + ((localtime())[5]); $year = "$cyear" unless $year; if ($year && ! ($year =~ m/$cyear/)) { @@ -106,7 +112,7 @@ sub update_saver_xml($$) { # my $curator = "Jamie Zawinski"; if (! ($authors =~ m/$curator/si)) { - if ($authors =~ m@^(.*),? and (.*)$@s) { + if ($authors =~ m@^(.*?),? and (.*)$@s) { $authors = "$1, $2, and $curator"; } else { $authors .= " and $curator"; @@ -215,7 +221,7 @@ sub update($) { $copyright =~ s/\b\d{4}-(\d{4})\b/$1/; # Lose the Wikipedia URLs. - $info_str =~ s@http:.*\bwikipedia\b[^\s]+[ \t]*\n?@@gm; + $info_str =~ s@http:.*?\b(wikipedia|mathworld)\b[^\s]+[ \t]*\n?@@gm; $info_str =~ s/(\n\n)\n+/$1/gs; $info_str =~ s/(^\s+|\s+$)//gs; @@ -258,12 +264,12 @@ sub usage() { sub main() { my @files = (); - while ($#ARGV >= 0) { - $_ = shift @ARGV; - if ($_ eq "--verbose") { $verbose++; } - elsif (m/^-v+$/) { $verbose += length($_)-1; } - elsif (m/^-./) { usage; } - else { push @files, $_; } + while ($_ = $ARGV[0]) { + shift @ARGV; + if (m/^--?verbose$/s) { $verbose++; } + elsif (m/^-v+$/) { $verbose += length($_)-1; } + elsif (m/^--?q(uiet)?$/s) { $verbose = 0; } + else { push @files, $_; } } usage() unless ($#files >= 0); foreach (@files) {