scripted-diff: Remove PAIRTYPE

Zcash: Added an extra command to handle cases where the pair were not
separated by a space.

-BEGIN VERIFY SCRIPT-
sed -i 's/PAIRTYPE(\([^,]*\), \([^\)]*\))/std::pair<\1, \2>/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
sed -i 's/PAIRTYPE(\([^,]*\),\([^\)]*\))/std::pair<\1, \2>/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
sed -i ':a;N;$!ba;s/#define std::pair<t1, t2>    std::pair<t1, t2>\n//' ./src/utilstrencodings.h ;
-END VERIFY SCRIPT-
This commit is contained in:
Jorge Timón 2017-06-02 03:28:42 +02:00 committed by Jack Grigg
parent 92a867febc
commit f5e98e0fb1
10 changed files with 32 additions and 33 deletions

View File

@ -240,7 +240,7 @@ bool CAlert::ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThre
}
// Check if this alert has been cancelled
for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts)
for (std::pair<const uint256, CAlert>& item : mapAlerts)
{
const CAlert& alert = item.second;
if (alert.Cancels(*this))

View File

@ -574,7 +574,7 @@ void CleanupBlockRevFiles()
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
// start removing block files.
int nContigCounter = 0;
for (const PAIRTYPE(string, path)& item : mapBlockFiles) {
for (const std::pair<string, path>& item : mapBlockFiles) {
if (atoi(item.first) == nContigCounter) {
nContigCounter++;
continue;

View File

@ -4662,13 +4662,13 @@ bool static LoadBlockIndexDB()
// Calculate nChainWork
vector<pair<int, CBlockIndex*> > vSortedByHeight;
vSortedByHeight.reserve(mapBlockIndex.size());
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
for (const std::pair<uint256, CBlockIndex*>& item : mapBlockIndex)
{
CBlockIndex* pindex = item.second;
vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
}
sort(vSortedByHeight.begin(), vSortedByHeight.end());
for (const PAIRTYPE(int, CBlockIndex*)& item : vSortedByHeight)
for (const std::pair<int, CBlockIndex*>& item : vSortedByHeight)
{
CBlockIndex* pindex = item.second;
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
@ -4754,7 +4754,7 @@ bool static LoadBlockIndexDB()
// Check presence of blk files
LogPrintf("Checking all blk files are present...\n");
set<int> setBlkDataFiles;
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
for (const std::pair<uint256, CBlockIndex*>& item : mapBlockIndex)
{
CBlockIndex* pindex = item.second;
if (pindex->nStatus & BLOCK_HAVE_DATA) {
@ -4801,7 +4801,7 @@ bool static LoadBlockIndexDB()
}
// Fill in-memory data
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
for (const std::pair<uint256, CBlockIndex*>& item : mapBlockIndex)
{
CBlockIndex* pindex = item.second;
// - This relationship will always be true even if pprev has multiple
@ -5795,7 +5795,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// Relay alerts
{
LOCK(cs_mapAlerts);
for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts)
for (std::pair<const uint256, CAlert>& item : mapAlerts)
item.second.RelayTo(pfrom);
}

View File

@ -1151,9 +1151,9 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
known blocks, and successively remove blocks that appear as pprev
of another block. */
std::set<const CBlockIndex*, CompareBlocksByHeight> setTips;
for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex)
for (const std::pair<const uint256, CBlockIndex*>& item : mapBlockIndex)
setTips.insert(item.second);
for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex)
for (const std::pair<const uint256, CBlockIndex*>& item : mapBlockIndex)
{
const CBlockIndex* pprev = item.second->pprev;
if (pprev)

View File

@ -478,7 +478,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp)
UniValue localAddresses(UniValue::VARR);
{
LOCK(cs_mapLocalHost);
for (const PAIRTYPE(CNetAddr, LocalServiceInfo) &item : mapLocalHost)
for (const std::pair<CNetAddr, LocalServiceInfo> &item : mapLocalHost)
{
UniValue rec(UniValue::VOBJ);
rec.pushKV("address", item.first.ToString());

View File

@ -97,7 +97,7 @@ void RPCTypeCheckObj(const UniValue& o,
const map<string, UniValue::VType>& typesExpected,
bool fAllowNull)
{
for (const PAIRTYPE(string, UniValue::VType)& t : typesExpected)
for (const std::pair<string, UniValue::VType>& t : typesExpected)
{
const UniValue& v = find_value(o, t.first);
if (!fAllowNull && v.isNull())
@ -178,7 +178,7 @@ std::string CRPCTable::help(const std::string& strCommand) const
vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second));
sort(vCommands.begin(), vCommands.end());
for (const PAIRTYPE(string, const CRPCCommand*)& command : vCommands)
for (const std::pair<string, const CRPCCommand*>& command : vCommands)
{
const CRPCCommand *pcmd = command.second;
string strMethod = pcmd->name;

View File

@ -76,7 +76,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
LogPrintf("Previous lock order was:\n");
for (const PAIRTYPE(void*, CLockLocation) & i : s2) {
for (const std::pair<void*, CLockLocation> & i : s2) {
if (i.first == mismatch.first) {
LogPrintf(" (1)");
if (!firstLocked && secondLocked && i.second.fTry)
@ -94,7 +94,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
firstLocked = false;
secondLocked = false;
LogPrintf("Current lock order is:\n");
for (const PAIRTYPE(void*, CLockLocation) & i : s1) {
for (const std::pair<void*, CLockLocation> & i : s1) {
if (i.first == mismatch.first) {
LogPrintf(" (1)");
if (!firstLocked && secondLocked && i.second.fTry)
@ -122,7 +122,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
(*lockstack).push_back(std::make_pair(c, locklocation));
if (!fTry) {
for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) {
for (const std::pair<void*, CLockLocation> & i : (*lockstack)) {
if (i.first == c)
break;
@ -159,14 +159,14 @@ void LeaveCritical()
std::string LocksHeld()
{
std::string result;
for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack)
for (const std::pair<void*, CLockLocation> & i : *lockstack)
result += i.second.ToString() + std::string("\n");
return result;
}
void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs)
{
for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack)
for (const std::pair<void*, CLockLocation> & i : *lockstack)
if (i.first == cs)
return;
fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());

View File

@ -18,7 +18,6 @@
#define UBEGIN(a) ((unsigned char*)&(a))
#define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
/** Used by SanitizeString() */
enum SafeChars

View File

@ -126,7 +126,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
entry.pushKV("walletconflicts", conflicts);
entry.pushKV("time", wtx.GetTxTime());
entry.pushKV("timereceived", (int64_t)wtx.nTimeReceived);
for (const PAIRTYPE(string,string)& item : wtx.mapValue)
for (const std::pair<string, string>& item : wtx.mapValue)
entry.pushKV(item.first, item.second);
entry.pushKV("vjoinsplit", TxJoinSplitToJSON(wtx));
@ -1650,7 +1650,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp)
includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY;
map<string, CAmount> mapAccountBalances;
for (const PAIRTYPE(CTxDestination, CAddressBookData)& entry : pwalletMain->mapAddressBook) {
for (const std::pair<CTxDestination, CAddressBookData>& entry : pwalletMain->mapAddressBook) {
if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me
mapAccountBalances[entry.second.name] = 0;
}
@ -1685,7 +1685,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp)
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
UniValue ret(UniValue::VOBJ);
for (const PAIRTYPE(string, CAmount)& accountBalance : mapAccountBalances) {
for (const std::pair<string, CAmount>& accountBalance : mapAccountBalances) {
ret.pushKV(accountBalance.first, ValueFromAmount(accountBalance.second));
}
return ret;

View File

@ -1444,7 +1444,7 @@ void CWallet::MarkDirty()
{
{
LOCK(cs_wallet);
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet)
for (std::pair<const uint256, CWalletTx>& item : mapWallet)
item.second.MarkDirty();
}
}
@ -2825,7 +2825,7 @@ void CWallet::ReacceptWalletTransactions()
std::map<int64_t, CWalletTx*> mapSorted;
// Sort pending wallet transactions based on their initial wallet insertion order
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet)
for (std::pair<const uint256, CWalletTx>& item : mapWallet)
{
const uint256& wtxid = item.first;
CWalletTx& wtx = item.second;
@ -2839,7 +2839,7 @@ void CWallet::ReacceptWalletTransactions()
}
// Try to add wallet transactions to memory pool
for (PAIRTYPE(const int64_t, CWalletTx*)& item : mapSorted)
for (std::pair<const int64_t, CWalletTx*>& item : mapSorted)
{
CWalletTx& wtx = *(item.second);
@ -3068,7 +3068,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
LOCK(cs_wallet);
// Sort them in chronological order
multimap<unsigned int, CWalletTx*> mapSorted;
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet)
for (std::pair<const uint256, CWalletTx>& item : mapWallet)
{
CWalletTx& wtx = item.second;
// Don't rebroadcast if newer than nTime:
@ -3076,7 +3076,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
continue;
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
}
for (PAIRTYPE(const unsigned int, CWalletTx*)& item : mapSorted)
for (std::pair<const unsigned int, CWalletTx*>& item : mapSorted)
{
CWalletTx& wtx = *item.second;
if (wtx.RelayWalletTransaction())
@ -3686,7 +3686,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
}
return false;
}
for (PAIRTYPE(const CWalletTx*, unsigned int) pcoin : setCoins)
for (std::pair<const CWalletTx*, unsigned int> pcoin : setCoins)
{
CAmount nCredit = pcoin.first->vout[pcoin.second].nValue;
//The coin age after the next block (depth+1) is used instead of the current,
@ -3779,7 +3779,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
//
// Note how the sequence number is set to max()-1 so that the
// nLockTime set above actually works.
for (const PAIRTYPE(const CWalletTx*,unsigned int)& coin : setCoins)
for (const std::pair<const CWalletTx*, unsigned int>& coin : setCoins)
txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(),
std::numeric_limits<unsigned int>::max()-1));
@ -3789,7 +3789,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// Sign
int nIn = 0;
CTransaction txNewConst(txNew);
for (const PAIRTYPE(const CWalletTx*,unsigned int)& coin : setCoins)
for (const std::pair<const CWalletTx*, unsigned int>& coin : setCoins)
{
bool signSuccess;
const CScript& scriptPubKey = coin.first->vout[coin.second].scriptPubKey;
@ -4035,7 +4035,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
{
// Delete destdata tuples associated with address
std::string strAddress = keyIO.EncodeDestination(address);
for (const PAIRTYPE(string, string) &item : mapAddressBook[address].destdata)
for (const std::pair<string, string> &item : mapAddressBook[address].destdata)
{
CWalletDB(strWalletFile).EraseDestData(strAddress, item.first);
}
@ -4205,7 +4205,7 @@ std::map<CTxDestination, CAmount> CWallet::GetAddressBalances()
{
LOCK(cs_wallet);
for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet)
for (std::pair<uint256, CWalletTx> walletEntry : mapWallet)
{
CWalletTx *pcoin = &walletEntry.second;
@ -4245,7 +4245,7 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
set< set<CTxDestination> > groupings;
set<CTxDestination> grouping;
for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet)
for (std::pair<uint256, CWalletTx> walletEntry : mapWallet)
{
CWalletTx *pcoin = &walletEntry.second;
@ -4336,7 +4336,7 @@ std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAcco
{
LOCK(cs_wallet);
set<CTxDestination> result;
for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook)
for (const std::pair<CTxDestination, CAddressBookData>& item : mapAddressBook)
{
const CTxDestination& address = item.first;
const string& strName = item.second.name;