From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#14005: 24.3.50; cc-mode: Incorrectly-indented C code (wrong syntax). Test case and bisection. Date: Thu, 24 Dec 2015 21:47:34 +0000 Message-ID: <20151224214734.GB5714@acm.fritz.box> References: <87y5di78z5.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1450993590 4880 80.91.229.3 (24 Dec 2015 21:46:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Dec 2015 21:46:30 +0000 (UTC) Cc: 14005-done@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 24 22:46:14 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1aCDi9-0007mm-J6 for geb-bug-gnu-emacs@m.gmane.org; Thu, 24 Dec 2015 22:46:13 +0100 Original-Received: from localhost ([::1]:33504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCDi8-0001Hx-M0 for geb-bug-gnu-emacs@m.gmane.org; Thu, 24 Dec 2015 16:46:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCDi4-0001Gr-TJ for bug-gnu-emacs@gnu.org; Thu, 24 Dec 2015 16:46:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aCDi3-0002Hw-SM for bug-gnu-emacs@gnu.org; Thu, 24 Dec 2015 16:46:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCDhy-0002H9-3Z; Thu, 24 Dec 2015 16:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aCDhx-0007IJ-Mv; Thu, 24 Dec 2015 16:46:01 -0500 Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 24 Dec 2015 21:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 14005 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Mail-Followup-To: 14005@debbugs.gnu.org, acm@muc.de, dima@secretsauce.net Original-Received: via spool by 14005-done@debbugs.gnu.org id=D14005.145099351927983 (code D ref 14005); Thu, 24 Dec 2015 21:46:01 +0000 Original-Received: (at 14005-done) by debbugs.gnu.org; 24 Dec 2015 21:45:19 +0000 Original-Received: from localhost ([127.0.0.1]:33892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aCDhH-0007HG-I3 for submit@debbugs.gnu.org; Thu, 24 Dec 2015 16:45:19 -0500 Original-Received: from mail.muc.de ([193.149.48.3]:39473) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aCDhF-0007H6-NQ for 14005-done@debbugs.gnu.org; Thu, 24 Dec 2015 16:45:18 -0500 Original-Received: (qmail 74611 invoked by uid 3782); 24 Dec 2015 21:45:16 -0000 Original-Received: from acm.muc.de (p548A5291.dip0.t-ipconnect.de [84.138.82.145]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 24 Dec 2015 22:45:15 +0100 Original-Received: (qmail 6391 invoked by uid 1000); 24 Dec 2015 21:47:34 -0000 Content-Disposition: inline In-Reply-To: <87y5di78z5.fsf@secretsauce.net> User-Agent: Mutt/1.5.23 (2014-03-12) 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:110353 Archived-At: Hello, Dima. The problem is no longer apparent in the current emacs-25 branch at savannah, so I'm closing this bug as fixed. On Tue, Mar 19, 2013 at 10:48:14PM -1000, Dima Kogan wrote: > I'm observing very uninteresting-looking C code get > incorrectly-indented. The sample source file (attached) ends with the > following function: > static Matrix *NonMaximalSuppression(Matrix *strength, Matrix *orientation) > { > int x, y, i, rows = strength->rows, cols = strength->cols; > int pixels = strength->rows * strength->cols, maximum; > double str1, str2; /* interpolated edge strength */ > double a1, a2, b1, b2, c1, c2; /* nearest pixels' edge strength */ > float ux, uy; /* weights of a, b, c, and str */ > double ori, str; /* strength and orientation at center */ > Matrix *newstrength; > /* Newstrength holds the NMS'ed strength values */ > newstrength = (Matrix *)malloc(sizeof(Matrix)); > newstrength->rows = strength->rows; > newstrength->sheets = 1; > newstrength->cols = strength->cols; > newstrength->ptr = (double *)calloc(pixels, sizeof(double)); > return(newstrength); > } > I'm observing that everything after the /* Newstrength .... */ comment > gets "string" syntax, which is incorrect. This can be seen with > (c-guess-basic-syntax). This also causes incorrect indentation of the > empty line before the return statement (TAB there should move to column > 2, but it stays at 0). > The full test source file is attached (called "tst.c"). This is a slight > modification of the source from http://ai.stanford.edu/~ruzon/compass/. > This test case is much longer than I'd like, but the bug appears to be > very sensitive to preceding code, so I'm leaving it alone. > To observe the issue, you can run > $ emacs -Q --batch --eval '(progn (find-file "/tmp/tst.c") (goto-char > 6072) (message "%s" (c-guess-basic-syntax))) > The right answer is "statement", but the current version of emacs says > "string". I did a bisection. This problem was introduced in early 2012 > with this commit: > http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=b0b68fedb6a6fe7bc55c1fe4f256bda9a93134b5 > This means that all releases of emacs 24 are affected. > Thanks. -- Alan Mackenzie (Nuremberg, Germany).