On Wed, 5 Sep 2001, Doug MacEachern wrote:

> On Thu, 6 Sep 2001, Stas Bekman wrote:
>
> > something like that. We need to disregard: 'Sun Aug 19 10:32:24 2001'
>
> that would be fine.  as i suggested eariler, feel free to change the
> format of that header which includes the date to make it easier to rip
> this stuff out.  i'd rather see this than a .info file and the .tmp
> mv-if-diff stuff.

OK, can somebody test this patch? the latest httpd source fails to get
parsed for me (via 'make source_scan'), so I cannot verify my patch.

Thanks.

Index: lib/Apache/ParseSource.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/ParseSource.pm,v
retrieving revision 1.25
diff -u -r1.25 ParseSource.pm
--- lib/Apache/ParseSource.pm   2001/09/06 05:26:52     1.25
+++ lib/Apache/ParseSource.pm   2001/09/06 14:43:55
@@ -410,8 +410,6 @@
         $file = "$tdir/$subdir/$file";
     }

-    open my $pm, '>', $file or die "open $file: $!";
-
     # sort the hashes (including nested ones) for a consistent dump
     canonsort(\$data);

@@ -422,7 +420,7 @@
     my $version = $self->VERSION;
     my $date = scalar localtime;

-    print $pm <<EOF;
+    my $new_content = << "EOF";
 package $name;

 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -435,7 +433,30 @@

 1;
 EOF
-    close $pm;
+
+    my $old_content = '';
+    if (-e $file) {
+        open my $pm, '<', $file or die "open $file: $!";
+        local $/ = undef; # slurp the file
+        $old_content = <$pm>;
+        close $pm;
+    }
+
+    my $overwrite = 1;
+    if ($old_content) {
+        # strip the date line, which will never be the same before
+        # comparing
+        (my $old = $old_content) =~ s/\w{3} \w{3} \d+ \d+:\d+:\d+ \d{4}//;
+        (my $new = $new_content) =~ s/\w{3} \w{3} \d+ \d+:\d+:\d+ \d{4}//;
+        $overwrite = 0 if $old eq $new;
+    }
+
+    if ($overwrite) {
+        open my $pm, '>', $file or die "open $file: $!";
+        print $pm $new_content;
+        close $pm;
+    }
+
 }

 # canonsort(\$data);




_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to