Implemented keeping of comment-blocks between two lines matching /^$!/ unlabeled-1.1.2
authorshort <>
Sun, 27 Jan 2002 15:28:16 +0000 (15:28 +0000)
committershort <>
Sun, 27 Jan 2002 15:28:16 +0000 (15:28 +0000)
 - needed by /etc/cron.*/.cvslinks files to prevent crond errors
[cs_CZ] Implementovano zachovani komentarovych bloku mezi radky matchujicimi /^$!/
 - potrebne pro soubory /etc/cron.*/.cvslinks pro predejiti chyb od crond

bin/cvslinks

index c96248e..9f77734 100755 (executable)
@@ -57,9 +57,12 @@ sub do_u
        open L,FILENAME or die "File ".FILENAME." cannot be opened: $!";
        do_d();
        verbose "Creating links from ".FILENAME;
+       my $cmt=0;
        while (<L>) {
                chomp;
-               next if /^$/; # empty-file (->empty-dir) stub line
+               my $cmt_old=$cmt;
+               $cmt=!$cmt if /^#!/;
+               next if $cmt || $cmt_old || /^$/; # comment or empty-file (->empty-dir) stub line
                /^(.+)\t(.+)$/ or warn "Unrecognized line: $_";
                verbose "Creating link $1";
                symlink $2,$1 or warn "symlink(\"$2\"->\"$1\"): $!";
@@ -71,9 +74,21 @@ sub do_c
 {
        local(*L,*D);
        opendir D,"." or die "Cannot open directory \".\": $!";
-       open L,">".FILENAME or die "File ".FILENAME." cannot be created: $!";
        verbose "Storing links to ".FILENAME;
-       print L "\n"; # empty-file (->empty-dir) stub line
+       my $cmtblock="";
+       if (open L,FILENAME) {
+               my $cmt=0;
+               while (<L>) {
+                       my $cmt_old=$cmt;
+                       $cmt=!$cmt if /^#!/;
+                       next unless $cmt || $cmt_old; # comment
+                       $cmtblock.=$_;
+                       }
+               close L;
+               }
+       $cmtblock="\n" if !$cmtblock; # empty-file (->empty-dir) stub line
+       open L,">".FILENAME or die "File ".FILENAME." cannot be created: $!";
+       print L $cmtblock;
        for (readdir D) {
                next if ! -l;
                my $target=readlink or die "Cannot read link $_: $!";
@@ -81,6 +96,7 @@ sub do_c
                print L "$_\t$target\n";
                }
        closedir D;
+       close L;
 }
 
 sub descent