unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5649: 23.1.92; Indentation problems in C mode
@ 2010-02-25 16:11 Michael Welsh Duggan
  2010-02-27  0:12 ` Chong Yidong
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Welsh Duggan @ 2010-02-25 16:11 UTC (permalink / raw)
  To: 5649

[-- Attachment #1: Type: text/plain, Size: 1168 bytes --]

I'm getting some screwy indentation behavior from C mode.  From a
current bzr checkout/install of emacs, try the following recipe: 

emacs -Q foo.c                 | starts emacs on foo.c (included below)
C-u 7 C-n                      | move down 7 lines
TAB                            | indent, nothing changes (good)
C-p C-p                        | move up 2 lines
TAB C-n TAB C-n                | indent 2 lines, nothing changes (good)
TAB                            | line unindents by 2 (bad)
TAB                            | line re-indents (good, but strange)
TAB                            | no change this time

And here's another recipe for weirdness:

emacs -Q foo.c                 | starts emacs on foo.c (included below)
C-x h                          | select buffer
C-M-\                          | indent region everything from line 7
                               |   down to the while (0) unindents 2
C-u 5 C-n                      | move down to the do {
C-x ( TAB C-n C-x )            | define a macro to indent and move down
                               |   a line
C-x e e e e e e                | Indent each line, no change

Here's foo.c


[-- Attachment #2: foo.c --]
[-- Type: text/plain, Size: 408 bytes --]

#if !SK_ENABLE_IPV6
#  define skipaddrApplyCIDR(ipaddr, cidr)       \
  ipUnionApplyCIDRV4(&(ipaddr)->ip_ip, cidr)
#else
#  define skipaddrApplyCIDR(ipaddr, cidr)                       \
  do {								\
    if (skipaddrIsV6(ipaddr)) {					\
      ipUnionApplyCIDRV6(&((ipaddr)->ip_ip), cidr);		\
    } else {							\
      ipUnionApplyCIDRV4(&((ipaddr)->ip_ip), cidr);		\
    }								\
  } while (0)
#endif

[-- Attachment #3: Type: text/plain, Size: 4934 bytes --]


In GNU Emacs 23.1.92.2 (i686-pc-linux-gnu, GTK+ Version 2.10.4)
 of 2010-02-19 on maru.green.cert.org
Windowing system distributor `The X.Org Foundation', version 11.0.70101000
configured using `configure  '--prefix=/home/mwd' '--without-toolkit-scroll-bars' '--with-gif=no''

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: @im=none
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Group

Minor modes in effect:
  gnus-undo-mode: t
  shell-dirtrack-mode: t
  display-time-mode: t
  diff-auto-refine-mode: t
  tooltip-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
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
<return> C-x h C-M-\ C-n C-n C-n C-n C-n C-n C-n C-n 
C-p <tab> C-o C-_ C-p <tab> C-n C-n C-n C-n C-b C-b 
} <tab> SPC <tab> C-p C-p C-p C-p C-p C-a C-p C-x h 
C-M-\ C-n C-n C-n C-n C-n C-n C-n <tab> C-n <tab> C-n 
<tab> C-n <tab> C-b C-b C-b C-b C-b C-b C-b C-b C-b 
C-b C-b \ <return> <tab> C-p C-x h C-M-\ C-n C-n C-n 
C-n C-n C-n C-n C-n C-p <tab> C-n <tab> C-n <tab> C-n 
<tab> C-n <tab> C-p C-p C-p C-p C-p <tab> C-p <tab> 
C-p <tab> C-p C-p C-p <tab> C-n C-a <tab> C-p C-a C-x 
h C-M-\ C-_ <switch-frame> M-x r e p o r e t - e m 
<tab> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> r t - e m <tab> <return> I 
n d e n t a t i o n SPC p r o b l e m s SPC i n SPC 
c c - m o d e <return> M-x c c - <tab> <tab> b <tab> 
<backspace> <backspace> <backspace> - <tab> b <tab> 
<backspace> r <tab> e <tab> <backspace> <backspace> 
s u <tab> <return> y M-p C-e <M-backspace> <M-backspace> 
C SPC m o d e <return> C-x o C-x k y e s <return> C-x 
0 M-v M-v C-n C-p C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-_ C-x k M-x r e p o r t - e m <tab> 
<return>

Recent messages:
Checking 39 files in /home/mwd/share/emacs/23.1.92/lisp/obsolete...
Checking 1 files in /home/mwd/share/emacs/23.1.92/leim...
Checking for load-path shadows...done
Making completion list... [4 times]
Do you want to submit a report on CC Mode? (y or n) 
Formatting bug report buffer.......
Please enter your report.  Type C-c C-c to send, C-c C-k to abort.
call-interactively: Beginning of buffer
Auto-saving...done
Undo!

Load-path shadows:
/afs/cert.org/usr/mwd/src/elisp/nnir hides /home/mwd/share/emacs/23.1.92/lisp/gnus/nnir

Features:
(reporter shadow emacsbug time-stamp tabify whitespace dabbrev
vc-dispatcher vc-svn flyspell ispell cc-mode cc-fonts cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs help-mode view copyright
gnus-dup mule-util gnus-cite ansi-color mail-extr gnus-async gnus-bcklg
parse-time timezone sort gnus-ml disp-table byte-opt bytecomp
byte-compile nnml utf-7 utf7 nndraft nnmh tls nnimap imap gnus-agent
gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu
mml2015 epg-config mm-view gnus-cache nnir edmacro kmacro gnus-sum
gnus-demon nntp gnus-group gnus-undo nnmail mail-source nnoo gnus-start
gnus-spec gnus-int gnus-range gnus-win uniquify tramp-imap assoc
tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds tramp
auth-source advice help-fns advice-preload shell format-spec
tramp-compat trampver time smime dig server psvn cl cl-19 log-edit
pcvs-util add-log diff-mode easy-mmode pgg pgg-parse pgg-def message
sendmail ecomplete rfc822 mml easymenu mml-sec password-cache mm-decode
mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp
ietf-drums mailabbrev gmm-utils mailheader canlock sha1 hex-util
hashcash gnus gnus-ems nnheader gnus-util netrc time-date mail-utils
mm-util mail-prsvr wid-edit generic-x dired-x dired-aux dired ange-ftp
regexp-opt comint ring tooltip ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs)

-- 
Michael Welsh Duggan
(mwd@cert.org)

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

* bug#5649: 23.1.92; Indentation problems in C mode
  2010-02-25 16:11 bug#5649: 23.1.92; Indentation problems in C mode Michael Welsh Duggan
@ 2010-02-27  0:12 ` Chong Yidong
  2010-03-01 11:38   ` Alan Mackenzie
  0 siblings, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2010-02-27  0:12 UTC (permalink / raw)
  To: Michael Welsh Duggan; +Cc: 5649

Michael Welsh Duggan <mwd@cert.org> writes:

> I'm getting some screwy indentation behavior from C mode.  From a
> current bzr checkout/install of emacs, try the following recipe:
>
> emacs -Q foo.c                 | starts emacs on foo.c (included below)
> C-u 7 C-n                      | move down 7 lines
> TAB                            | indent, nothing changes (good)
> C-p C-p                        | move up 2 lines
> TAB C-n TAB C-n                | indent 2 lines, nothing changes (good)
> TAB                            | line unindents by 2 (bad)
> TAB                            | line re-indents (good, but strange)
> TAB                            | no change this time

Thanks.  This is a regression vs Emacs 23.1, so we should definitely fix
it before releasing Emacs 23.2.

I can reproduce the bug with the Emacs 23.0.90, so it's be around since
at lease 12-09 last year.  However, I haven't yet had the time to do a
proper bisect.






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

* bug#5649: 23.1.92; Indentation problems in C mode
  2010-02-27  0:12 ` Chong Yidong
