Menu

#594 Unwanted space between *&

open
nobody
None
2025-03-24
2025-03-21
Zenju
No

AStyle built from git 2025-03-21 converts this

void test(char*& str)
{
}

into this:

void test(char* & str)
{
}

Note the unwanted space before the '&', which shouldn't happen with "--align-pointer=type".

using

--style=allman
--suffix=none
--keep-one-line-blocks
--align-pointer=type
--min-conditional-indent=0
--max-continuation-indent=80
--indent-switches
--indent-col1-comments
--indent-preproc-block
--indent-preproc-define
--pad-header
--pad-comma
--formatted
--lineend=linux
--indent-preproc-block
--convert-tabs
--preserve-ws

Discussion

  • Zenju

    Zenju - 2025-03-23

    There seems to be a more general issue:

    Astyle keeps the following code unchanged:

    void test(int*     test)
    {
        wxWindow   * const win = nullptr;
        int*            const win = nullptr;
        std::vector<std::pair<int, int>>  * const win = nullptr;
    }
    

    expected:

    void test(int* test)
    {
        wxWindow* const win = nullptr;
        int* const win = nullptr;
        std::vector<std::pair<int, int>>* const win = nullptr;
    }
    
     
  • André Simon

    André Simon - 2025-03-23

    I have pushed a fix for the first problem (pointer reference).

    The second you can inmprove with --squeeze-ws. But only int will be recognized as a type, this is a limitation of the current parser.

     
  • Zenju

    Zenju - 2025-03-24

    I have pushed a fix for the first problem (pointer reference).

    It works correctly now, thanks!

    The second you can inmprove with --squeeze-ws. But only int will be recognized as a type, this is a limitation of the current parser.

    Hopfully this function can be restored again at some time. I've been relying on it a lot in Astyle 3.1 to normalize third-party codebases, especially all the function signatures.

     

Log in to post a comment.

Auth0 Logo