Merge branch 'clang-format-3.9'

pull/765/head
Tatsuhiro Tsujikawa 2016-10-15 19:07:24 +09:00
commit df19921b83
52 changed files with 387 additions and 297 deletions

View File

@ -1,65 +1,94 @@
--- ---
Language: Cpp Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2 AccessModifierOffset: -2
AlignAfterOpenBracket: true AlignAfterOpenBracket: true
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false AlignEscapedNewlinesLeft: false
AlignOperands: true AlignOperands: true
AlignTrailingComments: true AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterDefinitionReturnType: false AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeBraces: Stroustrup
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false BreakConstructorInitializersBeforeComma: false
BinPackParameters: true BreakAfterJavaFieldAnnotations: false
BinPackArguments: true BreakStringLiterals: true
ColumnLimit: 80 ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: false IndentCaseLabels: false
IndentWidth: 2
IndentWrappedFunctionNames: false IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false JavaScriptQuotes: Leave
MaxEmptyLinesToKeep: 1 JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None NamespaceIndentation: None
ObjCBlockIndentWidth: 2 ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300 PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120 PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1 SpacesBeforeTrailingComments: 1
Cpp11BracedListStyle: true SpacesInAngles: false
Standard: Cpp11 SpacesInContainerLiterals: true
IndentWidth: 2 SpacesInCStyleCastParentheses: false
TabWidth: 8
UseTab: Never
BreakBeforeBraces: Stroustrup
SpacesInParentheses: false SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
SpacesInAngles: false Standard: Cpp11
SpaceInEmptyParentheses: false TabWidth: 8
SpacesInCStyleCastParentheses: false UseTab: Never
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
DisableFormat: false
... ...

View File

@ -111,8 +111,9 @@ int main(int argc, char** argv)
// the application can call aria2 API to add URI or query progress // the application can call aria2 API to add URI or query progress
// here // here
auto now = std::chrono::steady_clock::now(); auto now = std::chrono::steady_clock::now();
auto count = std::chrono::duration_cast<std::chrono::milliseconds>( auto count =
now - start).count(); std::chrono::duration_cast<std::chrono::milliseconds>(now - start)
.count();
// Print progress information once per 500ms // Print progress information once per 500ms
if (count >= 500) { if (count >= 500) {
start = now; start = now;
@ -130,7 +131,8 @@ int main(int argc, char** argv)
<< "(" << (dh->getTotalLength() > 0 << "(" << (dh->getTotalLength() > 0
? (100 * dh->getCompletedLength() / ? (100 * dh->getCompletedLength() /
dh->getTotalLength()) dh->getTotalLength())
: 0) << "%)" : 0)
<< "%)"
<< " D:" << dh->getDownloadSpeed() / 1024 << " D:" << dh->getDownloadSpeed() / 1024
<< "KiB/s, U:" << dh->getUploadSpeed() / 1024 << "KiB/s" << "KiB/s, U:" << dh->getUploadSpeed() / 1024 << "KiB/s"
<< std::endl; << std::endl;

View File

@ -389,8 +389,9 @@ int downloaderJob(JobQueue& jobq, NotifyQueue& notifyq)
break; break;
} }
auto now = std::chrono::steady_clock::now(); auto now = std::chrono::steady_clock::now();
auto count = std::chrono::duration_cast<std::chrono::milliseconds>( auto count =
now - start).count(); std::chrono::duration_cast<std::chrono::milliseconds>(now - start)
.count();
while (!jobq.empty()) { while (!jobq.empty()) {
std::unique_ptr<Job> job = jobq.pop(); std::unique_ptr<Job> job = jobq.pop();
job->execute(session); job->execute(session);

View File

@ -329,7 +329,8 @@ bool AbstractCommand::execute()
req_->getConnectedPort()); req_->getConnectedPort());
} }
if (e_->findCachedIPAddress(req_->getConnectedHostname(), if (e_->findCachedIPAddress(req_->getConnectedHostname(),
req_->getConnectedPort()).empty()) { req_->getConnectedPort())
.empty()) {
A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - All IP addresses were marked bad." A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - All IP addresses were marked bad."
" Removing Entry.", " Removing Entry.",
getCuid())); getCuid()));

View File

@ -41,11 +41,7 @@ namespace aria2 {
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
#define ADLER32_MESSAGE_DIGEST \ #define ADLER32_MESSAGE_DIGEST {"adler32", make_hi<Adler32MessageDigestImpl>()},
{ \
"adler32", make_hi<Adler32MessageDigestImpl>() \
} \
,
class Adler32MessageDigestImpl : public MessageDigestImpl { class Adler32MessageDigestImpl : public MessageDigestImpl {
public: public:

View File

@ -71,21 +71,23 @@ private:
}; };
typedef MessageDigestBase<CC_MD5_DIGEST_LENGTH, CC_MD5_CTX, CC_MD5_Init, typedef MessageDigestBase<CC_MD5_DIGEST_LENGTH, CC_MD5_CTX, CC_MD5_Init,
CC_MD5_Update, CC_MD5_Final> MessageDigestMD5; CC_MD5_Update, CC_MD5_Final>
MessageDigestMD5;
typedef MessageDigestBase<CC_SHA1_DIGEST_LENGTH, CC_SHA1_CTX, CC_SHA1_Init, typedef MessageDigestBase<CC_SHA1_DIGEST_LENGTH, CC_SHA1_CTX, CC_SHA1_Init,
CC_SHA1_Update, CC_SHA1_Final> MessageDigestSHA1; CC_SHA1_Update, CC_SHA1_Final>
MessageDigestSHA1;
typedef MessageDigestBase<CC_SHA224_DIGEST_LENGTH, CC_SHA256_CTX, typedef MessageDigestBase<CC_SHA224_DIGEST_LENGTH, CC_SHA256_CTX,
CC_SHA224_Init, CC_SHA224_Update, CC_SHA224_Init, CC_SHA224_Update, CC_SHA224_Final>
CC_SHA224_Final> MessageDigestSHA224; MessageDigestSHA224;
typedef MessageDigestBase<CC_SHA256_DIGEST_LENGTH, CC_SHA256_CTX, typedef MessageDigestBase<CC_SHA256_DIGEST_LENGTH, CC_SHA256_CTX,
CC_SHA256_Init, CC_SHA256_Update, CC_SHA256_Init, CC_SHA256_Update, CC_SHA256_Final>
CC_SHA256_Final> MessageDigestSHA256; MessageDigestSHA256;
typedef MessageDigestBase<CC_SHA384_DIGEST_LENGTH, CC_SHA512_CTX, typedef MessageDigestBase<CC_SHA384_DIGEST_LENGTH, CC_SHA512_CTX,
CC_SHA384_Init, CC_SHA384_Update, CC_SHA384_Init, CC_SHA384_Update, CC_SHA384_Final>
CC_SHA384_Final> MessageDigestSHA384; MessageDigestSHA384;
typedef MessageDigestBase<CC_SHA512_DIGEST_LENGTH, CC_SHA512_CTX, typedef MessageDigestBase<CC_SHA512_DIGEST_LENGTH, CC_SHA512_CTX,
CC_SHA512_Init, CC_SHA512_Update, CC_SHA512_Init, CC_SHA512_Update, CC_SHA512_Final>
CC_SHA512_Final> MessageDigestSHA512; MessageDigestSHA512;
} // namespace } // namespace

View File

@ -107,7 +107,8 @@ static struct {
} kSuites[] = { } kSuites[] = {
// From CipherSuite.h (10.11) // From CipherSuite.h (10.11)
SUITE(SSL_NULL_WITH_NULL_NULL, 0x0000), SUITE(SSL_NULL_WITH_NULL_NULL, 0x0000),
SUITE(SSL_RSA_WITH_NULL_MD5, 0x0001), SUITE(SSL_RSA_WITH_NULL_SHA, 0x0002), SUITE(SSL_RSA_WITH_NULL_MD5, 0x0001),
SUITE(SSL_RSA_WITH_NULL_SHA, 0x0002),
SUITE(SSL_RSA_EXPORT_WITH_RC4_40_MD5, 0x0003), SUITE(SSL_RSA_EXPORT_WITH_RC4_40_MD5, 0x0003),
SUITE(SSL_RSA_WITH_RC4_128_MD5, 0x0004), SUITE(SSL_RSA_WITH_RC4_128_MD5, 0x0004),
SUITE(SSL_RSA_WITH_RC4_128_SHA, 0x0005), SUITE(SSL_RSA_WITH_RC4_128_SHA, 0x0005),
@ -173,7 +174,8 @@ static struct {
SUITE(TLS_ECDH_anon_WITH_AES_128_CBC_SHA, 0xC018), SUITE(TLS_ECDH_anon_WITH_AES_128_CBC_SHA, 0xC018),
SUITE(TLS_ECDH_anon_WITH_AES_256_CBC_SHA, 0xC019), SUITE(TLS_ECDH_anon_WITH_AES_256_CBC_SHA, 0xC019),
SUITE(TLS_NULL_WITH_NULL_NULL, 0x0000), SUITE(TLS_NULL_WITH_NULL_NULL, 0x0000),
SUITE(TLS_RSA_WITH_NULL_MD5, 0x0001), SUITE(TLS_RSA_WITH_NULL_SHA, 0x0002), SUITE(TLS_RSA_WITH_NULL_MD5, 0x0001),
SUITE(TLS_RSA_WITH_NULL_SHA, 0x0002),
SUITE(TLS_RSA_WITH_RC4_128_MD5, 0x0004), SUITE(TLS_RSA_WITH_RC4_128_MD5, 0x0004),
SUITE(TLS_RSA_WITH_RC4_128_SHA, 0x0005), SUITE(TLS_RSA_WITH_RC4_128_SHA, 0x0005),
SUITE(TLS_RSA_WITH_3DES_EDE_CBC_SHA, 0x000A), SUITE(TLS_RSA_WITH_3DES_EDE_CBC_SHA, 0x000A),

View File

@ -84,8 +84,8 @@ AuthConfigFactory::createAuthConfig(const std::shared_ptr<Request>& request,
request->getPassword()); request->getPassword());
} }
else { else {
return createHttpAuthResolver(op) return createHttpAuthResolver(op)->resolveAuthConfig(
->resolveAuthConfig(request->getHost()); request->getHost());
} }
} }
} }

View File

@ -76,7 +76,8 @@ public:
class AuthConfigFactory { class AuthConfigFactory {
public: public:
typedef std::set<std::unique_ptr<BasicCred>, typedef std::set<std::unique_ptr<BasicCred>,
DerefLess<std::unique_ptr<BasicCred>>> BasicCredSet; DerefLess<std::unique_ptr<BasicCred>>>
BasicCredSet;
private: private:
std::unique_ptr<Netrc> netrc_; std::unique_ptr<Netrc> netrc_;

View File

@ -259,8 +259,8 @@ void printProgressSummary(const RequestGroupList& groups, size_t cols,
o << " as of " << buf; o << " as of " << buf;
} }
} }
o << " *** \n" << std::setfill(SEP_CHAR) << std::setw(cols) << SEP_CHAR o << " *** \n"
<< "\n"; << std::setfill(SEP_CHAR) << std::setw(cols) << SEP_CHAR << "\n";
global::cout()->write(o.str().c_str()); global::cout()->write(o.str().c_str());
std::for_each(groups.begin(), groups.end(), std::for_each(groups.begin(), groups.end(),
PrintSummary(cols, e, sizeFormatter)); PrintSummary(cols, e, sizeFormatter));

View File

