mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
warnings.pl: again, don't update the timestamp unless we need to
Don't update the timestamp unless we really have to do so. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
eeccbfe6ec
commit
1a3bf7a3d7
1 changed files with 15 additions and 12 deletions
|
|
@ -279,17 +279,20 @@ if ($what eq 'c') {
|
|||
close($out);
|
||||
|
||||
# Write data to file if and only if it has changed
|
||||
# Windows requires append mode here
|
||||
open($out, '+>>', $outfile)
|
||||
or die "$0: cannot open output file $outfile: $!\n";
|
||||
my $datalen = length($outdata);
|
||||
my $oldlen = read($out, my $oldoutdata, $datalen+1);
|
||||
if (!defined($oldlen) || $oldlen != $datalen ||
|
||||
!($oldoutdata eq $outdata)) {
|
||||
# Data changed, must rewrite
|
||||
truncate($out, 0);
|
||||
seek($out, 0, SEEK_SET)
|
||||
or die "$0: cannot rewind output file $outfile: $!\n";
|
||||
print $out $outdata;
|
||||
# For some systems, even if we don't write, opening for append
|
||||
# apparently touches the timestamp, so we need to read and write
|
||||
# as separate operations.
|
||||
if (open(my $out, '<', $outfile)) {
|
||||
my $datalen = length($outdata);
|
||||
my $oldlen = read($out, my $oldoutdata, $datalen+1);
|
||||
close($out);
|
||||
exit 0 if (defined($oldlen) && $oldlen == $datalen &&
|
||||
($oldoutdata eq $outdata));
|
||||
}
|
||||
|
||||
# Data changed, must rewrite
|
||||
open(my $out, '>', $outfile)
|
||||
or die "$0: cannot open output file $outfile: $!\n";
|
||||
|
||||
print $out $outdata;
|
||||
close($out);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue