[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bindat docs on length of str, strz, etc types

From: Kim F. Storm
Subject: Re: bindat docs on length of str, strz, etc types
Date: Thu, 28 Dec 2006 00:06:11 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux)

Kevin Ryde <address@hidden> writes:

> In the "Bindat Spec" node of the lisp manual, the `repeat' type has
>       COUNT may be an integer, or a list of one element that names a
>       previous field.
> If I'm not mistaken that applies to any of the LEN arguments for str,
> strz, etc too (the "Bindat Examples" have some like that).  I wonder
> if the words could be in a more prominent / more general spot.
> And also if I'm not mistaken a form `(eval FOO)' is allowed, for
> calculating a length.  

You are right.  And all (eval FOO) forms can access `last' and
the other items listed only for the last type of eval form.

>                        It'd be nice to describe that.


> I tried it for a jpeg record, where the length field includes itself
> so the data is "length-2" bytes
>       ((marker u16)
>        (length u16)
>        (data   str (eval (- (assoc-default 'length struct) 2))))
> But perhaps there's a cleaner way I missed.

This should work:

        ((marker u16)
         (length u16)
         (data   str (eval (- last 2))))

Kim F. Storm <address@hidden> http://www.cua.dk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]