@ -97,9 +97,10 @@ bool DHTGetPeersCommand::execute()
elapsed >= GET_PEER_INTERVAL_LOW)) || elapsed >= GET_PEER_INTERVAL_LOW)) ||
(btRuntime_->getConnections() == 0 && (btRuntime_->getConnections() == 0 &&
elapsed >= GET_PEER_INTERVAL_ZERO))))) { elapsed >= GET_PEER_INTERVAL_ZERO))))) {
A2_LOG_DEBUG(fmt("Issuing PeerLookup for infoHash=%s", A2_LOG_DEBUG(
bittorrent::getInfoHashString( fmt("Issuing PeerLookup for infoHash=%s",
requestGroup_->getDownloadContext()).c_str())); bittorrent::getInfoHashString(requestGroup_->getDownloadContext())
.c_str()));
task_ = taskFactory_->createPeerLookupTask( task_ = taskFactory_->createPeerLookupTask(
requestGroup_->getDownloadContext(), e_->getBtRegistry()->getTcpPort(), requestGroup_->getDownloadContext(), e_->getBtRegistry()->getTcpPort(),
peerStorage_); peerStorage_);

View File

@ -50,16 +50,14 @@ class DHTMessageDispatcher {
public: public:
virtual ~DHTMessageDispatcher() = default; virtual ~DHTMessageDispatcher() = default;
virtual void virtual void addMessageToQueue(std::unique_ptr<DHTMessage> message,
addMessageToQueue(std::unique_ptr<DHTMessage> message,
std::chrono::seconds timeout, std::chrono::seconds timeout,
std::unique_ptr<DHTMessageCallback> std::unique_ptr<DHTMessageCallback> callback =
callback = std::unique_ptr<DHTMessageCallback>{}) = 0; std::unique_ptr<DHTMessageCallback>{}) = 0;
virtual void virtual void addMessageToQueue(std::unique_ptr<DHTMessage> message,
addMessageToQueue(std::unique_ptr<DHTMessage> message, std::unique_ptr<DHTMessageCallback> callback =
std::unique_ptr<DHTMessageCallback> std::unique_ptr<DHTMessageCallback>{}) = 0;
callback = std::unique_ptr<DHTMessageCallback>{}) = 0;
virtual void sendMessages() = 0; virtual void sendMessages() = 0;

View File

@ -56,15 +56,16 @@ private:
public: public:
DHTMessageDispatcherImpl(const std::shared_ptr<DHTMessageTracker>& tracker); DHTMessageDispatcherImpl(const std::shared_ptr<DHTMessageTracker>& tracker);
virtual void addMessageToQueue( virtual void
std::unique_ptr<DHTMessage> message, std::chrono::seconds timeout, addMessageToQueue(std::unique_ptr<DHTMessage> message,
std::unique_ptr<DHTMessageCallback> std::chrono::seconds timeout,
callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE; std::unique_ptr<DHTMessageCallback> callback =
std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE;
virtual void addMessageToQueue( virtual void
std::unique_ptr<DHTMessage> message, addMessageToQueue(std::unique_ptr<DHTMessage> message,
std::unique_ptr<DHTMessageCallback> std::unique_ptr<DHTMessageCallback> callback =
callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE; std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE;
virtual void sendMessages() CXX11_OVERRIDE; virtual void sendMessages() CXX11_OVERRIDE;

View File

@ -98,7 +98,8 @@ private:
}; };
typedef std::set<std::shared_ptr<CacheEntry>, typedef std::set<std::shared_ptr<CacheEntry>,
DerefLess<std::shared_ptr<CacheEntry>>> CacheEntrySet; DerefLess<std::shared_ptr<CacheEntry>>>
CacheEntrySet;
CacheEntrySet entries_; CacheEntrySet entries_;
public: public:

View File

@ -161,7 +161,8 @@ std::string DefaultBtAnnounce::getAnnounceUrl()
const size_t keyLen = 8; const size_t keyLen = 8;
std::string uri = announceList_.getAnnounce(); std::string uri = announceList_.getAnnounce();
uri += uriHasQuery(uri) ? "&" : "?"; uri += uriHasQuery(uri) ? "&" : "?";
uri += fmt("info_hash=%s&" uri +=
fmt("info_hash=%s&"
"peer_id=%s&" "peer_id=%s&"
"uploaded=%" PRId64 "&" "uploaded=%" PRId64 "&"
"downloaded=%" PRId64 "&" "downloaded=%" PRId64 "&"
@ -171,13 +172,14 @@ std::string DefaultBtAnnounce::getAnnounceUrl()
"numwant=%d&" "numwant=%d&"
"no_peer_id=1", "no_peer_id=1",
util::percentEncode(bittorrent::getInfoHash(downloadContext_), util::percentEncode(bittorrent::getInfoHash(downloadContext_),
INFO_HASH_LENGTH).c_str(), INFO_HASH_LENGTH)
.c_str(),
util::percentEncode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH) util::percentEncode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH)
.c_str(), .c_str(),
stat.getSessionUploadLength(), stat.getSessionDownloadLength(), stat.getSessionUploadLength(), stat.getSessionDownloadLength(), left,
left, util::percentEncode(bittorrent::getStaticPeerId() + util::percentEncode(
PEER_ID_LENGTH - keyLen, bittorrent::getStaticPeerId() + PEER_ID_LENGTH - keyLen, keyLen)
keyLen).c_str(), .c_str(),
numWant); numWant);
if (tcpPort_) { if (tcpPort_) {
uri += fmt("&port=%u", tcpPort_); uri += fmt("&port=%u", tcpPort_);

View File

@ -88,8 +88,9 @@ DefaultBtMessageReceiver::receiveHandshake(bool quickReply)
} }
else { else {
throw DL_ABORT_EX( throw DL_ABORT_EX(
fmt("Bad Info Hash %s", util::toHex(peerConnection_->getBuffer() + 28, fmt("Bad Info Hash %s",
INFO_HASH_LENGTH).c_str())); util::toHex(peerConnection_->getBuffer() + 28, INFO_HASH_LENGTH)
.c_str()));
} }
if (peerConnection_->getBufferLength() == if (peerConnection_->getBufferLength() ==
BtHandshakeMessage::MESSAGE_LENGTH && BtHandshakeMessage::MESSAGE_LENGTH &&

View File

@ -431,8 +431,8 @@ std::multimap<std::string, DownloadEngine::SocketPoolEntry>::iterator
DownloadEngine::findSocketPoolEntry(const std::string& key) DownloadEngine::findSocketPoolEntry(const std::string& key)
{ {
std::pair<std::multimap<std::string, SocketPoolEntry>::iterator, std::pair<std::multimap<std::string, SocketPoolEntry>::iterator,
std::multimap<std::string, SocketPoolEntry>::iterator> range = std::multimap<std::string, SocketPoolEntry>::iterator>
socketPool_.equal_range(key); range = socketPool_.equal_range(key);
for (auto i = range.first, eoi = range.second; i != eoi; ++i) { for (auto i = range.first, eoi = range.second; i != eoi; ++i) {
const SocketPoolEntry& e = (*i).second; const SocketPoolEntry& e = (*i).second;
// We assume that if socket is readable it means peer shutdowns // We assume that if socket is readable it means peer shutdowns

View File

@ -76,7 +76,8 @@ private:
KSocketEntrySet socketEntries_; KSocketEntrySet socketEntries_;
#ifdef ENABLE_ASYNC_DNS #ifdef ENABLE_ASYNC_DNS
typedef std::map<std::pair<AsyncNameResolver*, Command*>, typedef std::map<std::pair<AsyncNameResolver*, Command*>,
KAsyncNameResolverEntry> KAsyncNameResolverEntrySet; KAsyncNameResolverEntry>
KAsyncNameResolverEntrySet;
KAsyncNameResolverEntrySet nameResolverEntries_; KAsyncNameResolverEntrySet nameResolverEntries_;
#endif // ENABLE_ASYNC_DNS #endif // ENABLE_ASYNC_DNS

View File

@ -72,10 +72,11 @@ bool FileAllocationCommand::executeInternal()
} }
fileAllocationEntry_->allocateChunk(); fileAllocationEntry_->allocateChunk();
if (fileAllocationEntry_->finished()) { if (fileAllocationEntry_->finished()) {
A2_LOG_DEBUG(fmt(MSG_ALLOCATION_COMPLETED, A2_LOG_DEBUG(fmt(
static_cast<long int>( MSG_ALLOCATION_COMPLETED,
std::chrono::duration_cast<std::chrono::seconds>( static_cast<long int>(std::chrono::duration_cast<std::chrono::seconds>(
timer_.difference(global::wallclock())).count()), timer_.difference(global::wallclock()))
.count()),
getRequestGroup()->getTotalLength())); getRequestGroup()->getTotalLength()));
std::vector<std::unique_ptr<Command>> commands; std::vector<std::unique_ptr<Command>> commands;
fileAllocationEntry_->prepareForNextAction(commands, getDownloadEngine()); fileAllocationEntry_->prepareForNextAction(commands, getDownloadEngine());

View File

@ -195,8 +195,8 @@ void HttpHeader::setReasonPhrase(const std::string& reasonPhrase)
bool HttpHeader::fieldContains(int hdKey, const char* value) bool HttpHeader::fieldContains(int hdKey, const char* value)
{ {
std::pair<std::multimap<int, std::string>::const_iterator, std::pair<std::multimap<int, std::string>::const_iterator,
std::multimap<int, std::string>::const_iterator> range = std::multimap<int, std::string>::const_iterator>
equalRange(hdKey); range = equalRange(hdKey);
for (auto i = range.first; i != range.second; ++i) { for (auto i = range.first; i != range.second; ++i) {
std::vector<Scip> values; std::vector<Scip> values;
util::splitIter((*i).second.begin(), (*i).second.end(), util::splitIter((*i).second.begin(), (*i).second.end(),
@ -221,12 +221,29 @@ bool HttpHeader::isKeepAlive() const
namespace { namespace {
const char* INTERESTING_HEADER_NAMES[] = { const char* INTERESTING_HEADER_NAMES[] = {
"accept-encoding", "access-control-request-headers", "accept-encoding",
"access-control-request-method", "authorization", "connection", "access-control-request-headers",
"content-disposition", "content-encoding", "content-length", "access-control-request-method",
"content-range", "content-type", "digest", "infohash", "last-modified", "authorization",
"link", "location", "origin", "port", "retry-after", "sec-websocket-key", "connection",
"sec-websocket-version", "set-cookie", "transfer-encoding", "upgrade", "content-disposition",
"content-encoding",
"content-length",
"content-range",
"content-type",
"digest",
"infohash",
"last-modified",
"link",
"location",
"origin",
"port",
"retry-after",
"sec-websocket-key",
"sec-websocket-version",
"set-cookie",
"transfer-encoding",
"upgrade",
}; };
} // namespace } // namespace

View File

@ -50,10 +50,12 @@ template <typename SeqType, typename ValueType, typename ReferenceType,
typename PointerType, typename SeqIteratorType> typename PointerType, typename SeqIteratorType>
struct IndexedListIterator { struct IndexedListIterator {
typedef IndexedListIterator<SeqType, ValueType, ValueType&, ValueType*, typedef IndexedListIterator<SeqType, ValueType, ValueType&, ValueType*,
typename SeqType::iterator> iterator; typename SeqType::iterator>
iterator;
typedef IndexedListIterator<SeqType, ValueType, const ValueType&, typedef IndexedListIterator<SeqType, ValueType, const ValueType&,
const ValueType*, const ValueType*,
typename SeqType::const_iterator> const_iterator; typename SeqType::const_iterator>
const_iterator;
typedef typename SeqIteratorType::iterator_category iterator_category; typedef typename SeqIteratorType::iterator_category iterator_category;
typedef ValueType value_type; typedef ValueType value_type;
@ -314,11 +316,12 @@ public:
typedef std::deque<std::pair<KeyType, ValuePtrType>> SeqType; typedef std::deque<std::pair<KeyType, ValuePtrType>> SeqType;
typedef IndexedListIterator<SeqType, ValuePtrType, ValuePtrType&, typedef IndexedListIterator<SeqType, ValuePtrType, ValuePtrType&,
ValuePtrType*, ValuePtrType*, typename SeqType::iterator>
typename SeqType::iterator> iterator; iterator;
typedef IndexedListIterator<SeqType, ValuePtrType, const ValuePtrType&, typedef IndexedListIterator<SeqType, ValuePtrType, const ValuePtrType&,
const ValuePtrType*, const ValuePtrType*,
typename SeqType::const_iterator> const_iterator; typename SeqType::const_iterator>
const_iterator;
ValuePtrType& operator[](size_t n) { return seq_[n].second; } ValuePtrType& operator[](size_t n) { return seq_[n].second; }

View File

@ -56,8 +56,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand(
if (req->getProtocol() == "http" if (req->getProtocol() == "http"
#ifdef ENABLE_SSL #ifdef ENABLE_SSL
// for SSL // for SSL
|| || req->getProtocol() == "https"
req->getProtocol() == "https"
#endif // ENABLE_SSL #endif // ENABLE_SSL
) { ) {

View File

@ -81,7 +81,8 @@ private:
KSocketEntrySet socketEntries_; KSocketEntrySet socketEntries_;
#ifdef ENABLE_ASYNC_DNS #ifdef ENABLE_ASYNC_DNS
typedef std::map<std::pair<AsyncNameResolver*, Command*>, typedef std::map<std::pair<AsyncNameResolver*, Command*>,
KAsyncNameResolverEntry> KAsyncNameResolverEntrySet; KAsyncNameResolverEntry>
KAsyncNameResolverEntrySet;
KAsyncNameResolverEntrySet nameResolverEntries_; KAsyncNameResolverEntrySet nameResolverEntries_;
#endif // ENABLE_ASYNC_DNS #endif // ENABLE_ASYNC_DNS

View File

@ -115,7 +115,8 @@ private:
#ifdef ENABLE_ASYNC_DNS #ifdef ENABLE_ASYNC_DNS
typedef std::map<std::pair<AsyncNameResolver*, Command*>, typedef std::map<std::pair<AsyncNameResolver*, Command*>,
KAsyncNameResolverEntry> KAsyncNameResolverEntrySet; KAsyncNameResolverEntry>
KAsyncNameResolverEntrySet;
#endif // ENABLE_ASYNC_DNS #endif // ENABLE_ASYNC_DNS
uv_loop_t* loop_; uv_loop_t* loop_;

View File

@ -76,7 +76,8 @@ private:
KSocketEntrySet socketEntries_; KSocketEntrySet socketEntries_;
#ifdef ENABLE_ASYNC_DNS #ifdef ENABLE_ASYNC_DNS
typedef std::map<std::pair<AsyncNameResolver*, Command*>, typedef std::map<std::pair<AsyncNameResolver*, Command*>,
KAsyncNameResolverEntry> KAsyncNameResolverEntrySet; KAsyncNameResolverEntry>
KAsyncNameResolverEntrySet;
KAsyncNameResolverEntrySet nameResolverEntries_; KAsyncNameResolverEntrySet nameResolverEntries_;
#endif // ENABLE_ASYNC_DNS #endif // ENABLE_ASYNC_DNS

View File

@ -77,7 +77,8 @@ private:
private: private:
typedef std::set<std::shared_ptr<KSocketEntry>, typedef std::set<std::shared_ptr<KSocketEntry>,
DerefLess<std::shared_ptr<KSocketEntry>>> KSocketEntrySet; DerefLess<std::shared_ptr<KSocketEntry>>>
KSocketEntrySet;
KSocketEntrySet socketEntries_; KSocketEntrySet socketEntries_;
#ifdef ENABLE_ASYNC_DNS #ifdef ENABLE_ASYNC_DNS
typedef std::set<std::shared_ptr<KAsyncNameResolverEntry>, typedef std::set<std::shared_ptr<KAsyncNameResolverEntry>,

View File

@ -777,7 +777,8 @@ void formatDownloadResultCommon(
if (downloadResult->sessionTime.count() > 0) { if (downloadResult->sessionTime.count() > 0) {
o << std::setw(8) o << std::setw(8)
<< util::abbrevSize(downloadResult->sessionDownloadLength * 1000 / << util::abbrevSize(downloadResult->sessionDownloadLength * 1000 /
downloadResult->sessionTime.count()) << "B/s"; downloadResult->sessionTime.count())
<< "B/s";
} }
else { else {
o << std::setw(11); o << std::setw(11);

View File

@ -53,21 +53,43 @@ namespace {
std::vector<std::string> rpcMethodNames = { std::vector<std::string> rpcMethodNames = {
"aria2.addUri", "aria2.addUri",
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
"aria2.addTorrent", "aria2.getPeers", "aria2.addTorrent",
"aria2.getPeers",
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK #ifdef ENABLE_METALINK
"aria2.addMetalink", "aria2.addMetalink",
#endif // ENABLE_METALINK #endif // ENABLE_METALINK
"aria2.remove", "aria2.pause", "aria2.forcePause", "aria2.pauseAll", "aria2.remove",
"aria2.forcePauseAll", "aria2.unpause", "aria2.unpauseAll", "aria2.pause",
"aria2.forceRemove", "aria2.changePosition", "aria2.tellStatus", "aria2.forcePause",
"aria2.getUris", "aria2.getFiles", "aria2.getServers", "aria2.tellActive", "aria2.pauseAll",
"aria2.tellWaiting", "aria2.tellStopped", "aria2.getOption", "aria2.forcePauseAll",
"aria2.changeUri", "aria2.changeOption", "aria2.getGlobalOption", "aria2.unpause",
"aria2.changeGlobalOption", "aria2.purgeDownloadResult", "aria2.unpauseAll",
"aria2.removeDownloadResult", "aria2.getVersion", "aria2.getSessionInfo", "aria2.forceRemove",
"aria2.shutdown", "aria2.forceShutdown", "aria2.getGlobalStat", "aria2.changePosition",
"aria2.saveSession", "system.multicall", "system.listMethods", "aria2.tellStatus",
"aria2.getUris",
"aria2.getFiles",
"aria2.getServers",
"aria2.tellActive",
"aria2.tellWaiting",
"aria2.tellStopped",
"aria2.getOption",
"aria2.changeUri",
"aria2.changeOption",
"aria2.getGlobalOption",
"aria2.changeGlobalOption",
"aria2.purgeDownloadResult",
"aria2.removeDownloadResult",
"aria2.getVersion",
"aria2.getSessionInfo",
"aria2.shutdown",
"aria2.forceShutdown",
"aria2.getGlobalStat",
"aria2.saveSession",
"system.multicall",
"system.listMethods",
"system.listNotifications", "system.listNotifications",
}; };
} // namespace } // namespace

View File

@ -156,7 +156,8 @@ private:
SocketEntrySet socketEntries_; SocketEntrySet socketEntries_;
#ifdef ENABLE_ASYNC_DNS #ifdef ENABLE_ASYNC_DNS
typedef std::map<std::pair<AsyncNameResolver*, Command*>, typedef std::map<std::pair<AsyncNameResolver*, Command*>,
AsyncNameResolverEntry> AsyncNameResolverEntrySet; AsyncNameResolverEntry>
AsyncNameResolverEntrySet;
AsyncNameResolverEntrySet nameResolverEntries_; AsyncNameResolverEntrySet nameResolverEntries_;
#endif // ENABLE_ASYNC_DNS #endif // ENABLE_ASYNC_DNS

View File

@ -66,7 +66,8 @@ public:
private: private:
typedef std::set<std::shared_ptr<ServerStat>, typedef std::set<std::shared_ptr<ServerStat>,
DerefLess<std::shared_ptr<ServerStat>>> ServerStatSet; DerefLess<std::shared_ptr<ServerStat>>>
ServerStatSet;
ServerStatSet serverStats_; ServerStatSet serverStats_;
}; };

View File

@ -107,8 +107,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
* check out. If the call failed, we'll not take this branch at all * check out. If the call failed, we'll not take this branch at all
* and disable support below. * and disable support below.
*/ */
|| || errno != ENOSYS
errno != ENOSYS
#endif #endif
) { ) {
if (rv < -1) { if (rv < -1) {

View File

@ -75,7 +75,8 @@ int SpeedCalc::calculateSpeed()
return 0; return 0;
} }
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>( auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
timeSlots_[0].first.difference(now)).count(); timeSlots_[0].first.difference(now))
.count();
if (elapsed <= 0) { if (elapsed <= 0) {
elapsed = 1; elapsed = 1;
} }
@ -102,7 +103,8 @@ int SpeedCalc::calculateNewestSpeed(int seconds)
} }
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>( auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
(*--it).first.difference(now)).count(); (*--it).first.difference(now))
.count();
if (elapsed <= 0) { if (elapsed <= 0) {
elapsed = 1; elapsed = 1;
} }
@ -128,7 +130,8 @@ void SpeedCalc::update(size_t bytes)
int SpeedCalc::calculateAvgSpeed() const int SpeedCalc::calculateAvgSpeed() const
{ {
auto milliElapsed = std::chrono::duration_cast<std::chrono::milliseconds>( auto milliElapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
start_.difference(global::wallclock())).count(); start_.difference(global::wallclock()))
.count();
// if milliElapsed is too small, the average speed is rubbish, better // if milliElapsed is too small, the average speed is rubbish, better
// return 0 // return 0
if (milliElapsed > 4) { if (milliElapsed > 4) {

View File

@ -55,8 +55,7 @@ public:
Timer(Timer&& time) = default; Timer(Timer&& time) = default;
template <typename duration> template <typename duration>
constexpr explicit Timer(const duration& t) constexpr explicit Timer(const duration& t) : tp_(t)
: tp_(t)
{ {
} }

View File

@ -87,8 +87,7 @@ public:
String(const unsigned char* data, size_t length); String(const unsigned char* data, size_t length);
template <typename InputIterator> template <typename InputIterator>
String(InputIterator first, InputIterator last) String(InputIterator first, InputIterator last) : str_(first, last)
: str_(first, last)
{ {
} }

View File

@ -44,14 +44,14 @@
#endif // __MINGW32__ #endif // __MINGW32__
#ifdef __MINGW32__ #ifdef __MINGW32__
#define a2_sockopt_t char * #define a2_sockopt_t char*
#ifndef HAVE_GETADDRINFO #ifndef HAVE_GETADDRINFO
#define HAVE_GETADDRINFO #define HAVE_GETADDRINFO
#endif // !HAVE_GETADDRINFO #endif // !HAVE_GETADDRINFO
#undef HAVE_GAI_STRERROR #undef HAVE_GAI_STRERROR
#undef gai_strerror #undef gai_strerror
#else #else
#define a2_sockopt_t void * #define a2_sockopt_t void*
#endif // __MINGW32__ #endif // __MINGW32__
#ifdef HAVE_NETDB_H #ifdef HAVE_NETDB_H

View File

@ -61,7 +61,7 @@ you lose-- must know STACK_DIRECTION at compile - time
#if defined(CRAY) && defined(CRAY_STACKSEG_END) #if defined(CRAY) && defined(CRAY_STACKSEG_END)
long long
i00afunc(); i00afunc();
#define ADDRESS_FUNCTION(arg) (char*) i00afunc(&(arg)) #define ADDRESS_FUNCTION(arg) (char*)i00afunc(&(arg))
#else #else
#define ADDRESS_FUNCTION(arg) &(arg) #define ADDRESS_FUNCTION(arg) &(arg)
#endif #endif
@ -344,7 +344,7 @@ static long i00afunc(long* address)
{ {
struct stk_stat status; struct stk_stat status;
struct stk_trailer* trailer; struct stk_trailer* trailer;
long* block, size; long *block, size;
long result = 0; long result = 0;
/* We want to iterate through all of the segments. The first /* We want to iterate through all of the segments. The first

View File

@ -42,7 +42,7 @@
namespace aria2 { namespace aria2 {
template <typename T, size_t N> constexpr size_t arraySize(T(&)[N]) template <typename T, size_t N> constexpr size_t arraySize(T (&)[N])
{ {
return N; return N;
} }

View File

@ -196,7 +196,7 @@ public:
} }
ulong<dim>& operator*=(const ulong<dim>& rhs) ulong<dim>& operator*=(const ulong<dim>& rhs)
{ {
*this = *this* rhs; *this = *this * rhs;
return *this; return *this;
} }

View File

@ -135,8 +135,7 @@ bool parseDate(time_t& time, std::string::const_iterator first,
minute = getInteger(hEnd + 1, mEnd); minute = getInteger(hEnd + 1, mEnd);
second = getInteger(mEnd + 1, sEnd); second = getInteger(mEnd + 1, sEnd);
continue; continue;
NOT_TIME: NOT_TIME:;
;
} }
if (!foundDayOfMonth) { if (!foundDayOfMonth) {
std::string::const_iterator j = getNextDigit((*i).begin(), (*i).end()); std::string::const_iterator j = getNextDigit((*i).begin(), (*i).end());

View File

@ -1032,18 +1032,10 @@ static const std::set<std::string> names{
// For fast name |lookup| // For fast name |lookup|
static const std::unordered_map<std::string, Algorithms> mapped{ static const std::unordered_map<std::string, Algorithms> mapped{
{"md5", algoMD5}, {"md5", algoMD5}, {"sha", algoSHA1}, {"sha1", algoSHA1},
{"sha", algoSHA1}, {"sha-1", algoSHA1}, {"sha224", algoSHA224}, {"sha-224", algoSHA224},
{"sha1", algoSHA1}, {"sha256", algoSHA256}, {"sha-256", algoSHA256}, {"sha384", algoSHA384},
{"sha-1", algoSHA1}, {"sha-384", algoSHA384}, {"sha512", algoSHA512}, {"sha-512", algoSHA512},
{"sha224", algoSHA224},
{"sha-224", algoSHA224},
{"sha256", algoSHA256},
{"sha-256", algoSHA256},
{"sha384", algoSHA384},
{"sha-384", algoSHA384},
{"sha512", algoSHA512},
{"sha-512", algoSHA512},
}; };
static const auto mapped_end = mapped.end(); static const auto mapped_end = mapped.end();
} // namespace } // namespace

View File

@ -74,13 +74,12 @@ static int is_digit(char c) { return '0' <= c && c <= '9'; }
int uri_split(uri_split_result* res, const char* uri) int uri_split(uri_split_result* res, const char* uri)
{ {
int state = URI_BEFORE_SCHEME; int state = URI_BEFORE_SCHEME;
const char* scheme_first = NULL, * scheme_last = NULL, * host_first = NULL, const char *scheme_first = NULL, *scheme_last = NULL, *host_first = NULL,
* host_last = NULL, * path_first = NULL, * path_last = NULL, *host_last = NULL, *path_first = NULL, *path_last = NULL,
* query_first = NULL, * query_last = NULL, *query_first = NULL, *query_last = NULL, *fragment_first = NULL,
* fragment_first = NULL, * fragment_last = NULL, *fragment_last = NULL, *user_first = NULL, *user_last = NULL,
* user_first = NULL, * user_last = NULL, * passwd_first = NULL, *passwd_first = NULL, *passwd_last = NULL, *last_atmark = NULL,
* passwd_last = NULL, * last_atmark = NULL, * last_slash = NULL, *last_slash = NULL, *p = uri;
* p = uri;
int32_t port = -1; int32_t port = -1;
uint8_t flags = 0; uint8_t flags = 0;

View File

@ -547,7 +547,7 @@ bool parseLong(T& res, F f, const std::string& s, int base)
return false; return false;
} }
if (*endptr != '\0') { if (*endptr != '\0') {
for (const char* i = endptr, * eoi = s.c_str() + s.size(); i < eoi; ++i) { for (const char *i = endptr, *eoi = s.c_str() + s.size(); i < eoi; ++i) {
if (!isspace(*i)) { if (!isspace(*i)) {
return false; return false;
} }
@ -750,7 +750,7 @@ void parsePrioritizePieceRange(
std::string iso8859p1ToUtf8(const char* src, size_t len) std::string iso8859p1ToUtf8(const char* src, size_t len)
{ {
std::string dest; std::string dest;
for (const char* p = src, * last = src + len; p != last; ++p) { for (const char *p = src, *last = src + len; p != last; ++p) {
unsigned char c = *p; unsigned char c = *p;
if (0xa0u <= c) { if (0xa0u <= c) {
if (c <= 0xbfu) { if (c <= 0xbfu) {
@ -810,31 +810,28 @@ static const uint8_t utf8d[] = {
* The first part of the table maps bytes to character classes that * The first part of the table maps bytes to character classes that
* to reduce the size of the transition table and create bitmasks. * to reduce the size of the transition table and create bitmasks.
*/ */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 2, 2, 2, 2, 2, 2,
9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, 8,
7, 7, 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 8, 8, 8, 8, 8, 8,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8,
/* /*
* The second part is a transition table that maps a combination * The second part is a transition table that maps a combination
* of a state of the automaton and a character class to a state. * of a state of the automaton and a character class to a state.
*/ */
0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12, 0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12,
12, 12, 12, 12, 12, 24, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12,
12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12,
12, 12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
}; };
static uint32_t utf8dfa(uint32_t* state, uint32_t* codep, uint32_t byte) static uint32_t utf8dfa(uint32_t* state, uint32_t* codep, uint32_t byte)
@ -884,8 +881,8 @@ ssize_t parse_content_disposition(char* dest, size_t destlen,
const char** charsetp, size_t* charsetlenp, const char** charsetp, size_t* charsetlenp,
const char* in, size_t len) const char* in, size_t len)
{ {
const char* p = in, * eop = in + len, * mark_first = nullptr, const char *p = in, *eop = in + len, *mark_first = nullptr,
* mark_last = nullptr; *mark_last = nullptr;
int state = CD_BEFORE_DISPOSITION_TYPE; int state = CD_BEFORE_DISPOSITION_TYPE;
int in_file_parm = 0; int in_file_parm = 0;
int flags = 0; int flags = 0;

View File

@ -67,14 +67,17 @@ void showVersion()
"This program is distributed in the hope that it will be useful,\n" "This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n") << "\n" "GNU General Public License for more details.\n")
<< _("** Configuration **") << "\n" << _("Enabled Features") << ": " << "\n"
<< featureSummary() << "\n" << _("Hash Algorithms") << ": " << _("** Configuration **") << "\n"
<< MessageDigest::getSupportedHashTypeString() << "\n" << _("Libraries") << _("Enabled Features") << ": " << featureSummary() << "\n"
<< ": " << usedLibs() << "\n" << _("Compiler") << ": " << _("Hash Algorithms") << ": "
<< usedCompilerAndPlatform() << "\n" << _("System") << ": " << MessageDigest::getSupportedHashTypeString() << "\n"
<< getOperatingSystemInfo() << "\n" << _("Libraries") << ": " << usedLibs() << "\n"
<< "\n" << fmt(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n" << _("Compiler") << ": " << usedCompilerAndPlatform() << "\n"
<< _("System") << ": " << getOperatingSystemInfo() << "\n"
<< "\n"
<< fmt(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n"
<< _("Visit") << " " << PACKAGE_URL << std::endl; << _("Visit") << " " << PACKAGE_URL << std::endl;
} }
@ -105,7 +108,8 @@ void showUsage(const std::string& keyword,
out->printf("\n"); out->printf("\n");
out->printf(_("Options:")); out->printf(_("Options:"));
out->printf("\n"); out->printf("\n");
for (std::vector<const OptionHandler*>::const_iterator i = handlers.begin(), for (std::vector<const OptionHandler *>::const_iterator
i = handlers.begin(),
eoi = handlers.end(); eoi = handlers.end();
i != eoi; ++i) { i != eoi; ++i) {
write(out, *(*i)); write(out, *(*i));
@ -121,7 +125,7 @@ void showUsage(const std::string& keyword,
out->printf("\n"); out->printf("\n");
out->printf(_("Options:")); out->printf(_("Options:"));
out->printf("\n"); out->printf("\n");
for (std::vector<const OptionHandler*>::const_iterator for (std::vector<const OptionHandler *>::const_iterator
i = handlers.begin(), i = handlers.begin(),
eoi = handlers.end(); eoi = handlers.end();
i != eoi; ++i) { i != eoi; ++i) {

View File

@ -70,10 +70,10 @@ void BtRegistryTest::testGetDownloadContext_infoHash()
attrs1->infoHash = "hash1"; attrs1->infoHash = "hash1";
auto attrs2 = make_unique<TorrentAttribute>(); auto attrs2 = make_unique<TorrentAttribute>();
attrs2->infoHash = "hash2"; attrs2->infoHash = "hash2";
btRegistry.getDownloadContext(1) btRegistry.getDownloadContext(1)->setAttribute(CTX_ATTR_BT,
->setAttribute(CTX_ATTR_BT, std::move(attrs1)); std::move(attrs1));
btRegistry.getDownloadContext(2) btRegistry.getDownloadContext(2)->setAttribute(CTX_ATTR_BT,
->setAttribute(CTX_ATTR_BT, std::move(attrs2)); std::move(attrs2));
} }
CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1")); CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1"));
CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1").get() == CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1").get() ==

View File

@ -77,8 +77,9 @@ void CookieStorageTest::testStore()
CPPUNIT_ASSERT_EQUAL((size_t)1, st.size()); CPPUNIT_ASSERT_EQUAL((size_t)1, st.size());
CPPUNIT_ASSERT(st.contains(*goodCookie())); CPPUNIT_ASSERT(st.contains(*goodCookie()));
auto anotherCookie = auto anotherCookie = []() {
[]() { return createCookie("k", "v", "mirror", true, "/", true); }; return createCookie("k", "v", "mirror", true, "/", true);
};
CPPUNIT_ASSERT(st.store(anotherCookie(), now)); CPPUNIT_ASSERT(st.store(anotherCookie(), now));
CPPUNIT_ASSERT_EQUAL((size_t)2, st.size()); CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
CPPUNIT_ASSERT(st.contains(*anotherCookie())); CPPUNIT_ASSERT(st.contains(*anotherCookie()));
@ -107,8 +108,9 @@ void CookieStorageTest::testStore()
CPPUNIT_ASSERT_EQUAL((size_t)1, st.size()); CPPUNIT_ASSERT_EQUAL((size_t)1, st.size());
CPPUNIT_ASSERT(st.contains(*anotherCookie())); CPPUNIT_ASSERT(st.contains(*anotherCookie()));
auto fromNumericHost = auto fromNumericHost = []() {
[]() { return createCookie("k", "v", "192.168.1.1", true, "/", false); }; return createCookie("k", "v", "192.168.1.1", true, "/", false);
};
CPPUNIT_ASSERT(st.store(fromNumericHost(), now)); CPPUNIT_ASSERT(st.store(fromNumericHost(), now));
CPPUNIT_ASSERT_EQUAL((size_t)2, st.size()); CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
CPPUNIT_ASSERT(st.contains(*fromNumericHost())); CPPUNIT_ASSERT(st.contains(*fromNumericHost()));

View File

@ -109,7 +109,7 @@ void IndexedListTest::testErase()
CPPUNIT_ASSERT_EQUAL((size_t)(std::distance(i, list.end())), list.size()); CPPUNIT_ASSERT_EQUAL((size_t)(std::distance(i, list.end())), list.size());
int* pp = ++p; int* pp = ++p;
for (IndexedList<int, int*>::iterator j = list.begin(); j != list.end(); for (IndexedList<int, int *>::iterator j = list.begin(); j != list.end();
++j, ++pp) { ++j, ++pp) {
CPPUNIT_ASSERT_EQUAL(*pp, **j); CPPUNIT_ASSERT_EQUAL(*pp, **j);
} }

View File

@ -29,19 +29,20 @@ public:
public: public:
MockDHTMessageDispatcher() {} MockDHTMessageDispatcher() {}
virtual void addMessageToQueue( virtual void
std::unique_ptr<DHTMessage> message, std::chrono::seconds timeout, addMessageToQueue(std::unique_ptr<DHTMessage> message,
std::unique_ptr<DHTMessageCallback> std::chrono::seconds timeout,
callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE std::unique_ptr<DHTMessageCallback> callback =
std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
{ {
messageQueue_.push_back( messageQueue_.push_back(
Entry(std::move(message), std::move(timeout), std::move(callback))); Entry(std::move(message), std::move(timeout), std::move(callback)));
} }
virtual void addMessageToQueue( virtual void
std::unique_ptr<DHTMessage> message, addMessageToQueue(std::unique_ptr<DHTMessage> message,
std::unique_ptr<DHTMessageCallback> std::unique_ptr<DHTMessageCallback> callback =
callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
{ {
messageQueue_.push_back( messageQueue_.push_back(
Entry(std::move(message), DHT_MESSAGE_TIMEOUT, std::move(callback))); Entry(std::move(message), DHT_MESSAGE_TIMEOUT, std::move(callback)));

View File

@ -340,14 +340,15 @@ RpcRequest createAddTorrentReq()
void RpcMethodTest::testAddTorrent() void RpcMethodTest::testAddTorrent()
{ {
File(e_->getOption()->get(PREF_DIR) + File(e_->getOption()->get(PREF_DIR) +
"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove(); "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
.remove();
AddTorrentRpcMethod m; AddTorrentRpcMethod m;
{ {
// Saving upload metadata is disabled by option. // Saving upload metadata is disabled by option.
auto res = m.execute(createAddTorrentReq(), e_.get()); auto res = m.execute(createAddTorrentReq(), e_.get());
CPPUNIT_ASSERT( CPPUNIT_ASSERT(!File(e_->getOption()->get(PREF_DIR) +
!File(e_->getOption()->get(PREF_DIR) + "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists()); .exists());
CPPUNIT_ASSERT_EQUAL(0, res.code); CPPUNIT_ASSERT_EQUAL(0, res.code);
CPPUNIT_ASSERT_EQUAL(sizeof(a2_gid_t) * 2, CPPUNIT_ASSERT_EQUAL(sizeof(a2_gid_t) * 2,
downcast<String>(res.param)->s().size()); downcast<String>(res.param)->s().size());
@ -355,9 +356,9 @@ void RpcMethodTest::testAddTorrent()
e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE); e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE);
{ {
auto res = m.execute(createAddTorrentReq(), e_.get()); auto res = m.execute(createAddTorrentReq(), e_.get());
CPPUNIT_ASSERT( CPPUNIT_ASSERT(File(e_->getOption()->get(PREF_DIR) +
File(e_->getOption()->get(PREF_DIR) + "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists()); .exists());
CPPUNIT_ASSERT_EQUAL(0, res.code); CPPUNIT_ASSERT_EQUAL(0, res.code);
a2_gid_t gid; a2_gid_t gid;
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
@ -457,7 +458,8 @@ RpcRequest createAddMetalinkReq()
void RpcMethodTest::testAddMetalink() void RpcMethodTest::testAddMetalink()
{ {
File(e_->getOption()->get(PREF_DIR) + File(e_->getOption()->get(PREF_DIR) +
"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").remove(); "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
.remove();
AddMetalinkRpcMethod m; AddMetalinkRpcMethod m;
{ {
// Saving upload metadata is disabled by option. // Saving upload metadata is disabled by option.
@ -472,9 +474,9 @@ void RpcMethodTest::testAddMetalink()
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
0, GroupId::toNumericId( 0, GroupId::toNumericId(
gid2, downcast<String>(resParams->get(1))->s().c_str())); gid2, downcast<String>(resParams->get(1))->s().c_str()));
CPPUNIT_ASSERT( CPPUNIT_ASSERT(!File(e_->getOption()->get(PREF_DIR) +
!File(e_->getOption()->get(PREF_DIR) + "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists()); .exists());
} }
e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE); e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE);
{ {
@ -489,9 +491,9 @@ void RpcMethodTest::testAddMetalink()
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
0, GroupId::toNumericId( 0, GroupId::toNumericId(
gid4, downcast<String>(resParams->get(1))->s().c_str())); gid4, downcast<String>(resParams->get(1))->s().c_str()));
CPPUNIT_ASSERT( CPPUNIT_ASSERT(File(e_->getOption()->get(PREF_DIR) +
File(e_->getOption()->get(PREF_DIR) + "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists()); .exists());
auto tar = findReservedGroup(e_->getRequestGroupMan().get(), gid3); auto tar = findReservedGroup(e_->getRequestGroupMan().get(), gid3);
CPPUNIT_ASSERT(tar); CPPUNIT_ASSERT(tar);
@ -1018,8 +1020,10 @@ void RpcMethodTest::testGatherProgressCommon()
CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"),
downcast<String>(file->get("path"))->s()); downcast<String>(file->get("path"))->s());
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
uris[0], downcast<String>(downcast<Dict>(downcast<List>(file->get("uris")) uris[0],
->get(0))->get("uri"))->s()); downcast<String>(
downcast<Dict>(downcast<List>(file->get("uris"))->get(0))->get("uri"))
->s());
CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR), CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR),
downcast<String>(entry->get("dir"))->s()); downcast<String>(entry->get("dir"))->s());
@ -1389,15 +1393,18 @@ void RpcMethodTest::testSystemMulticall()
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
GroupId::toHex(getReservedGroup(rgman.get(), 1)->getGID()), GroupId::toHex(getReservedGroup(rgman.get(), 1)->getGID()),
downcast<String>(downcast<List>(resParams->get(1))->get(0))->s()); downcast<String>(downcast<List>(resParams->get(1))->get(0))->s());
CPPUNIT_ASSERT_EQUAL((int64_t)1, CPPUNIT_ASSERT_EQUAL(
downcast<Integer>(downcast<Dict>(resParams->get(2)) (int64_t)1,
->get("faultCode"))->i()); downcast<Integer>(downcast<Dict>(resParams->get(2))->get("faultCode"))
CPPUNIT_ASSERT_EQUAL((int64_t)1, ->i());
downcast<Integer>(downcast<Dict>(resParams->get(3)) CPPUNIT_ASSERT_EQUAL(
->get("faultCode"))->i()); (int64_t)1,
CPPUNIT_ASSERT_EQUAL((int64_t)1, downcast<Integer>(downcast<Dict>(resParams->get(3))->get("faultCode"))
downcast<Integer>(downcast<Dict>(resParams->get(4)) ->i());
->get("faultCode"))->i()); CPPUNIT_ASSERT_EQUAL(
(int64_t)1,
downcast<Integer>(downcast<Dict>(resParams->get(4))->get("faultCode"))
->i());
CPPUNIT_ASSERT(downcast<List>(resParams->get(5))); CPPUNIT_ASSERT(downcast<List>(resParams->get(5)));
CPPUNIT_ASSERT(downcast<List>(resParams->get(6))); CPPUNIT_ASSERT(downcast<List>(resParams->get(6)));
} }

View File

@ -342,32 +342,32 @@ static struct pbkdf2 {
"salt", "salt",
4, 4,
1, 1,
{0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9, 0xb5, 0x24, {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9,
0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6}, 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
20}, 20},
{"password", {"password",
8, 8,
"salt", "salt",
4, 4,
1, 1,
{0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9, 0xb5, 0x24, {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9,
0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6}, 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
0}, 0},
{"password", {"password",
8, 8,
"salt", "salt",
4, 4,
2, 2,
{0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c, 0xcd, 0x1e, 0xd9, 0x2a, {0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c, 0xcd, 0x1e,
0xce, 0x1d, 0x41, 0xf0, 0xd8, 0xde, 0x89, 0x57}, 0xd9, 0x2a, 0xce, 0x1d, 0x41, 0xf0, 0xd8, 0xde, 0x89, 0x57},
20}, 20},
{"password", {"password",
8, 8,
"salt", "salt",
4, 4,
4096, 4096,
{0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a, 0xbe, 0xad, 0x49, 0xd9, {0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a, 0xbe, 0xad,
0x26, 0xf7, 0x21, 0xd0, 0x65, 0xa4, 0x29, 0xc1}, 0x49, 0xd9, 0x26, 0xf7, 0x21, 0xd0, 0x65, 0xa4, 0x29, 0xc1},
20}, 20},
/* Disabled due to #236 /* Disabled due to #236
{ {
@ -385,9 +385,9 @@ static struct pbkdf2 {
"saltSALTsaltSALTsaltSALTsaltSALTsalt", "saltSALTsaltSALTsaltSALTsaltSALTsalt",
36, 36,
4096, 4096,
{0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b, 0x80, 0xc8, 0xd8, 0x36, {0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b, 0x80,
0x62, 0xc0, 0xe4, 0x4a, 0x8b, 0x29, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70, 0xc8, 0xd8, 0x36, 0x62, 0xc0, 0xe4, 0x4a, 0x8b, 0x29,
0x38}, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70, 0x38},
25, 25,
}, },
{"pass\0word", {"pass\0word",

View File

@ -670,8 +670,9 @@ void UtilTest2::testGenerateRandomData()
double mean = sum / counts.size(); double mean = sum / counts.size();
vector<double> diff(counts.size()); vector<double> diff(counts.size());
transform(counts.begin(), counts.end(), diff.begin(), transform(counts.begin(), counts.end(), diff.begin(),
[&](const decltype(counts)::value_type& elem) [&](const decltype(counts)::value_type& elem) -> double {
-> double { return (double)elem.second - mean; }); return (double)elem.second - mean;
});
double sq_sum = inner_product(diff.begin(), diff.end(), diff.begin(), 0.0); double sq_sum = inner_product(diff.begin(), diff.end(), diff.begin(), 0.0);
double stddev = sqrt(sq_sum / counts.size()); double stddev = sqrt(sq_sum / counts.size());
cout << "stddev: " << fixed << stddev << endl; cout << "stddev: " << fixed << stddev << endl;

View File

@ -177,13 +177,13 @@ void ValueBaseJsonParserTest::testParseUpdate()
const Integer* i = downcast<Integer>(list->get(0)); const Integer* i = downcast<Integer>(list->get(0));
CPPUNIT_ASSERT_EQUAL((Integer::ValueType)0, i->i()); CPPUNIT_ASSERT_EQUAL((Integer::ValueType)0, i->i());
const Integer* i1 = downcast<Integer>(list->get(1)); const Integer* i1 = downcast<Integer>(list->get(1));
CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i1->i()); CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i1->i());
const Integer* i2 = downcast<Integer>(list->get(2)); const Integer* i2 = downcast<Integer>(list->get(2));
CPPUNIT_ASSERT_EQUAL((Integer::ValueType)1, i2->i()); CPPUNIT_ASSERT_EQUAL((Integer::ValueType)1, i2->i());
const Integer* i3 = downcast<Integer>(list->get(3)); const Integer* i3 = downcast<Integer>(list->get(3));
CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i3->i()); CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i3->i());
const Integer* i4 = downcast<Integer>(list->get(4)); const Integer* i4 = downcast<Integer>(list->get(4));
CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i4->i()); CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i4->i());
} }
{ {
// escape chars: ", \, /, \b, \f, \n, \r, \t // escape chars: ", \, /, \b, \f, \n, \r, \t