@ 2010-03-01 11:38   ` Alan Mackenzie
  2010-03-01 15:00     ` Chong Yidong
  2010-03-01 15:17     ` Michael Welsh Duggan
  0 siblings, 2 replies; 7+ messages in thread
From: Alan Mackenzie @ 2010-03-01 11:38 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5649, Michael Welsh Duggan

Hi, Michael and Yidong

On Fri, Feb 26, 2010 at 07:12:06PM -0500, Chong Yidong wrote:
> Michael Welsh Duggan <mwd@cert.org> writes:

> > I'm getting some screwy indentation behavior from C mode.  From a
> > current bzr checkout/install of emacs, try the following recipe:

> > emacs -Q foo.c                 | starts emacs on foo.c (included below)
> > C-u 7 C-n                      | move down 7 lines
> > TAB                            | indent, nothing changes (good)
> > C-p C-p                        | move up 2 lines
> > TAB C-n TAB C-n                | indent 2 lines, nothing changes (good)
> > TAB                            | line unindents by 2 (bad)
> > TAB                            | line re-indents (good, but strange)
> > TAB                            | no change this time

> Thanks.  This is a regression vs Emacs 23.1, so we should definitely fix
> it before releasing Emacs 23.2.

> I can reproduce the bug with the Emacs 23.0.90, so it's be around since
> at lease 12-09 last year.  However, I haven't yet had the time to do a
> proper bisect.

I've just committed the folowing patch, which should fix the bug:


=== modified file 'lisp/progmodes/cc-engine.el'
--- lisp/progmodes/cc-engine.el	2010-02-25 21:21:25 +0000
+++ lisp/progmodes/cc-engine.el	2010-03-01 11:23:59 +0000
@@ -2641,7 +2641,8 @@
 	;; (car c-state-cache).  There can be no open parens/braces/brackets
 	;; between `good-pos'/`good-pos-actual-macro-start' and (point-max),
 	;; due to the interface spec to this function.
