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: Compiling Elisp to a native code with a GCC plugin Date: Fri, 17 Sep 2010 20:49:48 +0200 Message-ID: <83zkvgyzlf.fsf@gnu.org> References: <87bp805ecr.fsf@gmail.com> <87iq26z97e.fsf@uwakimon.sk.tsukuba.ac.jp> <87y6b0yi8o.fsf@uwakimon.sk.tsukuba.ac.jp> <87sk18bioh.fsf@lola.goethe.zz> <87fwx8bhkq.fsf@lola.goethe.zz> <83fwx81gzp.fsf@gnu.org> <83bp7w1fzd.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1284749822 7815 80.91.229.12 (17 Sep 2010 18:57:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 17 Sep 2010 18:57:02 +0000 (UTC) Cc: emacs-devel@gnu.org To: Lars Magne Ingebrigtsen , Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 17 20:57:01 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Owg7D-0007gn-6S for ged-emacs-devel@m.gmane.org; Fri, 17 Sep 2010 20:56:55 +0200 Original-Received: from localhost ([127.0.0.1]:55521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Owg7C-0001VL-IO for ged-emacs-devel@m.gmane.org; Fri, 17 Sep 2010 14:56:54 -0400 Original-Received: from [140.186.70.92] (port=57283 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Owg6z-0001A7-CM for emacs-devel@gnu.org; Fri, 17 Sep 2010 14:56:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Owg0w-0002x0-2N for emacs-devel@gnu.org; Fri, 17 Sep 2010 14:50:29 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:36675) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Owg0v-0002wo-Qn for emacs-devel@gnu.org; Fri, 17 Sep 2010 14:50:26 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0L8W00B00MPNSW00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Fri, 17 Sep 2010 20:49:45 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([77.126.210.149]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0L8W00BBHMYVFI60@a-mtaout22.012.net.il>; Fri, 17 Sep 2010 20:49:44 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:130354 Archived-At: > From: Lars Magne Ingebrigtsen > Date: Fri, 17 Sep 2010 19:30:52 +0200 > > Right. Things like > > int pt = PT; > > in buffer.c is easy enough, but is the following (from insdel.c) > correct? > > int b = XINT (Fmarker_position (current_buffer->mark)); I think it's a bug, should use "EMACS_INT b". > int e = XINT (make_number (PT)); > > I don't really understand the last line at all. It first creates a > Lisp_Object number from PT, and then gets the C-level EMACS_INT value > from that again? And then casts it to an int? I think it's a bug, should use "EMACS_INT e = PT;" As for why it converts it to Lisp integer and then back to a C EMACS_INT: it seems to be a historical curiosity. Revision 101018 made this change: === modified file 'src/insdel.c' --- src/insdel.c 2010-08-07 19:39:04 +0000 +++ src/insdel.c 2010-08-07 20:26:55 +0000 @@ -2055,13 +2055,12 @@ prepare_to_modify_buffer (EMACS_INT star && !NILP (Vtransient_mark_mode) && NILP (Vsaved_region_selection)) { - Lisp_Object b = Fmarker_position (current_buffer->mark); - Lisp_Object e = make_number (PT); - if (NILP (Fequal (b, e))) - { - validate_region (&b, &e); - Vsaved_region_selection = make_buffer_string (XINT (b), XINT (e), 0); - } + int b = XINT (Fmarker_position (current_buffer->mark)); + int e = XINT (make_number (PT)); + if (b < e) + Vsaved_region_selection = make_buffer_string (b, e, 0); + else if (b > e) + Vsaved_region_selection = make_buffer_string (e, b, 0); } I guess the change mechanically used XINT to move the comparison to C-level integers, but didn't pay attention to the fact that it would be easier to just remove the make_number call and use PT directly. Chong, did I miss something?