Re: C indentation error.

2006-04-03 Thread Alan Mackenzie
Hi, Michael, Tim and Richard!

On Sun, 19 Mar 2006, Michael Cadilhac wrote:

>> >   I got an  error with some C indentation in  macro definitions in GNU
>> >  Emacs 22.0.50.34 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
>> >  2006-03-02.

>> >   Error is triggered by:

>> >   With emacs -Q :
>> >   In scratch, insert the following:

>> > #foo :\
>> > bar

>> >   Toggle to c-mode, and try to indent the last line.

>> >   I get: Invalid search bound (wrong side of point).

, and on Fri, 24 Feb 2006, Tim Millet wrote:

> The following typedef describes the problem.  It shows that when the
> struct member is of a user defined type, the bitfield specification
> causes the line syntax to be mistaken.  The first struct member uses a
> builtin type and the indentation is correct.  This problem didn't occur
> in version 5.28

> typedef struct {
>  int chanCnt:5;   // correct indentation
> u_char_t chanCntRsvd:3; // INCORRECT indentation
> } CbChanCnt_t;

The following patch should fix both of these bugs.  :-)  Would you please
try it out and get back to me on [EMAIL PROTECTED] if it doesn't.

Unless there are problems with it, I will release this fix with the next
CC Mode release (5.31.4), whence it will find its way into the Emacs CVS
at savannah.gnu.org.


