skip if cvsps is not available
[git.ikiwiki.info.git] / IkiWiki / Plugin / cvs.pm
index 939e892705a5005c95aee694620a8514a62a5217..d44ded50571fe2832fbaf29ab3680fb1e02c912a 100644 (file)
@@ -8,7 +8,7 @@ use IkiWiki;
 use File::chdir;
 
 sub import {
-       hook(type => "wrapperargcheck", id => "cvs", call => \&wrapperargcheck);
+       hook(type => "genwrapper", id => "cvs", call => \&genwrapper);
        hook(type => "checkconfig", id => "cvs", call => \&checkconfig);
        hook(type => "getsetup", id => "cvs", call => \&getsetup);
        hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
@@ -23,15 +23,15 @@ sub import {
        hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
 }
 
-sub wrapperargcheck () {
-       my $check_args=<<"EOF";
-       int j;
-       for (j = 1; j < argc; j++)
-               if (strstr(argv[j], "New directory") != NULL)
-                       return 0;
-       return 1;
+sub genwrapper () {
+       return <<EOF;
+       {
+               int j;
+               for (j = 1; j < argc; j++)
+                       if (strstr(argv[j], "New directory") != NULL)
+                               exit(0);
+       }
 EOF
-       return $check_args;
 }
 
 sub checkconfig () {
@@ -298,7 +298,8 @@ sub rcs_recentchanges($) {
        system("env TZ=UTC cvsps -q --cvs-direct -z 30 -x >$tmpfile");
        if ($? == -1) {
                error "couldn't run cvsps: $!\n";
-       } elsif (($? >> 8) != 0) {
+       }
+       elsif (($? >> 8) != 0) {
                error "cvsps exited " . ($? >> 8) . ": $!\n";
        }