From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: ptrdiff_t misuse Date: Fri, 06 Jul 2012 11:34:37 +0300 Message-ID: <83k3yh2spu.fsf@gnu.org> References: <83lij66yq9.fsf@gnu.org> <4FEDB953.1010800@yandex.ru> <4FEEA720.2040405@cs.ucla.edu> <4FEEFBAB.6000404@cs.ucla.edu> <4FF3E1D6.1050103@cs.ucla.edu> <83bojv4h13.fsf@gnu.org> <4FF48920.501@cs.ucla.edu> <83vci22mr0.fsf@gnu.org> <83obnu2e8s.fsf@gnu.org> <4FF62C92.8090406@cs.ucla.edu> <83liix2xvp.fsf@gnu.org> <4FF69476.2070701@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1341563721 5076 80.91.229.3 (6 Jul 2012 08:35:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 6 Jul 2012 08:35:21 +0000 (UTC) Cc: dmantipov@yandex.ru, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 06 10:35:20 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sn40T-0002C1-RZ for ged-emacs-devel@m.gmane.org; Fri, 06 Jul 2012 10:35:17 +0200 Original-Received: from localhost ([::1]:32809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn40P-0004Fm-Su for ged-emacs-devel@m.gmane.org; Fri, 06 Jul 2012 04:35:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn40J-0004BJ-5V for emacs-devel@gnu.org; Fri, 06 Jul 2012 04:35:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sn40C-0001X9-Dp for emacs-devel@gnu.org; Fri, 06 Jul 2012 04:35:06 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:59674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn40C-0001Ww-5i for emacs-devel@gnu.org; Fri, 06 Jul 2012 04:35:00 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0M6Q00900D5EBI00@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Fri, 06 Jul 2012 11:34:33 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.210.75]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M6Q009K7D5KBG00@a-mtaout20.012.net.il>; Fri, 06 Jul 2012 11:34:33 +0300 (IDT) In-reply-to: <4FF69476.2070701@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.166 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151446 Archived-At: > Date: Fri, 06 Jul 2012 00:32:06 -0700 > From: Paul Eggert > CC: dmantipov@yandex.ru, monnier@iro.umontreal.ca, emacs-devel@gnu.org > > On 07/05/2012 11:43 PM, Eli Zaretskii wrote: > > The value of 'hscroll' comes from Lisp, > > so it's in the range of an EMACS_INT. > > Why not treat it as such? > > > > For that matter, why not change 'hscroll' in 'struct window' to > > EMACS_INT as well? > > I would prefer that, yes. Although Stefan said last week that > hscroll should be 'int' > > on the grounds that hscroll values greater than INT_MAX don't work > anyway, perhaps that's moot now that you've fixed those problems with > large hscroll values. Stefan, do you object to making hscroll (and other values that come from Lisp) EMACS_INT? I think doing so will naturally and easily avoid the messy tests against max values of several data types where we want to clip values to some reasonable range. So I think it will be a net win in code clarity and maintainability, and will prevent subtle bugs. > If we change hscroll to EMACS_INT, we should also increase the max > hscroll value to MOST_POSITIVE_FIXNUM. It's already that: ptrdiff_t hscroll_max = min (MOST_POSITIVE_FIXNUM, PTRDIFF_MAX); ptrdiff_t new_hscroll = clip_to_bounds (0, hscroll, hscroll_max); (Of course, if we declare these variables EMACS_INT, PTRDIFF_MAX will not be needed anymore.) Or did you mean something else?