GNU bug report logs - #45160
27.1; [C] wrong indent for knr-style arguments declaration

Previous Next

Packages: emacs, cc-mode;

Reported by: Bruno <braoult <at> gmail.com>

Date: Thu, 10 Dec 2020 15:03:01 UTC

Severity: normal

Found in version 27.1

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Bruno <braoult <at> gmail.com>
Subject: bug#45160: closed (Re: bug#45160: 27.1; [C] wrong indent for
 knr-style arguments declaration)
Date: Sat, 12 Dec 2020 14:49:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#45160: 27.1; [C] wrong indent for knr-style arguments declaration

which was filed against the emacs,cc-mode package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 45160 <at> debbugs.gnu.org.

-- 
45160: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=45160
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Alan Mackenzie <acm <at> muc.de>
To: Bruno Raoult <braoult <at> gmail.com>
Cc: 45160-done <at> debbugs.gnu.org, acm <at> muc.de
Subject: Re: bug#45160: 27.1; [C] wrong indent for knr-style arguments
 declaration
Date: Sat, 12 Dec 2020 14:48:52 +0000
Hello again, Bruno.

On Fri, Dec 11, 2020 at 20:22:19 +0100, Bruno Raoult wrote:
> Thanks Alan,

[ .... ]

> > The following patch should fix the problem.  Would you please apply
> > it to your Emacs (cc-engine.el is in .../emacs/lisp/progmodes) and
> > byte compile cc-engine.el.  Then please try it out on your real
> > source code, and either confirm the bug has indeed been fixed, or say
> > what's still wrong.  (If you would like any help with the patching or
> > byte compiling, feel free to send me private email.)

> That fix was really fast !

It was a high quality bug report, and easy to diagnose.

> I applied the patch, and it appears to work in a few source files I did
> try.  I did not notice any side effect so far : I will keep your
> version, and let you know (in this bug thread) if I notice any issue
> that is not present in original version.

Thank you for such a fast test.  I am closing the bug with this post.

> Thanks again,

> Bruno.

> -- 
> 2 + 2 = 5, for very large values of 2.

-- 
Alan Mackenzie (Nuremberg, Germany).

[Message part 3 (message/rfc822, inline)]
From: Bruno <braoult <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; [C] wrong indent for knr-style arguments declaration
Date: Thu, 10 Dec 2020 16:02:02 +0100
Within "emacs -Q" session, open the following C source file:

------------------------------ foo.c
int f(i, j, k)
int i;
int j;
int k;
{
return 1;
}

int g(i, j, k)
int i;
int j, k;
{
return 1;
}
------------------------------

Then, do "C-c ." (c-set-style) to "k&r", and "c-c c-o" (c-set-offset),
and set "knr-argdecl-intro" to "+".

We have now the following values in c-offsets-alist :
knr-argdecl-intro : +  (First line of a K&R C argument declaration)
knr-argdecl : 0        (Subsequent lines in a K&R C argument declaration)

re-indent foo.c. At this stage we expect the following indentation for
arguments declarations.

------------------------------ expected indentation
int f(i, j, k)
    int i;
    int j;
    int k;
{
    return 1;
}

int g(i, j, k)
    int i;
    int j, k;
{
    return 1;
}
------------------------------

But we get the following result (please note line 11).

------------------------------ emacs indentation
int f(i, j, k)
    int i;
    int j;
    int k;
{
    return 1;
}

int g(i, j, k)
    int i;
int j, k;
{
    return 1;
}
------------------------------

It should be noted that if we separate each argument on separate lines
(function f), indentation is correct.
It is incorrect if multiple variables are in same declaration (function
g).

Also, multiple variables on first arguments declaration line seems to
have correct indentation.

Regards,

Bruno.

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32)
 of 2020-10-29 built on lorien
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Ubuntu 20.04.1 LTS

Recent messages:
End of buffer [3 times]
Beginning of buffer [3 times]
Making completion list...
Beginning of buffer [3 times]
previous-line: Beginning of buffer
user-error: No further undo information
C-x C-g is undefined
previous-line: Beginning of buffer [10 times]
scroll-up-command: End of buffer
command-execute: Buffer is read-only: #<buffer *Bug Help*>
Quit
Configured features:
XPM JPEG TIFF GIF PNG SOUND GSETTINGS GLIB NOTIFY INOTIFY LIBSELINUX
GNUTLS FREETYPE HARFBUZZ XFT ZLIB TOOLKIT_SCROLL_BARS GTK2 X11 XDBE XIM
MODULES THREADS PDUMPER GMP

Important settings:
  value of $LC_MESSAGES: C
  value of $LC_MONETARY: en_IE.UTF-8
  value of $LC_NUMERIC: en_IE.UTF-8
  value of $LC_TIME: en_IE.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(pp shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x seq
byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils thingatpt help-fns
radix-tree help-mode cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 70553 13929)
 (symbols 48 8643 2)
 (strings 32 22665 2290)
 (string-bytes 1 841592)
 (vectors 16 13093)
 (vector-slots 8 166207 22348)
 (floats 8 23 93)
 (intervals 56 501 6)
 (buffers 1000 17))



This bug report was last modified 4 years and 219 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.