From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#24870: 26.0.50; parse-partial-sexp ignores comment-end Date: Wed, 14 Dec 2016 19:56:23 +0000 Message-ID: <20161214195623.GA3881@acm.fritz.box> References: <7cb86247-1e30-f029-0b9b-c53cc096ec4b@easy-emacs.de> <87mvggh2hu.fsf@users.sourceforge.net> <87h967cj0f.fsf@users.sourceforge.net> <87eg1bcg0y.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1481745432 30005 195.159.176.226 (14 Dec 2016 19:57:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 14 Dec 2016 19:57:12 +0000 (UTC) User-Agent: Mutt/1.5.24 (2015-08-30) Cc: 24870@debbugs.gnu.org, Matt Armstrong To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 14 20:57:08 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1cHFfn-0006xQ-KS for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Dec 2016 20:57:07 +0100 Original-Received: from localhost ([::1]:49859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cHFfr-0001aI-Qg for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Dec 2016 14:57:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cHFfm-0001WE-N8 for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2016 14:57:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cHFfi-0006Dn-Rm for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2016 14:57:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cHFfi-0006Dh-Nh for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2016 14:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cHFfi-000059-84 for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2016 14:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Dec 2016 19:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24870 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 24870-submit@debbugs.gnu.org id=B24870.148174540732753 (code B ref 24870); Wed, 14 Dec 2016 19:57:02 +0000 Original-Received: (at 24870) by debbugs.gnu.org; 14 Dec 2016 19:56:47 +0000 Original-Received: from localhost ([127.0.0.1]:42136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHFfT-0008WD-6m for submit@debbugs.gnu.org; Wed, 14 Dec 2016 14:56:47 -0500 Original-Received: from ocolin.muc.de ([193.149.48.4]:44684 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1cHFfR-0008W4-2O for 24870@debbugs.gnu.org; Wed, 14 Dec 2016 14:56:45 -0500 Original-Received: (qmail 53541 invoked by uid 3782); 14 Dec 2016 19:56:43 -0000 Original-Received: from acm.muc.de (p548C778A.dip0.t-ipconnect.de [84.140.119.138]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 14 Dec 2016 20:56:42 +0100 Original-Received: (qmail 3995 invoked by uid 1000); 14 Dec 2016 19:56:23 -0000 Content-Disposition: inline In-Reply-To: <87eg1bcg0y.fsf@users.sourceforge.net> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:127041 Archived-At: Hello, Noam. On Tue, Dec 13, 2016 at 11:04:45PM -0500, npostavs@users.sourceforge.net wrote: > npostavs@users.sourceforge.net writes: > > I have tracked the issue down to scan_sexps_forward in syntax.c > Applying this change which reverts part of [1] seems to fix the issue: > --- i/src/syntax.c > +++ w/src/syntax.c > @@ -3192,7 +3192,11 @@ scan_sexps_forward (struct lisp_parse_state *state, > while (from < end) > { > - if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) > + INC_FROM; > + code = prev_from_syntax & 0xff; > + > + if (from < end > + && SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) > && (c1 = FETCH_CHAR (from_byte), > syntax = SYNTAX_WITH_FLAGS (c1), > SYNTAX_FLAGS_COMSTART_SECOND (syntax))) > @@ -3213,8 +3217,6 @@ scan_sexps_forward (struct lisp_parse_state *state, > } > else > { > - INC_FROM; > - code = prev_from_syntax & 0xff; > if (code == Scomment_fence) > { > /* Record the comment style we have entered so that only > Alan, can you explain what the idea behind that change was? We're talking about 9dcf5998935c8aaa846d7585b81f0dcfe1935b3d from Sun Mar 20 13:19:48 2016 +0000, still? The idea is that in a (parse-partial-sexp from to), the end position might be in the middle of a two character comment marker, such as "/*". Before this change, it was impossible successfully to use the result of that operation as the old state for continuing parse-partial-sexp from that position, since it did not contain enough info to see it was in a comment after passing the "*" The change 9dcf599 added an extra element onto the parse state which was non-nil when we end up after a "/", etc. > I think it might correspond to this part of the commit message: > Reformulate code at the top of the main loop correctly to > recognize comment openers when starting in the middle of one. > [1]: 9dcf5998935c Sun Mar 20 13:19:48 2016 +0000 > "Amend parse-partial-sexp correctly to handle two character comment delimiters" With the above in mind, I think we should both check your proposed patch to make sure it doesn't break the working of 9dcf599. Thanks for Cc'ing me in on this. -- Alan Mackenzie (Nuremberg, Germany).