aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2014-06-10 22:20:34 -0700
committerH. Peter Anvin <hpa@zytor.com>2014-06-10 22:22:32 -0700
commit51a00c364b645f926910105701c4e2e4d3d34047 (patch)
tree19b1d1efd1faaa252eed5a8bdc8c30ef013ca31b
parentf1b14073efabd58a7aa5911817bb51da96aff1a3 (diff)
downloadabc80-51a00c364b645f926910105701c4e2e4d3d34047.tar.gz
abc80-51a00c364b645f926910105701c4e2e4d3d34047.tar.xz
abc80-51a00c364b645f926910105701c4e2e4d3d34047.zip
data: Add missing script file stripzero.pl
stripzero.pl is used to clean up the tail of cbios.bin. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rwxr-xr-xdata/stripzero.pl21
1 files changed, 21 insertions, 0 deletions
diff --git a/data/stripzero.pl b/data/stripzero.pl
new file mode 100755
index 0000000..d44ea0b
--- /dev/null
+++ b/data/stripzero.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+#
+# Remove trailing zeroes from a file
+#
+
+use bytes;
+
+($file) = @ARGV;
+
+open(FILE, '+<:raw', $file) or die "$0: $file: $!\n";
+
+$l = -s FILE;
+
+while ($l > 0) {
+ seek(FILE, $l-1, 0);
+ last if (read(FILE, $d, 1) != 1 || $d ne "\0");
+ $l--;
+}
+truncate(FILE, $l);
+close(FILE);
+exit 0;