From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.help Subject: Re: Byte swapping and bindat Date: Sat, 11 Jun 2022 08:54:53 +0800 Message-ID: <87edzwkoiq.fsf@yahoo.com> References: <87pmjglllc.fsf.ref@yahoo.com> <87pmjglllc.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26683"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: Stefan Monnier To: Stefan Monnier via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 11 02:57:04 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nzpR1-0006kH-9o for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 11 Jun 2022 02:57:03 +0200 Original-Received: from localhost ([::1]:53672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzpQz-0003LN-B9 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 10 Jun 2022 20:57:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzpPB-0003JP-6p for help-gnu-emacs@gnu.org; Fri, 10 Jun 2022 20:55:10 -0400 Original-Received: from sonic307-10.consmr.mail.ne1.yahoo.com ([66.163.190.33]:33193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzpP9-0002Ce-AV for help-gnu-emacs@gnu.org; Fri, 10 Jun 2022 20:55:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1654908902; bh=CRpZHGrnmLPiqGoNS1l36U7RCgsdohWo0QqAvjnU4Hg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=NliYH3ilcFeGbbwUs/HClIPJ4rXoIgsa/uZBddM1PY9cFWFJoEumeVezl63ZI+D/JL+w9P+VpLeHx+7Im27CRlkHMRM0M1V5F9sAeDyal3c/D4LZvTfsY+dUc2fJWt7bqF1ANYKV5t4YeFd8glCahtQ0xsz5aI/un55h/1JtaVrZY6khOHXijqyOkxKq/HNugx9Au9tS58RKBptyf+IVArs2fvGShy2PVZZf/+PYQ03xSujexSmWTvzC4YBY2OQP88Qzzc/XNHpMVRi4obNY0T/2Ocp4BReJXkOP61vH4Mbp5jaic4yhMuw2eFd2tGlB6as+hspeMxZ4HVMFGhUWLg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1654908902; bh=nlkJ0OXlSTGq1Cl6Oi3nOx39Zvv0vJxv1dj7sLUMlnd=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=ot8tQ63AecogS/Oc/XqRhi+6wPfShmtekFWVgHh/2ujmnsla/yK2ukZ9ApFI2O2VIYTU2JKRANvF97TYNMtx00kJJJsKr1K+asetLYurgz5QsXSSmQk+3zht1TmVsCQttCui6hpyRVLNeF8kfbeFvDbWIWav1qwbnJcT/EyZN+ZZFYI+cWYe4CIGMf6UpaaAN/gkLHFJje6lv/f6zy6nIEG2OvFK/UoThRbOMgMYUK2p3AdqtYMpNmys1iKyn31Ifk/dhOQ6YFFZFjkO7IyH1GDpKJUGE1NCUUwphhiLublfWomqEJVQBczRgLAbJcYIHFkIh/UNpl5DBDv3Yc7i7A== X-YMail-OSG: sXHAf3sVM1l0eQpABEija.aYauEDSNAxZN2TZYfNaWs39VqSWPYeNNRW06.Ym7K ACrWlUQf3RfWosauwDVEaEJAPjkQKbKLc6hQHNNS9HG9AMYMal7VmNeO26kMsTNlm2tQyTOq7Mbx RFhWZ9wBbLNN3RMF7snVwvEhkmM3SwwyXWqUZz3C0xRr2z8JA2Jsf95DuLbfaEQE_ZcC3IaEomyQ wLzrr1Dw8q5bfoimPKfBiS4t1pJa.ELzbzoo0B_ZXiU0mgw6wXGkgEmnCn1UibsZz.d2glyu2jak rfPYBnlCWRyjYhja7Y.g5w_jbVwlpIkjoEWxl08o5dGPhAhJKv6Oqh9AH5Y8HkjeBGzzqFvlDDBP aC23PGl40WGt3BvEafHAI.jR9JFnPDMVF05GHPMJgZrN8u_4B8OQKHQj08_vl3HDtDg1ARgH0a4y 881pJO7iHo8AHojxk3imU0ustrvOUCrQMsqUGkEAQR6a38Knx7cd_o43l4BHSbl5W_f0Bp9PDbg3 c8upWzOUQzhWz8LlnIX_goZ1lJie._J2.lNDOsUeZWI7A5CaNg8SJtDuZVx7..aShfqS5dX8sf93 XTxBA2fJiwTc_vMtAn1eZTu9G_neQkzhOKldbm03Cn9sNVi4.dezylVo.5gFHWtwKnfti5RWbN87 SyapQc4zo9ESKw_9fZMmWL6BbFz3DIuTw9hd2gxuHBuxpEbkjGEb_mi7KDevQh4LFTl.gdapsYOf fxsQa6Bdhb5gIIS8cQloqImwUVB2Chvwxi6Qnccj2wIByL4BK4w8TosriDIuu1bMrHS3wtt8_o9T E3DyQ1YEX2X9n7K0M3iHOgEdKNQ6rH.8pRIku3vhib X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ne1.yahoo.com with HTTP; Sat, 11 Jun 2022 00:55:02 +0000 Original-Received: by hermes--canary-production-sg3-5f7658c994-6jtvl (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 5ba9753ec7fcf3eb424f7d9377cfaf59; Sat, 11 Jun 2022 00:54:57 +0000 (UTC) In-Reply-To: (Stefan Monnier via Users list for the's message of "Fri, 10 Jun 2022 09:32:31 -0400") X-Mailer: WebService/1.1.20280 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.190.33; envelope-from=luangruo@yahoo.com; helo=sonic307-10.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:137642 Archived-At: Stefan Monnier via Users list for the GNU Emacs text editor writes: >> Is there a way to specify a bindat type with fields whose endianess >> depends on an external parameter (or another field of the type?) > > I'm so glad you asked: > > (let* ((threshold 32) > (type (bindat-type (kind uint 8) > (length sint 32 (> kind threshold))))) > (list (bindat-unpack type "\x10\x00\x00\x01\x01") > (bindat-unpack type "\x80\x00\x00\x01\x01"))) > => > (((kind . 16) (length . 257)) > ((kind . 128) (length . 16842752))) > > That's one of the benefits of the new Bindat :-) Thanks. Where is that documented? (And what about an unsigned integer? Is it just `uint', which according to the doc is a big-endian number?)