Hi

On Thu, Jun 29, 2017 at 09:29:57PM +0200, Klemens Nanni wrote:
> While reading file(1)'s code in #openbsd-daily mulander noted that the
> 'name' and 'use' types were missing from magic(5).
> 
> I'm not entirely sure yet whether this is complete, so here's what I
> did:
> 
> magic(5) provided by devel/magic documents version 5.31 while base's
> magic(5) is at 4.24. Here are the types found in 5.31 but not ours as
> well as those of the missing ones that are actually implemented but
> undocumented as of now:
> 
>       $ grep -i "TYPE_($(grep -F 'It Dv' $(man -w magic) |
>               cut -d' ' -f3 | sort | uniq -u | paste -sd\| - |
>               tee /dev/stderr))" magic.h
>       beid3|beqwdate|clear|indirect|leid3|leqwdate|name|qwdate|use
>               MAGIC_TYPE_CLEAR,
>               MAGIC_TYPE_NAME,
>               MAGIC_TYPE_USE,
> 
> What about the current version being 4.21? We're clearly ahead of this,
> it seems magic(5) wasn't updated when nicm@ reimplemented things.
> 
> This patch documents the respective types.

Did you copy this text from upstream or write it?

Some comments inline.

> Feedback/OK?
> 
> Index: magic.5
> ===================================================================
> RCS file: /cvs/src/usr.bin/file/magic.5,v
> retrieving revision 1.17
> diff -u -p -r1.17 magic.5
> --- magic.5   24 Apr 2016 07:02:07 -0000      1.17
> +++ magic.5   29 Jun 2017 17:41:56 -0000
> @@ -218,6 +218,31 @@ This is intended to be used with the tes
> .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 continuation
> +level.

I would just say "that level" or "the test's level" not "that
continuation level" because there is no previous mention of
"continuation".

> +It is intended to be used with the default test.
> +.It Dv name
> +Define a
> +.Dq named

I don't think quotation marks are necessary here.

> +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 begins with a

"the referenced instance" would be better than "the referenced".

> +.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)

Reply via email to