Search code examples
c++cuncrustify

uncrustify space after // in wrapped command line


I use uncrustify with following parameter:

sp_cmt_cpp_start                = force         # Add space after opening '//'
cmt_width                       = 78  

Input:

bi.dwSize = sizeof (bi); //Size of the structure itself, must be initialized with sizeof(CGOSBOARDINFO)

Output:

bi.dwSize = sizeof(bi); // Size of the structure itself, must be
                              //initialized with sizeof(CGOSBOARDINFO)

But after // in the second line "//initialized" it should look like:

bi.dwSize = sizeof(bi); // Size of the structure itself, must be
                              // initialized with sizeof(CGOSBOARDINFO)

Does anyone have an idea how to fix this small problem?


Solution

  • I've filed the issue against uncrustify. I've also got a possible fix, if you care and are able to rebuild uncrustify from source.

    https://github.com/bengardner/uncrustify/issues/95

    As a workaround, you can simply change force to add in your uncrustify configuration. This seems to have the right behavior, as long as your comments don't contain embedded double and triple spaces. (uncrustify's line wrapping has slightly wacky behavior when confronted with consecutive whitespace characters.)

    EDIT: The bug is fixed in master, as of 2012-12-04: https://github.com/bengardner/uncrustify/commit/44e0253a