[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] fix indent handling of range in case statements
From: |
Jean-Christophe Dubois |
Subject: |
[PATCH] fix indent handling of range in case statements |
Date: |
Thu, 1 Oct 2009 22:27:33 +0200 |
User-agent: |
KMail/1.11.4 (Linux/2.6.28-15-generic; KDE/4.2.4; i686; ; ) |
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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] fix indent handling of range in case statements,
Jean-Christophe Dubois <=