style: make clang-format break long lines #21223

pull vasild wants to merge 1 commits into bitcoin:master from vasild:clang-format-ColumnLimit changing 1 files +1 −1
  1. vasild commented at 1:36 PM on February 18, 2021: member

    Without limit clang-format would join manually broken lines into a single very long line, hindering readability.

  2. style: make clang-format break long lines
    Without limit clang-format would join manually broken lines into a
    single very long line, hindering readability.
    1322dae9da
  3. laanwj added the label Scripts and tools on Feb 18, 2021
  4. jnewbery commented at 3:52 PM on February 18, 2021: member

    @vasild do you have an example of this? The only instances I've seen are argument/parameter lists, which should be fixed by #21221.

  5. vasild commented at 5:36 PM on February 18, 2021: member

    Yes (those are not affected by BinPackParameters and BinPackArguments from #21221):

    before (without limit, master):

        txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
    
    //
    
                        for (std::set<uint256>::iterator it = pto->m_tx_relay->setInventoryTxToSend.begin(); it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) {
    
    //
    
            if (m_shift < n || m_shift >= std::numeric_limits<uint64_t>::max() || m_shift < std::numeric_limits<I>::min() || m_shift > std::numeric_limits<I>::max()) throw std::ios_base::failure("differential value overflow");
    
    //
    
        std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(vChain.begin(), vChain.end(), blockparams,
            [](CBlockIndex* pBlock, const std::pair<int64_t, int>& blockparams) -> bool { return pBlock->GetBlockTimeMax() < blockparams.first || pBlock->nHeight < blockparams.second; });
    

    after (with limit, this PR):

        txNew.vin[0].scriptSig = CScript()
                                 << 486604799 << CScriptNum(4)
                                 << std::vector<unsigned char>(
                                        (const unsigned char*)pszTimestamp,
                                        (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
    
    //
    
                        for (std::set<uint256>::iterator it =
                                 pto->m_tx_relay->setInventoryTxToSend.begin();
                             it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) {
    
    //
    
            if (m_shift < n || m_shift >= std::numeric_limits<uint64_t>::max() ||
                m_shift < std::numeric_limits<I>::min() || m_shift > std::numeric_limits<I>::max())
                throw std::ios_base::failure("differential value overflow");
    
    //
    
        std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(
            vChain.begin(), vChain.end(), blockparams,
            [](CBlockIndex* pBlock, const std::pair<int64_t, int>& blockparams) -> bool {
                return pBlock->GetBlockTimeMax() < blockparams.first ||
                       pBlock->nHeight < blockparams.second;
            });
    

    Maybe I did not pick the best examples, see the output of git grep '.{100,}' '*.cpp' '*.h' (or 150 for the extreme cases).

  6. vasild commented at 9:21 AM on February 19, 2021: member

    @jnewbery, I just realized that you asked for an example where clang-format would join a manually broken line and I gave examples where it would break a long line (the opposite).

    Indeed I cannot find such examples, other than functions' arguments/parameters, which is addressed in #21221.

    Closing this in favor of #21221. Will reopen if I find examples where manually broken lines get joined (with #21221 merged).

  7. vasild closed this on Feb 19, 2021

  8. jnewbery commented at 9:23 AM on February 19, 2021: member

    Thanks @vasild!

  9. DrahtBot locked this on Aug 16, 2022
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 18:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me