bug-indent
[Top][All Lists]
Advanced

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

Re: [PATCH] fix indent handling of range in case statements


From: Jean-Christophe Dubois
Subject: Re: [PATCH] fix indent handling of range in case statements
Date: Wed, 11 Nov 2009 15:08:58 +0100
User-agent: KMail/1.12.2 (Linux/2.6.31-14-generic; KDE/4.3.2; i686; ; )

Just curious: Is this patch accepted or is it inadequate for some reason?

I got no feed back on this proposed patch.

JC

le jeudi 1 octobre 2009 Jean-Christophe Dubois a écrit
> indent is not handling correctly case statements dealing with values range.
> 
> For example:
> 
>         case 0x01 ... 0x0b:
> 
> Will be transformed by indent in:
> 
>         case 0x01...0 x0b:
> 
> Which cannot compile.
> 
> This patch tries to fix this issue. I am not sure this is the correct
> solution but it seems to work for me.
> 
> Signed-off-by: Jean-Christophe Dubois <address@hidden>
> 
> --- indent-2.2.10.org/src/lexi.c      2008-03-11 19:50:42.000000000 +0100
> +++ indent-2.2.10/src/lexi.c  2009-10-01 01:22:09.349653276 +0200
> @@ -938,28 +938,38 @@
>           break;
> 
>     case '.':
> -      if (parser_state_tos->in_decl &&
> -          (buf_ptr[0] == '.') &&
> +      if ((buf_ptr[0] == '.') &&
>            (buf_ptr[1] == '.'))
>        {
> -        /* check for '...' in a declaration */
> +      /* We have a '...'. This is supposed to mean something */
>           if ((buf_ptr += 2) >= buf_end)
>           {
>              fill_buffer();
>           }
> 
> -         unary_delim = true;
> -         code = decl;
> -         token_end = buf_ptr;
> -         break;
> -      }
> -      unary_delim = false;
> -      code = struct_delim;
> +         if (parser_state_tos->in_decl)
> +         {
> +            /* this is '...' in a declaration */
> +            unary_delim = true;
> +            code = decl;
> +            token_end = buf_ptr;
> +         } else {
> +            /* this is '...' somewhere else */
> +            /* for example: case 1 ... 9: */
> +            unary_delim = true;
> +            code = binary_op;
> +            token_end = buf_ptr;
> +         }
> +      } else {
> +
> +         unary_delim = false;
> +         code = struct_delim;
> 
> -      if (*buf_ptr == '*')   /* object .* pointer-to-member */
> -      {
> -         ++buf_ptr;
> -         token_end = buf_ptr;
> +         if (*buf_ptr == '*')        /* object .* pointer-to-member */
> +         {
> +            ++buf_ptr;
> +            token_end = buf_ptr;
> +         }
>        }
>        break;
> 
> 
> 
> 
> _______________________________________________
> bug-indent mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/bug-indent
> 





reply via email to

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