On Tue, Jul 25, 2017 at 08:54:15PM +0000, Klemens Nanni wrote: > On Tue, Jul 25, 2017 at 09:43:48PM +0100, Stuart Henderson wrote: > > On 2017/07/25 20:57, Klemens Nanni wrote: > > > I didn't touch the manual's first sentence mentioning file(1)'s version > > > since nicm@ reimplemented file(1) with revision 1.11 on 2015/04/24. He > > > or someone else more knowledgable in this regard might want to bump it > > > accordingly. > > > > OpenBSD's /etc/magic doesn't match that provided with any particular > > version of file, parts have been updated as people have run into a need > > or bug, but there's been no wholesale update. Perhaps this would do? > > > > diff --git usr.bin/file/magic.5 usr.bin/file/magic.5 > > index 812c4c31095..f9ea22c3cc4 100644 > > --- usr.bin/file/magic.5 > > +++ usr.bin/file/magic.5 > > @@ -41,10 +41,9 @@ > > This manual page documents the format of the magic file as > > used by the > > .Xr file 1 > > -command, version 4.24. > > -The > > +command. > > .Xr file 1 > > -command identifies the type of a file using, > > +identifies the type of a file using, > > among other tests, > > a test for whether the file contains certain > > .Dq "magic patterns" . > Already thought as much, looks fine to me. > > > > -.Dd $Mdocdate: April 24 2016 $ > > > +.Dd $Mdocdate: July 25 2017 $ > > > > btw, it's better to leave the CVS keywords ($Mdocdate$, $OpenBSD$, etc) > > alone, changing them guarantees a conflict if commits are made to the file. > Ah, sure (I knew about this in my first diff). Here's an updated diff I simply forgot to send back then.
Feedback, more comments or improvements? diff --git a/usr.bin/file/magic.5 b/usr.bin/file/magic.5 index 812c4c31095..b2f3a27671a 100644 --- a/usr.bin/file/magic.5 +++ b/usr.bin/file/magic.5 @@ -41,10 +41,9 @@ This manual page documents the format of the magic file as used by the .Xr file 1 -command, version 4.24. -The +command. .Xr file 1 -command identifies the type of a file using, +identifies the type of a file using, among other tests, a test for whether the file contains certain .Dq "magic patterns" . @@ -218,6 +217,28 @@ This is intended to be used with the test .Em x (which is always true) and a message that is to be used if there are no other matches. +.It Dv clear +This test is always true and clears the match flag for that level. +It is intended to be used with the default test. +.It Dv name +Define a named magic instance that can be called from another +.Dv use +magic entry, like a subroutine call. +Named instance direct magic offsets are relative to the offset of the +previous matched entry, but indirect offsets are relative to the +beginning of the file as usual. +Named magic entries always match. +.It Dv use +Recursively call the named magic starting from the current offset. +If the name of the referenced instance begins with a +.Dv ^ +then the endianness of the magic is switched; if the magic mentioned +.Dv leshort +for example, +it is treated as +.Dv beshort +and vice versa. +This is useful to avoid duplicating the rules for different endianness. .El .Pp Each top-level magic pattern (see below for an explanation of levels)
