all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Benjamin Moody <benjamin.moody@gmail.com>
To: bug-gnu-emacs@gnu.org
Subject: bug#4289: 23.1; Incorrect indentation in C, following certain 'case' labels
Date: Sat, 29 Aug 2009 16:59:54 -0400	[thread overview]
Message-ID: <87eiqupc8l.fsf@bigdeer.rsh.net> (raw)




In Emacs 23.1, I've found an issue with the indentation rules for C
mode.  In some circumstances, following a series of multiple labels,
the second and subsequent statements are not indented properly.  For
example, in the following code:

void foo(int x)
{
  switch (x) {
  case 1:
  case 2:
    printf("aaa");
    break;

  case '3':
  case '4':
    printf("bbb");
  break;
  }
}

the second 'break' statement should be indented by 4 spaces, to align
with the 'printf'.

This problem seems to appear when there are multiple labels (either
normal named labels, 'case' labels, or 'default' labels) in a row,
with no intervening statments, and either the first or the last such
label is a 'case' label with a character constant as its value.

This problem does NOT occur with Emacs 22.3.  It does occur in C++ and
ObjC modes as well.  It affects indentation using either TAB or M-x
indent-region.

A workaround is to place the character constant(s) in parentheses.

This is obviously not a serious problem, but it is a somewhat annoying
one which would be nice to see fixed.

Benjamin Moody



In GNU Emacs 23.1.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2009-08-03 on nautilus, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10402000
configured using `configure  '--build=x86_64-linux-gnu' '--host=x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=athena' '--with-toolkit-scroll-bars' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: C/l

Minor modes in effect:
  iswitchb-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  abbrev-mode: t

Recent input:
<help-echo> C-x C-f / t m p / t e s t . c <return> 
v o i d SPC f o o ( i n t SPC x ) <return> { <return> 
<tab> s w i t c h SPC ( x ) SPC { <return> <tab> c 
a s d e <backspace> <backspace> e 1 SPC <backspace> 
<backspace> SPC 1 : <return> <tab> c a s e SPC 2 : 
<return> <tab> p r i n t f ( " a a a " ) ; <return> 
<tab> b r e a k ; <return> <return> <tab> c a s e SPC 
' 3 ' : <return> <tab> c a s e SPC ' 4 ' : <return> 
<tab> p r i n t f ( " b b b " ) ; <return> <tab> b 
r e a k j ; <backspace> <backspace> ; <return> } <S-return> 
} <return> M-x r e p o r t - e m a <tab> <return>

Recent messages:
Setting up ede...
Loading `eieio': old-style backquotes detected!
Setting up ede...done
Setting up eieio...done
Setting up semantic...done
Setting up speedbar...done
Setting up cedet-contrib...done
Loading /etc/emacs/site-start.d/55ecb.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
(New file)






             reply	other threads:[~2009-08-29 20:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-29 20:59 Benjamin Moody [this message]
2009-08-31 20:05 ` bug#4289: 23.1; Incorrect indentation in C, following certain 'case' labels Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eiqupc8l.fsf@bigdeer.rsh.net \
    --to=benjamin.moody@gmail.com \
    --cc=4289@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.