Z-code files must have a Z-machine number between 1 and 8 inclusive;
adding a sanity check for that fixes the issue; the MP3 file in
question is properly detected now. Incidentally, the fix also gets rid
of the need to have a "(false match)" message; the file in question
(inbig5.ocp from texlive-omega) matches as a "version 0" Z-machine
file; there's no such thing, so we can drop that match; it now matches
simply as "data". Please let me know if there are any changes I should
make to the patch, or if you have any other files which erroneously
match the Z-machine magic.

The attached patch against current git adds a new dpatch to make the
adventure magic more specific.

Adam Buchbinder
From 2eb950ff768a0ab586b10e1b66195dfc785fe17f Mon Sep 17 00:00:00 2001
From: Adam Buchbinder <adam.buchbin...@gmail.com>
Date: Tue, 17 Feb 2009 10:01:18 -0500
Subject: [PATCH] Fix false matches against Z-machine pattern.

A particular MP3 file as well as a particular file from texlive-omega
match the pattern for Z-machine games. Make the pattern a bit more
restrictive to get rid of the false matches. (Closes: #499748)
---
 debian/patches/00list                            |    1 +
 debian/patches/220-magic-update-adventure.dpatch |   43 ++++++++++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)
 create mode 100755 debian/patches/220-magic-update-adventure.dpatch

diff --git a/debian/patches/00list b/debian/patches/00list
index 82c74bf..1dff685 100644
--- a/debian/patches/00list
+++ b/debian/patches/00list
@@ -16,6 +16,7 @@
 217-magic-update-ruby.dpatch
 218-magic-update-gimp.dpatch
 219-magic-update-wav.dpatch
+220-magic-update-adventure.dpatch
 320-magic-add-par2.dpatch
 321-magic-add-pe5.dpatch
 322-magic-add-pmenu.dpatch
diff --git a/debian/patches/220-magic-update-adventure.dpatch b/debian/patches/220-magic-update-adventure.dpatch
new file mode 100755
index 0000000..37407ef
--- /dev/null
+++ b/debian/patches/220-magic-update-adventure.dpatch
@@ -0,0 +1,43 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 220-magic-update-adventure.dpatch by Adam Buchbinder <adam.buchbin...@gmail.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix some false matches against the Z-machine pattern. (Closes: #499748)
+
+...@dpatch@
+diff -urNad file~/magic/Magdir/adventure file/magic/Magdir/adventure
+--- file~/magic/Magdir/adventure	2009-02-16 10:59:52.000000000 -0500
++++ file/magic/Magdir/adventure	2009-02-17 09:58:00.000000000 -0500
+@@ -17,17 +17,23 @@
+ #------------------------------------------------------------------------------
+ # Z-machine:  file(1) magic for Z-machine binaries.
+ #
+-# This will match ${TEX_BASE}/texmf/omega/ocp/char2uni/inbig5.ocp which
+-# appears to be a version-0 Z-machine binary.
++# Updated by Adam Buchbinder <adam.buchbin...@gmail.com>
+ #
+-# The (false match) message is to correct that behavior.  Perhaps it is
+-# not needed.
++# The first byte is the Z-machine revision; it is always between 1 and 8. We
++# had false matches (for instance, inbig5.ocp from the Omega TeX extension as
++# well as an occasional MP3 file), so we sanity-check the version number.
+ #
+-16	belong&0xfe00f0f0	0x3030	Infocom game data
+->0	ubyte			0	(false match)
+->0	ubyte			>0	(Z-machine %d,
+->>2	ubeshort		x	Release %d /
+->>18	string			>\0	Serial %.6s)
++# It might be possible to sanity-check the release number as well, as it seems
++# (at least in classic Infocom games) to always be a relatively small number,
++# always under 150 or so, but as this isn't rigorous, we'll wait on that until
++# it becomes clear that it's needed.
++#
++0	ubyte			>0
++>0	ubyte			<9
++>>16	belong&0xfe00f0f0	0x3030	Infocom game data
++>>>0	ubyte			x	(Z-machine %d,
++>>>>2	ubeshort		x	Release %d /
++>>>>18	string			>\0	Serial %.6s)
+ 
+ #------------------------------------------------------------------------------
+ # Glulx:  file(1) magic for Glulx binaries.
-- 
1.5.6.3

Reply via email to