From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Byte swapping and bindat Date: Sat, 11 Jun 2022 08:45:16 +0300 Message-ID: <83fskbzrbn.fsf@gnu.org> References: <87pmjglllc.fsf.ref@yahoo.com> <87pmjglllc.fsf@yahoo.com> <83mtekzf9f.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20406"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 11 07:50:19 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nzu0o-00056o-2l for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Jun 2022 07:50:18 +0200 Original-Received: from localhost ([::1]:33324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzu0m-0002pb-F9 for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Jun 2022 01:50:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nztvx-0001aT-Dr for emacs-devel@gnu.org; Sat, 11 Jun 2022 01:45:17 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nztvx-0008RK-4a; Sat, 11 Jun 2022 01:45:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=pZ+mnoV2uYG/Cxb5qHEkWMqv7uqSFxBLqyRbuK2Cyxk=; b=X8QHCdQ/j7X/ lS/oXOh8IKVGHj8xT82HV/SiWY/3ZfIT75ALqBfe/5BOaVnv7DyODTjIc9lSCTknyJKoPLeeMfJl4 ZFqwJqAcxnW7Fh5TGPKwNPtOPQQUWvvdlVbm4LCwGWmq69kMIlg/61MeNeNb1aOZWO0McirfWp3hd z/r8f+gBjdgkuvaSjzM4OBBbQFwWAVnPBXIWj58eXcs7ZIv/bxWKtjpenuHCSvf1yfVuZy+PI4jGZ c5je9VksO3bXXbm3JfUTvCc/AVQywodywA0Qp52WVBuPt+xh0MNe4G2B5D7tYoSgZvXzKI3OURrP/ u82FzN23FL2D8ZgfCMyGsw==; Original-Received: from [87.69.77.57] (port=3973 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nztvw-0001TU-GC; Sat, 11 Jun 2022 01:45:16 -0400 In-Reply-To: (message from Stefan Monnier on Fri, 10 Jun 2022 17:42:41 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:291017 Archived-At: > From: Stefan Monnier > Cc: EMACS development team > Date: Fri, 10 Jun 2022 17:42:41 -0400 > > > It would be nice to have sint documented in the ELisp manual... > > Good point. I think it would also be nice to unify `uint` and `uintr`. > > What about the patch below? Thanks. > -@item uint @var{bitlen} > -Unsigned integer in network byte order, with @var{bitlen} bits. > +@item uint @var{bitlen} &optional @var{le} > +Unsigned integer in network byte order (big-endian), with @var{bitlen} bits. > @var{bitlen} has to be a multiple of 8. > +If @var{le} is non-@code{nil}, then use little-endian. ^^^^^^^^^^^^^^^^^ "use little-endian byte order" is more clear. > -@item uintr @var{bitlen} > -Unsigned integer in little endian order, with @var{bitlen} bits. > +@item sint @var{bitlen} @var{le} > +Signed integer in network byte order (big-endian), with @var{bitlen} bits. > @var{bitlen} has to be a multiple of 8. > +If @var{le} is non-@code{nil}, then use little-endian. Same here. > @@ -849,8 +852,7 @@ bindat-type > "Return the Bindat type value to pack&unpack TYPE. > TYPE is a Bindat type expression. It can take the following forms: > > - uint BITLEN - Big-endian unsigned integer > - uintr BITLEN - Little-endian unsigned integer > + uint BITLEN [LE] - unsigned integer (big-endian if LE is nil) > str LEN - Byte string > strz [LEN] - Zero-terminated byte-string > bits LEN - Bit vector (LEN is counted in bytes) Do we want to say in the doc string that uintr is supported for backward compatibility?