|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
[PATCH] fix indent handling of range in case statementsindent 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 <jcd@...> --- 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 bug-indent@... http://lists.gnu.org/mailman/listinfo/bug-indent |
|
|
Re: [PATCH] fix indent handling of range in case statementsJust 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 <jcd@...> > > --- 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 > bug-indent@... > http://lists.gnu.org/mailman/listinfo/bug-indent > _______________________________________________ bug-indent mailing list bug-indent@... http://lists.gnu.org/mailman/listinfo/bug-indent |
|
|
Re: [PATCH] fix indent handling of range in case statementsI 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 <jcd@...> >> >> --- 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 >> bug-indent@... >> http://lists.gnu.org/mailman/listinfo/bug-indent >> >> > > > > _______________________________________________ > bug-indent mailing list > bug-indent@... > http://lists.gnu.org/mailman/listinfo/bug-indent > > _______________________________________________ bug-indent mailing list bug-indent@... http://lists.gnu.org/mailman/listinfo/bug-indent |
|
|
Re: [PATCH] fix indent handling of range in case statementsle mercredi 11 novembre 2009 indent a écrit
> 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++. I ran into this "bug" using indent on qemu source code which is not C++ (although it might certainly use some C++ style constructs supported by gcc). That's why I tried to fix it. JC > 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 <jcd@...> > >> > >> --- 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 > >> bug-indent@... > >> http://lists.gnu.org/mailman/listinfo/bug-indent > > > > _______________________________________________ > > bug-indent mailing list > > bug-indent@... > > http://lists.gnu.org/mailman/listinfo/bug-indent > _______________________________________________ bug-indent mailing list bug-indent@... http://lists.gnu.org/mailman/listinfo/bug-indent |
| Free embeddable forum powered by Nabble | Forum Help |