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: master 37940b3: min and max now return one of their arguments Date: Tue, 7 Mar 2017 21:27:35 -0800 Organization: UCLA Computer Science Department Message-ID: <92047e08-5984-12f2-c285-4017fefac7a3@cs.ucla.edu> References: <20170307012700.3354.30219@vcs0.savannah.gnu.org> <20170307012701.1C05D23F1F@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------FFE945E2ECF17E2443EE92C2" X-Trace: blaine.gmane.org 1488950905 1046 195.159.176.226 (8 Mar 2017 05:28:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 8 Mar 2017 05:28:25 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 To: Glenn Morris , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 08 06:28:19 2017 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 1clU90-0007fW-RS for ged-emacs-devel@m.gmane.org; Wed, 08 Mar 2017 06:28:14 +0100 Original-Received: from localhost ([::1]:54147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clU96-0007Px-Ow for ged-emacs-devel@m.gmane.org; Wed, 08 Mar 2017 00:28:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clU8Z-0007Pf-Su for emacs-devel@gnu.org; Wed, 08 Mar 2017 00:27:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clU8V-0003qD-VB for emacs-devel@gnu.org; Wed, 08 Mar 2017 00:27:47 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1clU8V-0003q4-Le; Wed, 08 Mar 2017 00:27:43 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3EDD9160064; Tue, 7 Mar 2017 21:27:41 -0800 (PST) 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 fDHIcldfeU1n; Tue, 7 Mar 2017 21:27:40 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1CF4A16007A; Tue, 7 Mar 2017 21:27:40 -0800 (PST) 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 5D5BwNqaw0Hs; Tue, 7 Mar 2017 21:27:40 -0800 (PST) Original-Received: from [192.168.1.9] (unknown [47.153.188.248]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id EF874160064; Tue, 7 Mar 2017 21:27:39 -0800 (PST) In-Reply-To: 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:212830 Archived-At: This is a multi-part message in MIME format. --------------FFE945E2ECF17E2443EE92C2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Glenn Morris wrote: > It seems that this change causes a bunch of tests to fail with > > (wrong-type-argument numberp #) Sorry about that. Apparently 'min' and 'max' converted any marker result = to an=20 integer. I changed them back to do that with the attached patch. This beh= avior=20 is undocumented; I don't know whether it was intended, although it looks = like=20 some code relies on it now. --------------FFE945E2ECF17E2443EE92C2 Content-Type: text/x-diff; name="0001-min-and-max-should-not-return-markers.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-min-and-max-should-not-return-markers.patch" =46rom 79825fd06cfd7140c8d6e25db1c0fdc5a42f6098 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 7 Mar 2017 21:23:08 -0800 Subject: [PATCH] min and max should not return markers Problem reported by Glenn Morris in: http://lists.gnu.org/archive/html/emacs-devel/2017-03/msg00147.html * src/data.c (minmax_driver): Convert any marker result to an integer, since some callers assume this. * test/src/data-tests.el (data-tests-max, data-tests-min): Test for this. --- src/data.c | 4 ++-- test/src/data-tests.el | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/data.c b/src/data.c index 29547d8..c480ed2 100644 --- a/src/data.c +++ b/src/data.c @@ -2972,9 +2972,9 @@ minmax_driver (ptrdiff_t nargs, Lisp_Object *args, if (argnum =3D=3D 0 || !NILP (arithcompare (val, accum, comparison= ))) accum =3D val; else if (FLOATP (accum) && isnan (XFLOAT_DATA (accum))) - break; + return accum; } - return accum; + return MARKERP (accum) ? make_number (marker_position (accum)) : accum= ; } =20 DEFUN ("max", Fmax, Smax, 1, MANY, 0, diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 70ffdab..67d00a7 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el @@ -88,7 +88,9 @@ (should (=3D (1+ most-negative-fixnum) (max (float most-negative-fixnum) (1+ most-negative-fixnum)= ))) (should (=3D 8 (apply #'max '(3 8 3)))) - (should-error (max 9 8 'foo))) + (should-error (max 9 8 'foo)) + (should-error (max (make-marker))) + (should (eql 1 (max (point-min-marker) 1)))) =20 (ert-deftest data-tests-min () (should-error (min)) @@ -98,7 +100,9 @@ (should (=3D most-positive-fixnum (min (+ 1.0 most-positive-fixnum) most-positive-fixnum))) (should (=3D 3 (apply #'min '(3 8 3)))) - (should-error (min 9 8 'foo))) + (should-error (min 9 8 'foo)) + (should-error (min (make-marker))) + (should (eql 1 (min (point-min-marker) 1)))) =20 ;; Bool vector tests. Compactly represent bool vectors as hex ;; strings. --=20 2.9.3 --------------FFE945E2ECF17E2443EE92C2--