Remove whitespace before double colon in errors and logs #5497

pull paveljanik wants to merge 1 commits into bitcoin:master from paveljanik:removewhitespacebeforecolon changing 29 files +218 −218
  1. paveljanik commented at 8:23 AM on December 17, 2014: contributor

    Remove unnecessary whitespaces in errors and log messages as previously discussed. E.g.

    error("CAlert::CheckSignature() : verify signature failed");
    

    The space before the colon (':') is removed. This branch was created automatically with the following commands:

    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*error(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*LogPrint(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*LogPrintf(.*\".* : .*\"/ s# : #: #' {} \;
    

    on non GNU system (thus '' after -i, no + etc.). Developers are thus able to replicate its changes on their system to make rebase easy.

    No manual changes in this branch so far. git diff --check empty.

    This have to be handled later or before this PR to completely clean this up automatically (original lines from master):

    1. src/qt/coincontroltreewidget.cpp - the above commands add a newline at the end of file. Do not ask me why. sed was run on OS X 10.10.
    2. These error messages are in the master already and look ugly and the above commands change them:
    return error("AcceptToMemoryPool: : CheckTransaction failed");
    return state.DoS(100, error("AcceptToMemoryPool: : coinbase as individual tx"),
    return error("AcceptToMemoryPool: : nonstandard transaction input");
    
    1. To keep things automatable, the following lines are touched as well.
    LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled");
    LogPrint("net", "got inv: %s  %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
    LogPrint("net", "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop==uint256(0) ? "end" : hashStop.ToString(), nLimit, pfrom->id);
    LogPrintf("AddToWallet %s  %s%s\n", wtxIn.GetHash().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
    

    So a few questions/propositions:

    1. git checkout -- src/qt/coincontroltreewidget.cpp or keep the added newline?
    2. fix these error here manually or separate branch before this?
    3. fix these four problematic lines manually in this branch (deleted whitespaces do not make effect anyway) or let them be?
  2. in src/main.cpp:None in 87e925ce47 outdated
     921 | @@ -922,18 +922,18 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
     922 |          *pfMissingInputs = false;
     923 |  
     924 |      if (!CheckTransaction(tx, state))
     925 | -        return error("AcceptToMemoryPool: : CheckTransaction failed");
     926 | +        return error("AcceptToMemoryPool:: CheckTransaction failed");
    


    Diapolo commented at 8:46 AM on December 17, 2014:

    I'd suggest also (manually) removing these double ::.

  3. in src/main.cpp:None in 87e925ce47 outdated
    2838 | @@ -2839,7 +2839,7 @@ bool static LoadBlockIndexDB()
    2839 |  
    2840 |      // Check whether we have a transaction index
    2841 |      pblocktree->ReadFlag("txindex", fTxIndex);
    2842 | -    LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled");
    2843 | +    LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled": "disabled");
    


    Diapolo commented at 8:47 AM on December 17, 2014:

    NACK to this sort of change, perhaps you can also fix the few lines where this happens by hand?

  4. Diapolo commented at 8:48 AM on December 17, 2014: none

    Concept ACK, i like this pull and suggest fixing the few places with strange results by hand. Also I think all files have a newline at the end, so the change to coincontroltreewidget.cpp doesn't matter IMHO.

  5. paveljanik commented at 10:34 AM on December 17, 2014: contributor

    Hmm, the newline is added by sed itself (I thought my editor is at fault here):

    Pavels-MacBook-Pro:bitcoin pavel$ FILE=src/qt/coincontroltreewidget.cpp; md5sum $FILE; sed -i '' '/.*error(.*\".* : .*\"/ s# : #: #' $FILE ; md5sum $FILE
    8894e548ecb49a93faa32ea1c426d38b  src/qt/coincontroltreewidget.cpp
    fd8d6c1299b9f2b8381c11650176de01  src/qt/coincontroltreewidget.cpp
    Pavels-MacBook-Pro:bitcoin pavel$
    

    This is bug in sed. Good in this case, but a bug anyway.

  6. paveljanik commented at 10:47 AM on December 17, 2014: contributor

    OS X sed:

    Pavels-MacBook-Pro:tmp pavel$ echo -n file without newline at the end >file.txt
    Pavels-MacBook-Pro:tmp pavel$ cat file.txt 
    file without newline at the endPavels-MacBook-Pro:tmp pavel$ 
    Pavels-MacBook-Pro:tmp pavel$ sed 's#without#with#' file.txt 
    file with newline at the end
    Pavels-MacBook-Pro:tmp pavel$ 
    

    GNU sed:

    pavel@h:/tmp> echo -n file without newline at the end >file.txt
    pavel@h:/tmp> cat file.txt 
    file without newline at the endpavel@h:/tmp> 
    pavel@h:/tmp> sed 's#without#with#' file.txt
    file with newline at the endpavel@h:/tmp> 
    

    Bug reported to Apple Bug Reporter (ID 19277039).

  7. paveljanik commented at 6:47 AM on December 18, 2014: contributor

    This is now ready. Will squash later to make the review easier - first commit is automatic. 6b6677e and 6f26a5d are cleanups

  8. Diapolo commented at 10:48 AM on December 18, 2014: none

    Looks good now, utACK!

  9. paveljanik force-pushed on Dec 18, 2014
  10. paveljanik commented at 11:53 PM on December 18, 2014: contributor

    Rebased after constness changes to exceptions.

  11. paveljanik commented at 8:42 AM on December 20, 2014: contributor

    While checking the complete logs, I noticed I forgot about the qt stuff. Done with the following commands:

    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*qWarning(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*qDebug(.*\".* : .*\"/ s# : #: #' {} \;
    
  12. paveljanik force-pushed on Dec 20, 2014
  13. paveljanik commented at 9:05 AM on December 20, 2014: contributor

    And now squashed into one large commit.

  14. paveljanik commented at 9:31 AM on December 20, 2014: contributor

    So to make review easier, the script replicate.sh will do all the work:

    Pavels-MacBook-Pro:bitcoin pavel$ cat replicate.sh 
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*error(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*LogPrint(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*LogPrintf(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*qWarning(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*qDebug(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*failure(.*\".* : .*\"/ s# : #: #g' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*printf(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*assert(.*\".* : .*\"/ s# : #: #' {} \;
    

    And this is a list (reverted diff) of lines that were changed manually (:: -> :, and adding back a space where it was replaced wrongly):

    Pavels-MacBook-Pro:bitcoin pavel$ git diff removewhitespacebeforecolon | grep "^[+-] "
    -        return error("AcceptToMemoryPool: CheckTransaction failed");
    +        return error("AcceptToMemoryPool:: CheckTransaction failed");
    -        return state.DoS(100, error("AcceptToMemoryPool: coinbase as individual tx"),
    +        return state.DoS(100, error("AcceptToMemoryPool:: coinbase as individual tx"),
    -            return error("AcceptToMemoryPool: nonstandard transaction input");
    +            return error("AcceptToMemoryPool:: nonstandard transaction input");
    -    LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled");
    +    LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled": "disabled");
    -            LogPrint("net", "got inv: %s  %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
    +            LogPrint("net", "got inv: %s  %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have": "new", pfrom->id);
    -        LogPrint("net", "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop==uint256(0) ? "end" : hashStop.ToString(), nLimit, pfrom->id);
    +        LogPrint("net", "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight: -1), hashStop==uint256(0) ? "end" : hashStop.ToString(), nLimit, pfrom->id);
    -            throw std::ios_base::failure(feof(file) ? "CAutoFile::read: end of file" : "CAutoFile::read: fread failed");
    +            throw std::ios_base::failure(feof(file) ? "CAutoFile::read: end of file": "CAutoFile::read: fread failed");
    -            throw std::ios_base::failure(feof(src) ? "CBufferedFile::Fill: end of file" : "CBufferedFile::Fill: fread failed");
    +            throw std::ios_base::failure(feof(src) ? "CBufferedFile::Fill: end of file": "CBufferedFile::Fill: fread failed");
    -        printf("  * %s:\n", fCompressed ? "compressed" : "uncompressed");
    +        printf("  * %s:\n", fCompressed ? "compressed": "uncompressed");
    -        LogPrintf("AddToWallet %s  %s%s\n", wtxIn.GetHash().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
    +        LogPrintf("AddToWallet %s  %s%s\n", wtxIn.GetHash().ToString(), (fInsertedNew ? "new": ""), (fUpdated ? "update" : ""));
    Pavels-MacBook-Pro:bitcoin pavel$ 
    

    I won't do anything else now in this PR and wait for your reviews now.

  15. Diapolo commented at 12:58 PM on December 20, 2014: none

    Checked the qt stuff, still utACK from me.

  16. paveljanik force-pushed on Dec 31, 2014
  17. paveljanik commented at 2:03 PM on December 31, 2014: contributor

    Rebased.

  18. Remove whitespaces before double colon in errors and logs 7f1455eb98
  19. paveljanik force-pushed on Jan 8, 2015
  20. paveljanik commented at 10:49 AM on January 8, 2015: contributor

    Rebased again. Now fully automated with:

    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*error(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*LogPrint(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*LogPrintf(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*qWarning(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*qDebug(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*failure(.*\".* : .*\"/ s# : #: #g' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*printf(.*\".* : .*\"/ s# : #: #' {} \;
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/.*assert(.*\".* : .*\"/ s# : #: #' {} \;
    
    # Fix errors:
    find . -type f -and \( -name \*.cpp -or -name \*.h \) -exec sed -i '' '/[^ ]": "/ s#": "#" : "#' {} \;
    sed -i '' 's#pindex->nHeight: -1#pindex->nHeight : -1#' src/main.cpp
    
  21. laanwj added the label Trivial on Jan 8, 2015
  22. fanquake commented at 1:31 AM on January 16, 2015: member

    Needs rebase

  23. Diapolo commented at 7:37 AM on January 16, 2015: none

    I'd love to see this merged soon... scripted cleanup rocks IMHO.

  24. paveljanik commented at 7:40 AM on January 16, 2015: contributor

    I think this should me merged in after 0.10 is finished (to make it easier to merge stuff from last 0.10 fixes). And as soon as it is, I'll rebase again. @Diapolo this was the reason I scripted it ;-)

  25. laanwj commented at 1:28 PM on January 16, 2015: member

    This is part of @theuni 's https://github.com/theuni/bitcoin-trivial/commits/trivial-rebase , and will be merged via that route.

  26. laanwj closed this on Jan 16, 2015

  27. paveljanik deleted the branch on Feb 4, 2015
  28. MarcoFalke locked this on Sep 8, 2021

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-04-28 00:15 UTC

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