Menu

#341 --add-brackets misses statements following "added" blocks

closed-fixed
None
2017-04-09
2015-02-17
sfassabet
No

astyle 2.05.1

Environment/.astylerc
--add-brackets
--align-pointer=name
--align-reference=name
--break-blocks
--convert-tabs
--indent-cases
--indent-switches
--indent=spaces=2
--pad-header
--pad-oper
--style=gnu

astyle source code

ASFormatter.cpp:1020
... && (isLegalNameChar(currentChar) && currentChar != '.')

This does not cover all valid statements.

The following ...

main
{
if (1) return 0; ptr='[';
if (1) return 1; ++ptr;
if (1) return 1; --ptr;
if (1) return 1; (int
)ptr=1;
}

yields ...

main
{
if (1)
{
return 0;
} *ptr = '[';

if (1)
{
return 1;
} ++ptr;

if (1)
{
return 1;
} --ptr;

if (1)
{
return 1;
} (int *)ptr = 1;
}

rather than ...

main
{
if (1)
{
return 0;
}

*ptr = '[';

if (1)
{
return 1;
}

++ptr;

if (1)
{
return 1;
}

--ptr;

if (1)
{
return 1;
}

(int *)ptr = 1;
}

Discussion

  • Jim Pattee

    Jim Pattee - 2017-02-22
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,3 @@
    -
     astyle 2.05.1
    
     Environment/.astylerc
    
    • status: open --> open-fixed
    • assigned_to: Jim Pattee
     
  • Jim Pattee

    Jim Pattee - 2017-02-22

    Fixed.

     
  • Jim Pattee

    Jim Pattee - 2017-04-09
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.