*** ../cc-mode-5.32.cvs/cc-engine.elSun Feb 19 11:19:05 2006
--- cc-engine.elSun Apr  2 15:35:42 2006
***
*** 5791,5807 
nil
  
  (defun c-forward-label (&optional assume-markup preceding-token-end limit)
!   ;; Assuming the point is at the beginning of a token, check if it
!   ;; starts a label and if so move over it and return t, otherwise
!   ;; don't move and return nil.  The end of the label is taken to be
!   ;; the end of the first submatch in `c-opt-extra-label-key' if it
!   ;; matched, otherwise it's the colon.  The point is directly after
!   ;; the end on return.  The terminating char is marked with
!   ;; `c-decl-end' to improve recognition of the following declaration
!   ;; or statement.
;;
;; If ASSUME-MARKUP is non-nil, it's assumed that the preceding
!   ;; label, if any, has been marked up like that.
;;
;; If PRECEDING-TOKEN-END is given, it should be the first position
;; after the preceding token, i.e. on the other side of the
--- 5791,5822 
nil
  
  (defun c-forward-label (&optional assume-markup preceding-token-end limit)
!   ;; Assuming the point is at the beginning of a token, check if it starts a
!   ;; label and if so move over it and return t, otherwise don't move and
!   ;; return nil.  "Label" here means "most things with a colon".
!   ;;
!   ;; More precisely, a "label" is regarded as one of:
!   ;; (i) a goto target like "foo:";
!   ;; (ii) A case label - either the entire construct "case FOO:" or just the
!   ;;   bare "case", should the colon be missing;
!   ;; (iii) a keyword which needs a colon, like "default:" or "private:";
!   ;; (iv) One of QT's "extended" C++ variants of
!   ;; "private:"/"protected:"/"public:"/"more:" looking like "public slots:".
!   ;; (v) One of the keywords matched by `c-opt-extra-label-key' (without any
!   ;;   colon).  Currently (2006-03), this applies only to Objective C's
!   ;;   keywords "@private", "@protected", and "@public".
!   ;;
!   ;; One of the things which will NOT be recognised as a label is a bit-field
!   ;; element of a struct, something like "int foo:5".
!   ;;
!   ;; The end of the label is taken to be just after the colon, or the end of
!   ;; the first submatch in `c-opt-extra-label-key'.  The point is directly
!   ;; after the end on return.  The terminating char gets marked with
!   ;; `c-decl-end' to improve recognition of the following declaration or
!   ;; statement.
;;
;; If ASSUME-MARKUP is non-nil, it's assumed that the preceding
!   ;; label, if any, has already been marked up like that.
;;
;; If PRECEDING-TOKEN-END is given, it should be the first position
;; after the preceding token, i.e. on the other side of the
***
*** 5817,5824 
;;
;; This function might do hidden buffer changes.
  
!   (let ((start (point)))
  (cond
   ((looking-at c-label-kwds-regexp)
(let ((kwd-end (match-end 1)))
;; Record only the keyword itself for fontification, since in
--- 5832,5842 
;;
;; This function might do hidden buffer changes.
  
!   (let ((start (point))
!   qt-symbol-idx
!   macro-start); if we're in one.
  (cond
+  ;; "case" or "default" (Doesn't apply to AWK). 
   ((looking-at c-label-kwds-regexp)
(let ((kwd-end (match-end 1)))
;; Record only the keyword itself for fontification, since in
***
*** 5838,5844 
 (match-beginning 2))
  
(progn
! (goto-char (match-beginning 2))
  (c-put-c-type-property (1- (point)) 'c-decl-end)
 

Re: C indentation error.

2006-04-03 Thread Michael Cadilhac
Alan Mackenzie <[EMAIL PROTECTED]> writes:

> Hi, Michael, Tim and Richard!

  And hi everybody !

>>> > #foo :\
>>> > bar

>> typedef struct {
>>  int chanCnt:5;   // correct indentation
>> u_char_t chanCntRsvd:3; // INCORRECT indentation
>> } CbChanCnt_t;
>
> The following patch should fix both of these bugs.  :-)  Would you please
> try it out and get back to me on [EMAIL PROTECTED] if it doesn't.

  Yes, that makes it :-) The error is no longer triggered.

  Anyway, as I check the file where I had the error, and re-indent it,
  I've a more or less unexpected behavior :

#define CHOICE_COMMAND(N, Command)  \
case N: \
  if ((Command) != ERROR)   \
return false;   \
break;

  The « break » keyword is badly indented ; if I remove the line with
  the #define, it could come back indented at the right place.

  I'm saying « more or less » because I agree it's not a common use.

  Greetings,

-- 
Michael Cadilhac, a.k.a. Micha [mika] |
Epita/LRDE promo 2007 |   )\._.,--,'``.
123 av. de Fontainebleau | 08.70.65.13.14 |  /.  _.. \   _\  (` ._,.
94270 Le Kremlin Bicetre | 06.23.20.31.30 | '._.-(,_..'--(,_...`-..'


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: C indentation error.

2006-03-31 Thread Alan Mackenzie
Cc: [EMAIL PROTECTED], emacs-pretest-bug@gnu.org,
[EMAIL PROTECTED]
To: Michael Cadilhac <[EMAIL PROTECTED]>
From: Richard Stallman <[EMAIL PROTECTED]>

Hi, Michael, Richard!

First, a big apology for not getting back to you for so long.  As well as
all the things in Emacs, I've got serious personal stress at the moment and 
haven't been able to concentrate properly on the bug.  So, sorry.

Incidentally, Michael, your mail server has rejected my attempts to send
you mail, as follows:

Mar 31 09:58:21 acm sendmail[320]: JAA00286: to=<[EMAIL PROTECTED]>, 
delay=00:02:10, xdelay=00:00:03, mailer=esmtp, relay=smtp.lrde.epita.fr. 
[62.39.139.2], stat=Deferred: 451-193.149.49.134 is not yet authorized to 
deliver mail from <[EMAIL PROTECTED]> 
to

On Sun, 19 Mar 2006, Michael Cadilhac wrote:

>Richard Stallman <[EMAIL PROTECTED]> writes:
>
>> >   I got an  error with some C indentation in  macro definitions in GNU
>> >  Emacs 22.0.50.34 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
>> >  2006-03-02.
>> >
>> >   Error is triggered by:
>> >
>> >   With emacs -Q :
>> >   In scratch, insert the following:
>> >
>> > #foo :\
>> > bar

>> >   Toggle to c-mode, and try to indent the last line.
>> >
>> >   I get: Invalid search bound (wrong side of point).

Yes, this does indeed happen, and is definitely a bug.  Thank you for
reporting it.

I'm guessing that you've reduced the code down to the minimum needed to
demonstrate the bug, which is appreciated, and that you've got real code
in which this bug happened.

What is happening is that in c-forward-label, the code is trying to see
if "bar" is a label.  (It isn't, of course).  One of the things it checks
is if there is a label just before "bar".

To do this, it first moves backwards to "#foo".  Then it moves forward
over "whitespace" before calling c-forward-label recursively.  This
"whitespace" is the problem:  Since "#foo" is a preprocessor directive,
c-forward-syntactic-ws regards the entire line (including the
continuation line) as whitespace, hence point is in the wrong place .

The code here needs to be fixed to check for #things.

[ Discussion about "no-error" in c-syntactic-re-search-forward snipped. ]

>  After a little more search, I propose the following change :

>Index: lisp/progmodes/cc-engine.el
>===
>RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-engine.el,v
>retrieving revision 1.47
>diff -c -r1.47 cc-engine.el
>*** lisp/progmodes/cc-engine.el 24 Feb 2006 15:33:02 -  1.47
>--- lisp/progmodes/cc-engine.el 19 Mar 2006 17:59:56 -
>***
>*** 5916,5922 
> ;; it shouldn't apply when we check the
> ;; preceding label.
> c-record-type-identifiers)
>!(c-forward-syntactic-ws)
> (c-forward-label nil pte start
>  
>   ;; Check that the next nonsymbol token is ":".  Allow '('
>--- 5916,5922 
> ;; it shouldn't apply when we check the
> ;; preceding label.
> c-record-type-identifiers)
>!(c-forward-syntactic-ws pte)
> (c-forward-label nil pte start
>  
>   ;; Check that the next nonsymbol token is ":".  Allow '('
>
>
>--

>  Well... It fixes the bug, really, but it doesn't investigate the bug
>  as it probably should be ;  the bug _may_ be in c-forward-sws, a too
>  long function for me to work on ;-)

Your patch is a workaround rather than a fix.  I think I should be able
to fix the bug properly in the next week or two.

(Also, c-forward-sws is almost too long a function for _me_ to work on.
;-).

>  Bye !

Again, sorry for the delay in answering.

>Michael Cadilhac, a.k.a. Micha [mika] |

-- 
Alan Mackenzie (Munich, Germany)





___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: C indentation error.

2006-03-20 Thread Michael Cadilhac
Richard Stallman <[EMAIL PROTECTED]> writes:

> >   I got an  error with some C indentation in  macro definitions in GNU
> >  Emacs 22.0.50.34 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
> >  2006-03-02.
> >
> >   Error is triggered by:
> >
> >   With emacs -Q :
> >   In scratch, insert the following:
> >
> > #foo :\
> > bar
> >
> >   Toggle to c-mode, and try to indent the last line.
> >
> >   I get: Invalid search bound (wrong side of point).
>
>   However, looking at the  code of search_command, I'm wondering why
>   an error could  be output even if  noerror is t or a  symbol [1] ;
>   fixing this that way :
>
> The noerror argument means "no error if the search fails".
> Invalid arguments are a different issue.
>
> I will clarify this in the Lisp manual.
>
> So your proposed change in search.c should not be installed.

  That's what I thought ; I was  trying to get a reaction for this bug
  report ;-)

> Instead, the  code in CC  mode should be  fixed not to  pass invalid
> search bounds.

  After a little more search, I propose the following change :

Index: lisp/progmodes/cc-engine.el
===
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-engine.el,v
retrieving revision 1.47
diff -c -r1.47 cc-engine.el
*** lisp/progmodes/cc-engine.el 24 Feb 2006 15:33:02 -  1.47
--- lisp/progmodes/cc-engine.el 19 Mar 2006 17:59:56 -
***
*** 5916,5922 
 ;; it shouldn't apply when we check the
 ;; preceding label.
 c-record-type-identifiers)
!(c-forward-syntactic-ws)
 (c-forward-label nil pte start
  
   ;; Check that the next nonsymbol token is ":".  Allow '('
--- 5916,5922 
 ;; it shouldn't apply when we check the
 ;; preceding label.
 c-record-type-identifiers)
!(c-forward-syntactic-ws pte)
 (c-forward-label nil pte start
  
   ;; Check that the next nonsymbol token is ":".  Allow '('


--

  Well... It fixes the bug, really, but it doesn't investigate the bug
  as it probably should be ;  the bug _may_ be in c-forward-sws, a too
  long function for me to work on ;-)

  Bye !

-- 
Michael Cadilhac, a.k.a. Micha [mika] |
Epita/LRDE promo 2007 |   )\._.,--,'``.
123 av. de Fontainebleau | 08.70.65.13.14 |  /.  _.. \   _\  (` ._,.
94270 Le Kremlin Bicetre | 06.23.20.31.30 | '._.-(,_..'--(,_...`-..'


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: C indentation error.

2006-03-20 Thread Richard Stallman
>   I got an  error with some C indentation in  macro definitions in GNU
>  Emacs 22.0.50.34 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
>  2006-03-02.
>
>   Error is triggered by:
>
>   With emacs -Q :
>   In scratch, insert the following:
>
> #foo :\
> bar
>
>   Toggle to c-mode, and try to indent the last line.
>
>   I get: Invalid search bound (wrong side of point).

However, looking at the  code of search_command, I'm wondering why
an error could  be output even if  noerror is t or a  symbol [1] ;
fixing this that way :

The noerror argument means "no error if the search fails".
Invalid arguments are a different issue.

I will clarify this in the Lisp manual.

So your proposed change in search.c should not be installed.
Instead, the code in CC mode should be fixed not to pass
invalid search bounds.


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: C indentation error.

2006-03-17 Thread Michael Cadilhac
Michael Cadilhac <[EMAIL PROTECTED]> writes:

>   Hi !
>
>   I got an  error with some C indentation in  macro definitions in GNU
>  Emacs 22.0.50.34 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
>  2006-03-02.
>
>   Error is triggered by:
>
>   With emacs -Q :
>   In scratch, insert the following:
>
> #foo :\
> bar
>
>   Toggle to c-mode, and try to indent the last line.
>
>   I get: Invalid search bound (wrong side of point).
>

I spent couple of minutes trying to see what's going wrong, and
I didn't found something very conclusive.

However, looking at the  code of search_command, I'm wondering why
an error could  be output even if  noerror is t or a  symbol [1] ;
fixing this that way :

Index: search.c
===
RCS file: /cvsroot/emacs/emacs/src/search.c,v
retrieving revision 1.207
diff -c -r1.207 search.c
*** search.c1 Mar 2006 23:52:22 -   1.207
--- search.c17 Mar 2006 11:06:24 -
***
*** 927,933 
CHECK_NUMBER_COERCE_MARKER (bound);
lim = XINT (bound);
if (n > 0 ? lim < PT : lim > PT)
!   error ("Invalid search bound (wrong side of point)");
if (lim > ZV)
lim = ZV, lim_byte = ZV_BYTE;
else if (lim < BEGV)
--- 927,937 
CHECK_NUMBER_COERCE_MARKER (bound);
lim = XINT (bound);
if (n > 0 ? lim < PT : lim > PT)
!   {
! if (NILP (noerror))
!   error ("Invalid search bound (wrong side of point)");
! return Qnil;
!   }
if (lim > ZV)
lim = ZV, lim_byte = ZV_BYTE;
else if (lim < BEGV)


would fix the reported bug.

But I don't  know if c-indent is supposed to  pass a wrong `bound'
to c-syntactic-re-search-forward...

Bye.


Footnotes: 
[1]  the « error ("Invalid search bound (wrong side of point)"); »

-- 
Michael Cadilhac, a.k.a. Micha [mika] |
Epita/LRDE promo 2007 |   )\._.,--,'``.
123 av. de Fontainebleau | 08.70.65.13.14 |  /.  _.. \   _\  (` ._,.
94270 Le Kremlin Bicetre | 06.23.20.31.30 | '._.-(,_..'--(,_...`-..'


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


C indentation error.

2006-03-11 Thread Michael Cadilhac

  Hi !

  I got an  error with some C indentation in  macro definitions in GNU
 Emacs 22.0.50.34 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
 2006-03-02.

  Error is triggered by:

  With emacs -Q :
  In scratch, insert the following:

#foo :\
bar

  Toggle to c-mode, and try to indent the last line.

  I get: Invalid search bound (wrong side of point).

  Backtrace is:

;;
Debugger entered--Lisp error: (error "Invalid search bound (wrong side of 
point)")
  re-search-forward("[[:?;{=*/%&|,<>[EMAIL PROTECTED]" 6647 t)
  (progn (setq search-pos (point)) (re-search-forward regexp bound noerror))
  (and (progn (setq search-pos ...) (re-search-forward regexp bound noerror)) 
(progn (setq state ... state-pos ...) (if ... ... ...) (cond ... ... ... ... 
... ... ... ...)) (or (/= search-pos ...) (if ... ... ... t)))
  (while (and (progn ... ...) (progn ... ... ...) (or ... ...)))
  (let ((start ...) tmp search-pos state (state-pos ...) check-pos check-state 
(last-token-end-pos ...) found) (while (and ... ... ...)) (if found (progn ... 
...) (if ... ... ...) nil))
  c-syntactic-re-search-forward("[[:?;{=*/%&|,<>[EMAIL PROTECTED]" 6647 t t)
  c-forward-label(nil 6592 6647)
  c-forward-label()
  c-guess-basic-syntax()
  c-indent-line()
  ...
;;

  Bye.

-- 
Michael Cadilhac, a.k.a. Micha [mika] |
Epita/LRDE promo 2007 |   )\._.,--,'``.
123 av. de Fontainebleau | 08.70.65.13.14 |  /.  _.. \   _\  (` ._,.
94270 Le Kremlin Bicetre | 06.23.20.31.30 | '._.-(,_..'--(,_...`-..'


pgp4Uo4tzskR6.pgp
Description: PGP signature
___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug