From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: bindat docs on length of str, strz, etc types Date: Thu, 28 Dec 2006 00:06:11 +0100 Message-ID: References: <87r6ulq8qs.fsf@zip.com.au> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1167260786 18064 80.91.229.10 (27 Dec 2006 23:06:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 27 Dec 2006 23:06:26 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 28 00:06:23 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1Gzhqo-0003a6-1Y for ged-emacs-devel@m.gmane.org; Thu, 28 Dec 2006 00:06:22 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gzhqn-0002vR-KV for ged-emacs-devel@m.gmane.org; Wed, 27 Dec 2006 18:06:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gzhqa-0002ti-LV for emacs-devel@gnu.org; Wed, 27 Dec 2006 18:06:08 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GzhqZ-0002rz-Bl for emacs-devel@gnu.org; Wed, 27 Dec 2006 18:06:08 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GzhqZ-0002ro-4F for emacs-devel@gnu.org; Wed, 27 Dec 2006 18:06:07 -0500 Original-Received: from [195.41.46.235] (helo=pfepa.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GzhqY-00067d-Jr for emacs-devel@gnu.org; Wed, 27 Dec 2006 18:06:06 -0500 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx19.adsl-dhcp.tele.dk [80.62.38.68]) by pfepa.post.tele.dk (Postfix) with SMTP id E96CEFAC03C; Thu, 28 Dec 2006 00:06:04 +0100 (CET) Original-To: Kevin Ryde In-Reply-To: <87r6ulq8qs.fsf@zip.com.au> (Kevin Ryde's message of "Thu\, 28 Dec 2006 09\:22\:51 +1100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64379 Archived-At: Kevin Ryde 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. Indeed. > > 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 http://www.cua.dk