diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-09-11 17:43:38 -0700 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-09-11 17:43:38 -0700 |
commit | 1a3bf7a3d714f4205c12db0b1cdfe5f2f36a6a3b (patch) | |
tree | 0e45eceb7fc75957636aef501948e9f36c917cef | |
parent | eeccbfe6ece196ab29d51bf070f805e75a83a43e (diff) | |
download | nasm-1a3bf7a3d714f4205c12db0b1cdfe5f2f36a6a3b.tar.gz nasm-1a3bf7a3d714f4205c12db0b1cdfe5f2f36a6a3b.tar.xz nasm-1a3bf7a3d714f4205c12db0b1cdfe5f2f36a6a3b.zip |
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>
-rwxr-xr-x | asm/warnings.pl | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/asm/warnings.pl b/asm/warnings.pl index 6660d17a..11356860 100755 --- a/asm/warnings.pl +++ b/asm/warnings.pl @@ -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); |