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: indent
Subject: Re: [PATCH] fix indent handling of range in case statements
Date: Wed, 11 Nov 2009 19:44:24 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

I haven't got around to merging it yet, but just looking at the patch
lines it seemed acceptable - although you did not honour the coding style.
I would point out that there are a number of problems with C++ code
(which language "..." is part of and not C) that can break the code, so
be careful using indent on C++.


Jean-Christophe Dubois wrote:
> 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
>>
>>     
>
>
>
> _______________________________________________
> 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]