bug-indent
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-indent] False Nesting and Unmatched 'else' errors


From: david ingamells
Subject: Re: [Bug-indent] False Nesting and Unmatched 'else' errors
Date: Wed, 26 Mar 2003 17:47:23 +0000
User-agent: KMail/1.4.3

Leslie,
Thank you for your report. 
The problem is caused by the use of non-C constructs:


interrupt_state = ({ int res;  ...});

is not legal C, and indent will not be able to handle it.

David.

On Wednesday 26 March 2003 17:32, Leslie Mulder wrote:
> To who it may concern,
>
> We came across some code (INPUT FILE below) that we wanted to run through
> indent.
> Unfortunately the code structure caused indent to generate a number of
> false errors.
> The code structure is arcane and is the result of cpp expansions of macros
> defining
> in-line functions.
>
> Please note that we DID NOT write this code.
>
>  > indent --version
>
> GNU indent 2.2.8
>
>  > indent indent_tst_01.c -o test.p.c
>
> indent: indent_tst_01.c:15: Error:Stmt nesting error.
> indent: indent_tst_01.c:23: Error:Stmt nesting error.
> indent: indent_tst_01.c:24: Error:Unmatched 'else'
> indent: indent_tst_01.c:25: Error:Stmt nesting error.
> indent: indent_tst_01.c:26: Error:Stmt nesting error.
> indent: indent_tst_01.c:30: Error:Stmt nesting error.
> indent: indent_tst_01.c:31: Error:Unexpected end of file
>
>
>
> /***********************************INPUT FILE indent_tst_01.c
>
> static int
> set_debug_comm(int __comm_id)
> {
>      static int __selected_id = -2;
>      hal_virtual_comm_table_t* __chan;
>      int interrupt_state = 0;
>      int res = 1, update = 0;
>      ;
>
>      if (update) {
>          // Find the interrupt state of the channel.
>          __chan = __call_vv_CYGNUM_CALL_IF_DEBUG_PROCS();
>          if (__chan)
>              interrupt_state = ({ int res; do { } while (0); res =
> ((__comm_if_control_t)((*__chan)[5]))(((__comm_if_ch_data_t)((*__chan)[0]))
>, __COMMCTL_IRQ_DISABLE); do { } while (0); res;});
>
>          __selected_id = __comm_id;
>         
> hal_virtual_vector_table[6]=(CYG_ADDRWORD)(comm_channels[__comm_id]);
>
>          // Set interrupt state on the new channel.
>          __chan = __call_vv_CYGNUM_CALL_IF_DEBUG_PROCS();
>          if (interrupt_state)
>              ({ int res; do { } while (0); res =
> ((__comm_if_control_t)((*__chan)[5]))(((__comm_if_ch_data_t)((*__chan)[0]))
>, __COMMCTL_IRQ_ENABLE); do { } while (0); res;});
>          else
>              ({ int res; do { } while (0); res =
> ((__comm_if_control_t)((*__chan)[5]))(((__comm_if_ch_data_t)((*__chan)[0]))
>, __COMMCTL_IRQ_DISABLE); do { } while (0); res;});
>      }
>
>      ;
>      return res;
> }
>
>
> *****************************************************************/
>
> /***********************************OUTPUT FILE test.p.c
>   static int
> set_debug_comm (int __comm_id)
> {
>
> static int __selected_id = -2;
>
> hal_virtual_comm_table_t * __chan;
>
> int interrupt_state = 0;
>
> int res = 1, update = 0;
>
> ;
>
>
> if (update)
>      {
>
>          // Find the interrupt state of the channel.
>          __chan = __call_vv_CYGNUM_CALL_IF_DEBUG_PROCS ();
>
> if (__chan)
>
> interrupt_state = (
>                               {
>                               int res;
>                               do
>                               {
>                               }
>                               while (0);
>                               res =
>                               ((__comm_if_control_t) ((*__chan)[5]))
> (((__comm_if_ch_data_t) ((*__chan)[0])), __COMMCTL_IRQ_DISABLE);
>                               do
>                               {
>                               }
>                               while (0); res;}
>            );
>
>
> __selected_id = __comm_id;
>
> hal_virtual_vector_table[6] =
>              (CYG_ADDRWORD) (comm_channels[__comm_id]);
>
>
>              // Set interrupt state on the new channel.
>              __chan = __call_vv_CYGNUM_CALL_IF_DEBUG_PROCS ();
>
> if (interrupt_state)
>
> (
>                 {
>                 int res;
>                 do
>                 {
>                 }
>                 while (0);
>                 res =
>                 ((__comm_if_control_t) ((*__chan)[5]))
> (((__comm_if_ch_data_t) ((*__chan)[0])), __COMMCTL_IRQ_ENABLE); do
>                 {
>                 }
>                 while (0); res;}
>                );
>
>                else
>
> (
>                   {
>                   int res;
>                   do
>                   {
>                   }
>                   while (0);
>                   res =
>                   ((__comm_if_control_t) ((*__chan)[5]))
> (((__comm_if_ch_data_t) ((*__chan)[0])), __COMMCTL_IRQ_DISABLE);
>                   do
>                   {
>                   }
>                   while (0); res;}
>                  );
>
> }
>
> ;
>
> return res;
>
> }
>
>
>
> *****************************************************************/
>
>
>
>
> /--------------------------------------------------------------------------
>-------/
>
> Leslie J. Mulder
> Velocity Software Systems Ltd.
> 438 North Springer Ave.
> Burnaby, B.C.
> Canada V5B 1H4
>
> Tel (604) 291-8183 Fax (604) 291-8443
>
> /--------------------------------------------------------------------------
>-------/
>
>
>
>
> _______________________________________________
> Bug-indent mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-indent

-- 
David Ingamells
email: address@hidden

Tel:      01451 832114
Mobile: 07952 323613




reply via email to

[Prev in Thread] Current Thread [Next in Thread]