• Brad King's avatar
    Isolate formatted streaming blocks with clang-format off/on · 64b55203
    Brad King authored
    The clang-format tool can do a good job formatting most code, but
    well-organized streaming blocks are best left manually formatted.
    
    Find blocks of the form
    
        os <<
          "...\n"
          "...\n"
          ;
    
    using the command
    
        $ git ls-files -z -- Source |
          egrep -v -z '^Source/kwsys/' |
          xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
            '<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'
    
    Find blocks of the form
    
        os << "...\n"
           << "...\n"
           << "...\n";
    
    using the command
    
        $ git ls-files -z -- Source |
          egrep -v -z '^Source/kwsys/' |
          xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
            '<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'
    
    Surround such blocks with the pair
    
        /* clang-format off */
        ...
        /* clang-format on */
    
    in order to protect them from update by clang-format.  Use the C-style
    `/*...*/` comments instead of C++-style `//...` comments in order to
    prevent them from ever being swallowed by re-formatting of surrounding
    comments.
    64b55203
cmExportInstallFileGenerator.cxx 18.8 KB