unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45160: 27.1; [C] wrong indent for knr-style arguments declaration
@ 2020-12-10 15:02 Bruno
  2020-12-11 16:33 ` Alan Mackenzie
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno @ 2020-12-10 15:02 UTC (permalink / raw)
  To: 45160

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))





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-12 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-10 15:02 bug#45160: 27.1; [C] wrong indent for knr-style arguments declaration Bruno
2020-12-11 16:33 ` Alan Mackenzie
2020-12-11 19:22   ` Bruno Raoult
2020-12-12 14:48     ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).