From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Some vars now limited to fixnum size. (Was: Merging bignum to master) Date: Mon, 20 Aug 2018 10:27:34 -0700 Organization: UCLA Computer Science Department Message-ID: <31ba6457-6428-efc7-8423-1d6134c8e747@cs.ucla.edu> References: <877ekwu1mn.fsf@tromey.com> <611579fd-52f2-0104-ef82-a7a4a3929700@cs.ucla.edu> <878t51t32a.fsf_-_@red-bean.com> <28fcabff-d102-d67f-442f-f59eab5040c9@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------C288A18146639E97CBFEAE19" X-Trace: blaine.gmane.org 1534785989 9101 195.159.176.226 (20 Aug 2018 17:26:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Aug 2018 17:26:29 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cc: tom@tromey.com, Pip Cet , emacs-devel@gnu.org To: Karl Fogel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 20 19:26:25 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frnwe-0002FV-LU for ged-emacs-devel@m.gmane.org; Mon, 20 Aug 2018 19:26:24 +0200 Original-Received: from localhost ([::1]:48325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frnyl-0008G6-5T for ged-emacs-devel@m.gmane.org; Mon, 20 Aug 2018 13:28:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frnxv-0008Cj-Pp for emacs-devel@gnu.org; Mon, 20 Aug 2018 13:27:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frnxr-0002wA-MT for emacs-devel@gnu.org; Mon, 20 Aug 2018 13:27:43 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1frnxq-0002tL-FA for emacs-devel@gnu.org; Mon, 20 Aug 2018 13:27:39 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1B2751610C0; Mon, 20 Aug 2018 10:27:36 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Yw4VAFKUG9wf; Mon, 20 Aug 2018 10:27:35 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2A77F1615A6; Mon, 20 Aug 2018 10:27:35 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zIZW3BIeBjQu; Mon, 20 Aug 2018 10:27:35 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C04611610C0; Mon, 20 Aug 2018 10:27:34 -0700 (PDT) In-Reply-To: <28fcabff-d102-d67f-442f-f59eab5040c9@cs.ucla.edu> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228753 Archived-At: This is a multi-part message in MIME format. --------------C288A18146639E97CBFEAE19 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Paul Eggert wrote: > Karl Fogel wrote: >> My proposal would be to at least document it for `nthcdr' > > It would be better to fix nthcdr so that it works on bignums ... and I did that by installing the attached patch. Thanks for reporting the problem. It's helpful to see which functions should have higher priority for fixing these sorts of glitches. If you're bitten by similar glitches in other functions please let us know. --------------C288A18146639E97CBFEAE19 Content-Type: text/x-patch; name="0001-nthcdr-now-works-with-bignums.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-nthcdr-now-works-with-bignums.patch" >From 21397837eaf0801e7b1cd4155a811a939a7667de Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 20 Aug 2018 10:24:19 -0700 Subject: [PATCH] nthcdr now works with bignums Problem reported by Karl Fogel in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00671.html * src/fns.c (Fnthcdr): Support bignum counts. --- src/fns.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/fns.c b/src/fns.c index a11de1b082..aeb9308d22 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1402,9 +1402,20 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0, doc: /* Take cdr N times on LIST, return the result. */) (Lisp_Object n, Lisp_Object list) { - CHECK_FIXNUM (n); + CHECK_INTEGER (n); Lisp_Object tail = list; - for (EMACS_INT num = XFIXNUM (n); 0 < num; num--) + + EMACS_INT num; + if (FIXNUMP (n)) + num = XFIXNUM (n); + else + { + num = mpz_sgn (XBIGNUM (n)->value); + if (0 < num) + num = EMACS_INT_MAX; /* LIST cannot possibly be this long. */ + } + + for (; 0 < num; num--) { if (! CONSP (tail)) { -- 2.17.1 --------------C288A18146639E97CBFEAE19--