[File] A few questions regarding the actual semantic of "magic" rules

Marco Antoniotti marcoxa at gmail.com
Sun Jun 30 16:55:45 UTC 2024


Euxaristw gia tin apantisis sas :)

Fine for (1).  For (2) and (3), from your answers, I gather that "use" is
really a function call that should handle a stack.  Ok.
For (4) no I do not an example, and from what I see on my Mac there are no
cases of more than 1 level down calls.

All the best

Marco



On Sun, Jun 30, 2024 at 5:00 PM Christos Zoulas <christos at zoulas.com> wrote:

>
>
> On Jun 3, 2024, at 5:30 AM, Marco Antoniotti <marcoxa at gmail.com> wrote:
>
> Hi
>
>
> Thank you for supporting this tool for so many years.
>
>
> I have a few questions regarding the actual semantics of magic(5) rules.
>
>
> Let me call "group" a set of tests starting at a 0 level test.
>
>    1. My understanding is that each group is checked separately and that,
>    once one of them "succeeds" then the result is printed out and that's it.
>    I am saying this otherwise the "pdf" specification should print out two
>    equal lines on a vanilla PDF file.  Is that correct?
>
> Yes, unless -k is specified the first "group" matched that prints
> something "succeeds".
>
>
>    2. I understood that "name" and "use" rules can span magic(5)
>    boundaries.  Is that correct?
>
>
> That is correct. The program looks for a named rule in all the rules it
> has loaded so far.
>
>
>    3. When I use a "use" clause, what is the state of the position in the
>    file (buffer) after its invocation?  Whether it is successful or not?
>
> IIRC should be restored to what it was before the USE call.
>
>
>    4. Can I "use" a "name" that then uses another "name" etc.  It does
>    not appear to be the case on Mac OS right now.
>
>
> Should be able to. Can you give an example that does not work?
>
> I also believe I found a few problems with some of the magic(5) files; I
> will post them soon.
>
>
> That's it for now.
>
>
> Thanks
>
> Marco
>
> PS  Yes, I am parsing the magic(5) files.  Don't ask!  It's a rabbit hole.
>
>
> The program has organically grown for a very long time, so there are many
> weird corner cases.
>
> christos
>
>

-- 
Marco Antoniotti
Somewhere over the Rainbow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.astron.com/pipermail/file/attachments/20240630/b0215971/attachment.htm>


More information about the File mailing list