-	(setq pos (if good-pos-actual-macro-end
+	(setq pos (if (and good-pos-actual-macro-end
+			   (> in-macro-start good-pos-actual-macro-start))
 		      (1+ good-pos-actual-macro-end) ; get outside the macro as
 					; marked by a `category' text property.
 		    good-pos))


Thanks for the clean and concise bug report!

-- 
Alan Mackenzie (Nuremberg, Germany).






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

* bug#5649: 23.1.92; Indentation problems in C mode
  2010-03-01 11:38   ` Alan Mackenzie
@ 2010-03-01 15:00     ` Chong Yidong
  2010-03-01 15:17     ` Michael Welsh Duggan
  1 sibling, 0 replies; 7+ messages in thread
From: Chong Yidong @ 2010-03-01 15:00 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Michael Welsh Duggan, 5649-done

Alan Mackenzie <acm@muc.de> writes:
>
> I've just committed the folowing patch, which should fix the bug:

Thanks!






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

* bug#5649: 23.1.92; Indentation problems in C mode
  2010-03-01 11:38   ` Alan Mackenzie
  2010-03-01 15:00     ` Chong Yidong
@ 2010-03-01 15:17     ` Michael Welsh Duggan
  2010-03-01 18:04       ` Alan Mackenzie
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Welsh Duggan @ 2010-03-01 15:17 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Chong Yidong, 5649@debbugs.gnu.org

Alan Mackenzie <acm@muc.de> writes:

> Hi, Michael and Yidong
>
> On Fri, Feb 26, 2010 at 07:12:06PM -0500, Chong Yidong wrote:
>> Michael Welsh Duggan <mwd@cert.org> writes:
>
>> > I'm getting some screwy indentation behavior from C mode.  From a
>> > current bzr checkout/install of emacs, try the following recipe:
>
>> > emacs -Q foo.c                 | starts emacs on foo.c (included below)
>> > C-u 7 C-n                      | move down 7 lines
>> > TAB                            | indent, nothing changes (good)
>> > C-p C-p                        | move up 2 lines
>> > TAB C-n TAB C-n                | indent 2 lines, nothing changes (good)
>> > TAB                            | line unindents by 2 (bad)
>> > TAB                            | line re-indents (good, but strange)
>> > TAB                            | no change this time
>
>> Thanks.  This is a regression vs Emacs 23.1, so we should definitely fix
>> it before releasing Emacs 23.2.
>
>> I can reproduce the bug with the Emacs 23.0.90, so it's be around since
>> at lease 12-09 last year.  However, I haven't yet had the time to do a
>> proper bisect.
>
> I've just committed the folowing patch, which should fix the bug:

I'm afraid this causes a much more serious bug.  Recipe:

emacs -Q
Open a new C-mode file.  Then type the following:
#if FOO
#endif

int bar;

For me the following happens:  The #endif is not fontified.  The "int
bar" is not fontified.  The semicolon causes an error.  I have verified
that reverting the patch below goes back to the old behavior, so this
patch is what is causing the bug.


> === modified file 'lisp/progmodes/cc-engine.el'
> --- lisp/progmodes/cc-engine.el	2010-02-25 21:21:25 +0000
> +++ lisp/progmodes/cc-engine.el	2010-03-01 11:23:59 +0000
> @@ -2641,7 +2641,8 @@
>  	;; (car c-state-cache).  There can be no open parens/braces/brackets
>  	;; between `good-pos'/`good-pos-actual-macro-start' and (point-max),
>  	;; due to the interface spec to this function.
> -	(setq pos (if good-pos-actual-macro-end
> +	(setq pos (if (and good-pos-actual-macro-end
> +			   (> in-macro-start good-pos-actual-macro-start))
>  		      (1+ good-pos-actual-macro-end) ; get outside the macro as
>  					; marked by a `category' text property.
>  		    good-pos))
>
>
> Thanks for the clean and concise bug report!

-- 
Michael Welsh Duggan
(mwd@cert.org)






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

* bug#5649: 23.1.92; Indentation problems in C mode
  2010-03-01 15:17     ` Michael Welsh Duggan
@ 2010-03-01 18:04       ` Alan Mackenzie
  2010-03-01 18:40         ` Michael Welsh Duggan
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2010-03-01 18:04 UTC (permalink / raw)
  To: Michael Welsh Duggan; +Cc: Chong Yidong, 5649@debbugs.gnu.org

Hello, again,

On Mon, Mar 01, 2010 at 10:17:00AM -0500, Michael Welsh Duggan wrote:
> Alan Mackenzie <acm@muc.de> writes:

> > I've just committed the folowing patch, which should fix the bug:

> I'm afraid this causes a much more serious bug.  Recipe:

> emacs -Q
> Open a new C-mode file.  Then type the following:
> #if FOO
> #endif

> int bar;

Sorry.

> For me the following happens:  The #endif is not fontified.  The "int
> bar" is not fontified.  The semicolon causes an error.  I have verified
> that reverting the patch below goes back to the old behavior, so this
> patch is what is causing the bug.

Yes.

> > === modified file 'lisp/progmodes/cc-engine.el'
> > --- lisp/progmodes/cc-engine.el	2010-02-25 21:21:25 +0000
> > +++ lisp/progmodes/cc-engine.el	2010-03-01 11:23:59 +0000
> > @@ -2641,7 +2641,8 @@
> >  	;; (car c-state-cache).  There can be no open parens/braces/brackets
> >  	;; between `good-pos'/`good-pos-actual-macro-start' and (point-max),
> >  	;; due to the interface spec to this function.
> > -	(setq pos (if good-pos-actual-macro-end
> > +	(setq pos (if (and good-pos-actual-macro-end
> > +			   (> in-macro-start good-pos-actual-macro-start))
> >  		      (1+ good-pos-actual-macro-end) ; get outside the macro as
> >  					; marked by a `category' text property.
> >  		    good-pos))

I was thrown by my own bad commenting.  :-(  I've committed a correction
to this.  The relevant diff (wrt the buggy "middle" version) is:


=== modified file 'lisp/progmodes/cc-engine.el'
--- lisp/progmodes/cc-engine.el	2010-03-01 11:31:42 +0000
+++ lisp/progmodes/cc-engine.el	2010-03-01 17:42:35 +0000
@@ -2591,7 +2591,7 @@
   (save-restriction
     (narrow-to-region 1 (point-max))
     (save-excursion
-      (let* ((in-macro-start   ; point-max or beginning of macro containing it
+      (let* ((in-macro-start   ; start of macro containing (point-max) or nil.
 	      (save-excursion
 		(goto-char (point-max))
 		(and (c-beginning-of-macro)
@@ -2642,7 +2642,8 @@
 	;; between `good-pos'/`good-pos-actual-macro-start' and (point-max),
 	;; due to the interface spec to this function.
 	(setq pos (if (and good-pos-actual-macro-end
-			   (> in-macro-start good-pos-actual-macro-start))
+			   (not (eq good-pos-actual-macro-start
+				    in-macro-start)))
 		      (1+ good-pos-actual-macro-end) ; get outside the macro as
 					; marked by a `category' text property.
 		    good-pos))


> > Thanks for the clean and concise bug report!

I hope it's right now.

> -- 
> Michael Welsh Duggan
> (mwd@cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).






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

* bug#5649: 23.1.92; Indentation problems in C mode
  2010-03-01 18:04       ` Alan Mackenzie
@ 2010-03-01 18:40         ` Michael Welsh Duggan
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Welsh Duggan @ 2010-03-01 18:40 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Chong Yidong, 5649@debbugs.gnu.org

Alan Mackenzie <acm@muc.de> writes:

> Hello, again,
>
> On Mon, Mar 01, 2010 at 10:17:00AM -0500, Michael Welsh Duggan wrote:
>> Alan Mackenzie <acm@muc.de> writes:
>
>> > I've just committed the folowing patch, which should fix the bug:
>
>> I'm afraid this causes a much more serious bug.  Recipe:
>
>> emacs -Q
>> Open a new C-mode file.  Then type the following:
>> #if FOO
>> #endif
>
>> int bar;

[...]

> I was thrown by my own bad commenting.  :-(  I've committed a correction
> to this.  The relevant diff (wrt the buggy "middle" version) is:

[...]

>> > Thanks for the clean and concise bug report!
>
> I hope it's right now.

This does now seem to work.  Thanks!

-- 
Michael Welsh Duggan
(mwd@cert.org)






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

end of thread, other threads:[~2010-03-01 18:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-25 16:11 bug#5649: 23.1.92; Indentation problems in C mode Michael Welsh Duggan
2010-02-27  0:12 ` Chong Yidong
2010-03-01 11:38   ` Alan Mackenzie
2010-03-01 15:00     ` Chong Yidong
2010-03-01 15:17     ` Michael Welsh Duggan
2010-03-01 18:04       ` Alan Mackenzie
2010-03-01 18:40         ` Michael Welsh Duggan

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