From e0a827ff98e665a118e2001dfe29b14847a33070 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Date: Sat, 9 Jun 2018 16:23:36 +0900 Subject: [PATCH] Enable IndentPPDirectives --- .clang-format | 2 +- src/ARC4Encryptor.h | 8 +- src/AbstractCommand.cc | 4 +- src/AbstractDiskWriter.cc | 40 +++--- src/AbstractSingleDiskAdaptor.cc | 2 +- src/AdaptiveFileAllocationIterator.cc | 2 +- src/Adler32MessageDigestImpl.h | 5 +- src/AppleTLSContext.cc | 14 +- src/AppleTLSSession.cc | 2 +- src/ConsoleStatCalc.cc | 18 +-- src/Context.cc | 16 +-- src/CookieStorage.cc | 2 +- src/DHKeyExchange.h | 8 +- src/DHTEntryPointNameResolveCommand.cc | 2 +- src/DefaultBtProgressInfoFile.cc | 6 +- src/DefaultPieceStorage.cc | 6 +- src/DownloadCommand.cc | 2 +- src/DownloadEngine.cc | 4 +- src/DownloadEngine.h | 2 +- src/DownloadEngineFactory.cc | 10 +- src/EpollEventPoll.h | 2 +- src/Event.h | 2 +- src/FeatureConfig.cc | 54 ++++---- src/File.cc | 2 +- src/FtpConnection.cc | 16 +-- src/FtpInitiateConnectionCommand.cc | 4 +- src/FtpTunnelResponseCommand.cc | 2 +- src/HttpResponse.cc | 2 +- src/HttpResponseCommand.cc | 2 +- src/HttpServer.cc | 2 +- src/HttpServerBodyCommand.cc | 4 +- src/HttpServerCommand.cc | 2 +- src/KqueueEventPoll.cc | 4 +- src/KqueueEventPoll.h | 2 +- src/LibgnutlsTLSContext.cc | 4 +- src/LibgnutlsTLSSession.cc | 6 +- src/LibsslTLSContext.cc | 6 +- src/LibuvEventPoll.cc | 8 +- src/LibuvEventPoll.h | 2 +- src/Lock.h | 4 +- src/LogFactory.cc | 2 +- src/Metalink2RequestGroup.cc | 4 +- src/MetalinkParserController.cc | 2 +- src/MultiFileAllocationIterator.cc | 2 +- src/MultiUrlRequestInfo.cc | 14 +- src/NameResolveCommand.cc | 2 +- src/OptionHandlerFactory.cc | 12 +- src/Platform.cc | 14 +- src/PollEventPoll.h | 2 +- src/PortEventPoll.h | 4 +- src/ProtocolDetector.cc | 2 +- src/RequestGroup.cc | 62 ++++----- src/RequestGroupMan.cc | 2 +- src/RpcMethodImpl.cc | 12 +- src/RpcResponse.cc | 2 +- src/SelectEventPoll.cc | 2 +- src/SelectEventPoll.h | 2 +- src/SessionSerializer.cc | 2 +- src/SimpleRandomizer.cc | 12 +- src/SimpleRandomizer.h | 2 +- src/SocketCore.cc | 74 +++++------ src/Sqlite3CookieParser.cc | 2 +- src/UriListParser.cc | 2 +- src/WatchProcessCommand.cc | 6 +- src/WinTLSContext.cc | 10 +- src/WinTLSSession.cc | 8 +- src/XmlParser.h | 4 +- src/a2io.h | 174 ++++++++++++------------- src/a2netcompat.h | 68 +++++----- src/a2time.h | 14 +- src/alloca.c | 126 +++++++++--------- src/aria2api.cc | 2 +- src/asctime_r.c | 4 +- src/common.h | 56 ++++---- src/console.cc | 4 +- src/crypto_endian.h | 32 ++--- src/crypto_hash.cc | 12 +- src/download_handlers.cc | 8 +- src/download_helper.cc | 6 +- src/gai_strerror.c | 20 +-- src/gai_strerror.h | 8 +- src/getaddrinfo.c | 62 ++++----- src/getaddrinfo.h | 136 +++++++++---------- src/gettimeofday.c | 6 +- src/gettimeofday.h | 4 +- src/libgen.c | 4 +- src/libssl_compat.h | 4 +- src/localtime_r.c | 4 +- src/main.cc | 2 +- src/option_processing.cc | 8 +- src/strptime.c | 10 +- src/timegm.h | 2 +- src/util.cc | 34 ++--- src/util.h | 8 +- test/Aria2ApiTest.cc | 6 +- test/DefaultBtProgressInfoFileTest.cc | 22 ++-- test/DownloadHelperTest.cc | 14 +- test/Metalink2RequestGroupTest.cc | 6 +- test/MockPeerStorage.h | 8 +- test/RpcHelperTest.cc | 2 +- test/RpcMethodTest.cc | 6 +- 101 files changed, 716 insertions(+), 715 deletions(-) diff --git a/.clang-format b/.clang-format index 46fae476..fcb28b7e 100644 --- a/.clang-format +++ b/.clang-format @@ -68,7 +68,7 @@ IncludeCategories: Priority: 1 IncludeIsMainRegex: '$' IndentCaseLabels: false -IndentPPDirectives: None +IndentPPDirectives: AfterHash IndentWidth: 2 IndentWrappedFunctionNames: false JavaScriptQuotes: Leave diff --git a/src/ARC4Encryptor.h b/src/ARC4Encryptor.h index 9100de22..46854b5e 100644 --- a/src/ARC4Encryptor.h +++ b/src/ARC4Encryptor.h @@ -38,13 +38,13 @@ #include "common.h" #ifdef USE_INTERNAL_ARC4 -#include "InternalARC4Encryptor.h" +# include "InternalARC4Encryptor.h" #elif HAVE_LIBNETTLE -#include "LibnettleARC4Encryptor.h" +# include "LibnettleARC4Encryptor.h" #elif HAVE_LIBGCRYPT -#include "LibgcryptARC4Encryptor.h" +# include "LibgcryptARC4Encryptor.h" #elif HAVE_OPENSSL -#include "LibsslARC4Encryptor.h" +# include "LibsslARC4Encryptor.h" #endif #endif // D_ARC4_ENCRYPTOR_H diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index bf307b75..1502d570 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -68,8 +68,8 @@ #include "SocketRecvBuffer.h" #include "ChecksumCheckIntegrityEntry.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" -#include "AsyncNameResolverMan.h" +# include "AsyncNameResolver.h" +# include "AsyncNameResolverMan.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index a1eba628..ff4f8856 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -36,7 +36,7 @@ #include <unistd.h> #ifdef HAVE_MMAP -#include <sys/mman.h> +# include <sys/mman.h> #endif // HAVE_MMAP #include <fcntl.h> @@ -133,17 +133,17 @@ void AbstractDiskWriter::closeFile() #if defined(HAVE_MMAP) || defined(__MINGW32__) if (mapaddr_) { int errNum = 0; -#ifdef __MINGW32__ +# ifdef __MINGW32__ if (!UnmapViewOfFile(mapaddr_)) { errNum = GetLastError(); } CloseHandle(mapView_); mapView_ = INVALID_HANDLE_VALUE; -#else // !__MINGW32__ +# else // !__MINGW32__ if (munmap(mapaddr_, maplen_) == -1) { errNum = errno; } -#endif // !__MINGW32__ +# endif // !__MINGW32__ if (errNum != 0) { int errNum = fileError(); A2_LOG_ERROR(fmt("Unmapping file %s failed: %s", filename_.c_str(), @@ -224,13 +224,13 @@ int openFileWithFlags(const std::string& filename, int flags, errCode); } util::make_fd_cloexec(fd); -#if defined(__APPLE__) && defined(__MACH__) +# if defined(__APPLE__) && defined(__MACH__) // This may reduce memory consumption on Mac OS X. fcntl(fd, F_NOCACHE, 1); -#endif // __APPLE__ && __MACH__ +# endif // __APPLE__ && __MACH__ return fd; } -#endif // !__MINGW32__ +#endif // !__MINGW32__ } // namespace void AbstractDiskWriter::openExistingFile(int64_t totalLength) @@ -345,17 +345,17 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset) if (mapaddr_) { if (static_cast<int64_t>(len + offset) > maplen_) { int errNum = 0; -#ifdef __MINGW32__ +# ifdef __MINGW32__ if (!UnmapViewOfFile(mapaddr_)) { errNum = GetLastError(); } CloseHandle(mapView_); mapView_ = INVALID_HANDLE_VALUE; -#else // !__MINGW32__ +# else // !__MINGW32__ if (munmap(mapaddr_, maplen_) == -1) { errNum = errno; } -#endif // !__MINGW32__ +# endif // !__MINGW32__ if (errNum != 0) { A2_LOG_ERROR(fmt("Unmapping file %s failed: %s", filename_.c_str(), fileStrerror(errNum).c_str())); @@ -385,7 +385,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset) int errNum = 0; if (static_cast<int64_t>(len + offset) <= filesize) { -#ifdef __MINGW32__ +# ifdef __MINGW32__ mapView_ = CreateFileMapping(fd_, 0, PAGE_READWRITE, filesize >> 32, filesize & 0xffffffffu, 0); if (mapView_) { @@ -400,7 +400,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset) else { errNum = GetLastError(); } -#else // !__MINGW32__ +# else // !__MINGW32__ auto pa = mmap(nullptr, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0); @@ -410,7 +410,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset) else { mapaddr_ = reinterpret_cast<unsigned char*>(pa); } -#endif // !__MINGW32__ +# endif // !__MINGW32__ if (mapaddr_) { A2_LOG_DEBUG(fmt("Mapping file %s succeeded, length=%" PRId64 "", filename_.c_str(), static_cast<uint64_t>(filesize))); @@ -517,7 +517,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) return; } #ifdef HAVE_SOME_FALLOCATE -#ifdef __MINGW32__ +# ifdef __MINGW32__ truncate(offset + length); if (!SetFileValidData(fd_, offset + length)) { auto errNum = fileError(); @@ -528,7 +528,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) "(see --file-allocation).", fileStrerror(errNum).c_str())); } -#elif defined(__APPLE__) && defined(__MACH__) +# elif defined(__APPLE__) && defined(__MACH__) const auto toalloc = offset + length - size(); fstore_t fstore = {F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, 0, toalloc, 0}; @@ -546,7 +546,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) } // This forces the allocation on disk. ftruncate(fd_, offset + length); -#elif HAVE_FALLOCATE +# elif HAVE_FALLOCATE // For linux, we use fallocate to detect file system supports // fallocate or not. int r; @@ -560,7 +560,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) isDiskFullError(errNum) ? error_code::NOT_ENOUGH_DISK_SPACE : error_code::FILE_IO_ERROR); } -#elif HAVE_POSIX_FALLOCATE +# elif HAVE_POSIX_FALLOCATE int r = posix_fallocate(fd_, offset, length); if (r != 0) { throw DL_ABORT_EX3( @@ -569,9 +569,9 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) isDiskFullError(r) ? error_code::NOT_ENOUGH_DISK_SPACE : error_code::FILE_IO_ERROR); } -#else -#error "no *_fallocate function available." -#endif +# else +# error "no *_fallocate function available." +# endif #endif // HAVE_SOME_FALLOCATE } diff --git a/src/AbstractSingleDiskAdaptor.cc b/src/AbstractSingleDiskAdaptor.cc index 7210b2ce..54ec783e 100644 --- a/src/AbstractSingleDiskAdaptor.cc +++ b/src/AbstractSingleDiskAdaptor.cc @@ -41,7 +41,7 @@ #include "WrDiskCacheEntry.h" #include "LogFactory.h" #ifdef HAVE_SOME_FALLOCATE -#include "FallocFileAllocationIterator.h" +# include "FallocFileAllocationIterator.h" #endif // HAVE_SOME_FALLOCATE namespace aria2 { diff --git a/src/AdaptiveFileAllocationIterator.cc b/src/AdaptiveFileAllocationIterator.cc index c24f3b5b..0f864728 100644 --- a/src/AdaptiveFileAllocationIterator.cc +++ b/src/AdaptiveFileAllocationIterator.cc @@ -40,7 +40,7 @@ #include "Logger.h" #include "a2functional.h" #ifdef HAVE_FALLOCATE -#include "FallocFileAllocationIterator.h" +# include "FallocFileAllocationIterator.h" #endif // HAVE_FALLOCATE namespace aria2 { diff --git a/src/Adler32MessageDigestImpl.h b/src/Adler32MessageDigestImpl.h index 29b81bc8..178e3a27 100644 --- a/src/Adler32MessageDigestImpl.h +++ b/src/Adler32MessageDigestImpl.h @@ -41,7 +41,8 @@ namespace aria2 { #ifdef HAVE_ZLIB -#define ADLER32_MESSAGE_DIGEST {"adler32", make_hi<Adler32MessageDigestImpl>()}, +# define ADLER32_MESSAGE_DIGEST \ + {"adler32", make_hi<Adler32MessageDigestImpl>()}, class Adler32MessageDigestImpl : public MessageDigestImpl { public: @@ -58,7 +59,7 @@ private: #else // !HAVE_ZLIB -#define ADLER32_MESSAGE_DIGEST +# define ADLER32_MESSAGE_DIGEST #endif // !HAVE_ZLIB diff --git a/src/AppleTLSContext.cc b/src/AppleTLSContext.cc index 808ad570..82bfe84c 100644 --- a/src/AppleTLSContext.cc +++ b/src/AppleTLSContext.cc @@ -39,7 +39,7 @@ #include <sstream> #ifdef __MAC_10_6 -#include <Security/SecImportExport.h> +# include <Security/SecImportExport.h> #endif #include "LogFactory.h" @@ -55,10 +55,10 @@ using namespace aria2; #if defined(__MAC_10_6) -#if defined(__MAC_10_7) +# if defined(__MAC_10_7) static const void* query_keys[] = {kSecClass, kSecReturnRef, kSecMatchPolicy, kSecMatchLimit}; -#endif // defined(__MAC_10_7) +# endif // defined(__MAC_10_7) template <typename T> class CFRef { T ref_; @@ -278,7 +278,7 @@ bool AppleTLSContext::tryAsFingerprint(const std::string& fingerprint) return false; #else // defined(__MAC_10_7) -#if defined(__MAC_10_6) +# if defined(__MAC_10_6) CFRef<SecIdentitySearchRef> search; SecIdentitySearchRef raw_search; @@ -304,14 +304,14 @@ bool AppleTLSContext::tryAsFingerprint(const std::string& fingerprint) fmt("Failed to lookup %s in your KeyChain", fingerprint.c_str())); return false; -#else // defined(__MAC_10_6) +# else // defined(__MAC_10_6) A2_LOG_ERROR("Your system does not support creditials via fingerprints; " "Upgrade to OSX 10.6 or later"); return false; -#endif // defined(__MAC_10_6) -#endif // defined(__MAC_10_7) +# endif // defined(__MAC_10_6) +#endif // defined(__MAC_10_7) } bool AppleTLSContext::tryAsPKCS12(const std::string& certfile) diff --git a/src/AppleTLSSession.cc b/src/AppleTLSSession.cc index 868ab087..ca555e94 100644 --- a/src/AppleTLSSession.cc +++ b/src/AppleTLSSession.cc @@ -48,7 +48,7 @@ #define paramErr -50 #ifndef errSSLServerAuthCompleted -#define errSSLServerAuthCompleted -9841 +# define errSSLServerAuthCompleted -9841 #endif namespace { diff --git a/src/ConsoleStatCalc.cc b/src/ConsoleStatCalc.cc index 14d35d87..a28a4a54 100644 --- a/src/ConsoleStatCalc.cc +++ b/src/ConsoleStatCalc.cc @@ -35,10 +35,10 @@ #include "ConsoleStatCalc.h" #ifdef HAVE_TERMIOS_H -#include <termios.h> +# include <termios.h> #endif // HAVE_TERMIOS_H #ifdef HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> +# include <sys/ioctl.h> #endif // HAVE_SYS_IOCTL_H #include <unistd.h> @@ -66,9 +66,9 @@ #include "Option.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" -#include "PeerStorage.h" -#include "BtRegistry.h" +# include "bittorrent_helper.h" +# include "PeerStorage.h" +# include "BtRegistry.h" #endif // ENABLE_BITTORRENT namespace aria2 { @@ -302,19 +302,19 @@ void ConsoleStatCalc::calculateStat(const DownloadEngine* e) if (isTTY_) { #ifndef __MINGW32__ -#ifdef HAVE_TERMIOS_H +# ifdef HAVE_TERMIOS_H struct winsize size; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) { cols = std::max(0, (int)size.ws_col - 1); } -#endif // HAVE_TERMIOS_H -#else // __MINGW32__ +# endif // HAVE_TERMIOS_H +#else // __MINGW32__ CONSOLE_SCREEN_BUFFER_INFO info; if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE), &info)) { cols = std::max(0, info.dwSize.X - 2); } -#endif // !__MINGW32__ +#endif // !__MINGW32__ std::string line(cols, ' '); global::cout()->printf("\r%s\r", line.c_str()); } diff --git a/src/Context.cc b/src/Context.cc index c6603261..d12775bb 100644 --- a/src/Context.cc +++ b/src/Context.cc @@ -38,7 +38,7 @@ #include <getopt.h> #ifdef HAVE_SYS_RESOURCE_H -#include <sys/resource.h> +# include <sys/resource.h> #endif // HAVE_SYS_RESOURCE_H #include <numeric> @@ -72,11 +72,11 @@ #include "UriListParser.h" #include "message_digest_helper.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK -#include "metalink_helper.h" -#include "MetalinkEntry.h" +# include "metalink_helper.h" +# include "MetalinkEntry.h" #endif // ENABLE_METALINK extern char* optarg; @@ -121,18 +121,18 @@ void showFiles(const std::vector<std::string>& uris, printf(MSG_SHOW_FILES, (uri).c_str()); printf("\n"); try { -#ifdef ENABLE_BITTORRENT +# ifdef ENABLE_BITTORRENT if (dt.guessTorrentFile(uri)) { showTorrentFile(uri); } else -#endif // ENABLE_BITTORRENT -#ifdef ENABLE_METALINK +# endif // ENABLE_BITTORRENT +# ifdef ENABLE_METALINK if (dt.guessMetalinkFile(uri)) { showMetalinkFile(uri, op); } else -#endif // ENABLE_METALINK +# endif // ENABLE_METALINK { printf("%s\n\n", MSG_NOT_TORRENT_METALINK); } diff --git a/src/CookieStorage.cc b/src/CookieStorage.cc index 383bcb35..56db33ed 100644 --- a/src/CookieStorage.cc +++ b/src/CookieStorage.cc @@ -51,7 +51,7 @@ #include "cookie_helper.h" #include "BufferedFile.h" #ifdef HAVE_SQLITE3 -#include "Sqlite3CookieParserImpl.h" +# include "Sqlite3CookieParserImpl.h" #endif // HAVE_SQLITE3 namespace aria2 { diff --git a/src/DHKeyExchange.h b/src/DHKeyExchange.h index 48876a85..ffd64627 100644 --- a/src/DHKeyExchange.h +++ b/src/DHKeyExchange.h @@ -37,13 +37,13 @@ #include "common.h" #ifdef USE_INTERNAL_BIGNUM -#include "InternalDHKeyExchange.h" +# include "InternalDHKeyExchange.h" #elif HAVE_LIBGMP -#include "LibgmpDHKeyExchange.h" +# include "LibgmpDHKeyExchange.h" #elif HAVE_LIBGCRYPT -#include "LibgcryptDHKeyExchange.h" +# include "LibgcryptDHKeyExchange.h" #elif HAVE_OPENSSL -#include "LibsslDHKeyExchange.h" +# include "LibsslDHKeyExchange.h" #endif // HAVE_OPENSSL #endif // D_DH_KEY_EXCHANGE_H diff --git a/src/DHTEntryPointNameResolveCommand.cc b/src/DHTEntryPointNameResolveCommand.cc index 42731e10..35ceee0c 100644 --- a/src/DHTEntryPointNameResolveCommand.cc +++ b/src/DHTEntryPointNameResolveCommand.cc @@ -51,7 +51,7 @@ #include "fmt.h" #include "SocketCore.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolverMan.h" +# include "AsyncNameResolverMan.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index d76285c5..7a5da1c3 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -57,9 +57,9 @@ #include "BufferedFile.h" #include "SHA1IOFile.h" #ifdef ENABLE_BITTORRENT -#include "PeerStorage.h" -#include "BtRuntime.h" -#include "bittorrent_helper.h" +# include "PeerStorage.h" +# include "BtRuntime.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 { diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index 456058a5..ceff957b 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -70,7 +70,7 @@ #include "RequestGroup.h" #include "SimpleRandomizer.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 { @@ -485,7 +485,7 @@ void DefaultPieceStorage::completePiece(const std::shared_ptr<Piece>& piece) #ifdef ENABLE_BITTORRENT if (downloadContext_->hasAttribute(CTX_ATTR_BT)) { if (!bittorrent::getTorrentAttrs(downloadContext_)->metadata.empty()) { -#ifdef __MINGW32__ +# ifdef __MINGW32__ // On Windows, if aria2 opens files with GENERIC_WRITE access // right, some programs cannot open them aria2 is seeding. To // avoid this situation, re-open the files with read-only @@ -495,7 +495,7 @@ void DefaultPieceStorage::completePiece(const std::shared_ptr<Piece>& piece) diskAdaptor_->closeFile(); diskAdaptor_->enableReadOnly(); diskAdaptor_->openFile(); -#endif // __MINGW32__ +# endif // __MINGW32__ auto group = downloadContext_->getOwnerRequestGroup(); util::executeHookByOptName(group, option_, diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index 91042ef1..2db41e46 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -68,7 +68,7 @@ #include "MessageDigest.h" #include "message_digest_helper.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 { diff --git a/src/DownloadEngine.cc b/src/DownloadEngine.cc index a79702d0..2037f66f 100644 --- a/src/DownloadEngine.cc +++ b/src/DownloadEngine.cc @@ -68,10 +68,10 @@ #include "fmt.h" #include "wallclock.h" #ifdef ENABLE_BITTORRENT -#include "BtRegistry.h" +# include "BtRegistry.h" #endif // ENABLE_BITTORRENT #ifdef ENABLE_WEBSOCKET -#include "WebSocketSessionMan.h" +# include "WebSocketSessionMan.h" #endif // ENABLE_WEBSOCKET #include "Option.h" #include "util_security.h" diff --git a/src/DownloadEngine.h b/src/DownloadEngine.h index b6228a7f..b544cfc6 100644 --- a/src/DownloadEngine.h +++ b/src/DownloadEngine.h @@ -51,7 +51,7 @@ #include "CheckIntegrityMan.h" #include "DNSCache.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc index 3c5bfe58..64c5c76b 100644 --- a/src/DownloadEngineFactory.cc +++ b/src/DownloadEngineFactory.cc @@ -59,19 +59,19 @@ #include "array_fun.h" #include "EvictSocketPoolCommand.h" #ifdef HAVE_LIBUV -#include "LibuvEventPoll.h" +# include "LibuvEventPoll.h" #endif // HAVE_LIBUV #ifdef HAVE_EPOLL -#include "EpollEventPoll.h" +# include "EpollEventPoll.h" #endif // HAVE_EPOLL #ifdef HAVE_PORT_ASSOCIATE -#include "PortEventPoll.h" +# include "PortEventPoll.h" #endif // HAVE_PORT_ASSOCIATE #ifdef HAVE_KQUEUE -#include "KqueueEventPoll.h" +# include "KqueueEventPoll.h" #endif // HAVE_KQUEUE #ifdef HAVE_POLL -#include "PollEventPoll.h" +# include "PollEventPoll.h" #endif // HAVE_POLL #include "SelectEventPoll.h" #include "DlAbortEx.h" diff --git a/src/EpollEventPoll.h b/src/EpollEventPoll.h index d14afe82..ddaa80c4 100644 --- a/src/EpollEventPoll.h +++ b/src/EpollEventPoll.h @@ -44,7 +44,7 @@ #include "Event.h" #include "a2functional.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/Event.h b/src/Event.h index 39037912..7d6985eb 100644 --- a/src/Event.h +++ b/src/Event.h @@ -45,7 +45,7 @@ #include "a2netcompat.h" #include "Command.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc index ffc608a3..2b43c8b1 100644 --- a/src/FeatureConfig.cc +++ b/src/FeatureConfig.cc @@ -38,37 +38,37 @@ #include <cstring> #ifdef HAVE_ZLIB -#include <zlib.h> +# include <zlib.h> #endif // HAVE_ZLIB #ifdef HAVE_LIBXML2 -#include <libxml/xmlversion.h> +# include <libxml/xmlversion.h> #endif // HAVE_LIBXML2 #ifdef HAVE_LIBEXPAT -#include <expat.h> +# include <expat.h> #endif // HAVE_LIBEXPAT #ifdef HAVE_SQLITE3 -#include <sqlite3.h> +# include <sqlite3.h> #endif // HAVE_SQLITE3 #ifdef HAVE_LIBGNUTLS -#include <gnutls/gnutls.h> +# include <gnutls/gnutls.h> #endif // HAVE_LIBGNUTLS #ifdef HAVE_OPENSSL -#include <openssl/opensslv.h> +# include <openssl/opensslv.h> #endif // HAVE_OPENSSL #ifdef HAVE_LIBGMP -#include <gmp.h> +# include <gmp.h> #endif // HAVE_LIBGMP #ifdef HAVE_LIBGCRYPT -#include <gcrypt.h> +# include <gcrypt.h> #endif // HAVE_LIBGCRYPT #ifdef HAVE_LIBCARES -#include <ares.h> +# include <ares.h> #endif // HAVE_LIBCARES #ifdef HAVE_SYS_UTSNAME_H -#include <sys/utsname.h> +# include <sys/utsname.h> #endif // HAVE_SYS_UTSNAME_H #ifdef HAVE_LIBSSH2 -#include <libssh2.h> +# include <libssh2.h> #endif // HAVE_LIBSSH2 #include "util.h" @@ -252,11 +252,11 @@ std::string usedCompilerAndPlatform() std::stringstream rv; #if defined(__clang_version__) -#ifdef __apple_build_version__ +# ifdef __apple_build_version__ rv << "Apple LLVM "; -#else // !__apple_build_version__ +# else // !__apple_build_version__ rv << "clang "; -#endif // !__apple_build_version__ +# endif // !__apple_build_version__ rv << __clang_version__; #elif defined(__INTEL_COMPILER) @@ -266,23 +266,23 @@ std::string usedCompilerAndPlatform() #elif defined(__MINGW64_VERSION_STR) rv << "mingw-w64 " << __MINGW64_VERSION_STR; -#ifdef __MINGW64_VERSION_STATE +# ifdef __MINGW64_VERSION_STATE rv << " (" << __MINGW64_VERSION_STATE << ")"; -#endif // __MINGW64_VERSION_STATE +# endif // __MINGW64_VERSION_STATE rv << " / gcc " << __VERSION__; #elif defined(__GNUG__) -#ifdef __MINGW32__ +# ifdef __MINGW32__ rv << "mingw "; -#ifdef __MINGW32_MAJOR_VERSION +# ifdef __MINGW32_MAJOR_VERSION rv << (int)__MINGW32_MAJOR_VERSION; -#endif // __MINGW32_MAJOR_VERSION -#ifdef __MINGW32_MINOR_VERSION +# endif // __MINGW32_MAJOR_VERSION +# ifdef __MINGW32_MINOR_VERSION rv << "." << (int)__MINGW32_MINOR_VERSION; -#endif // __MINGW32_MINOR_VERSION +# endif // __MINGW32_MINOR_VERSION rv << " / "; -#endif // __MINGW32__ +# endif // __MINGW32__ rv << "gcc " << __VERSION__; #else // !defined(__GNUG__) @@ -348,13 +348,13 @@ std::string getOperatingSystemInfo() if (ovi.szCSDVersion[0]) { rv << " (" << ovi.szCSDVersion << ")"; } -#ifdef _WIN64 +# ifdef _WIN64 rv << " (x86_64)"; -#endif // _WIN64 +# endif // _WIN64 rv << " (" << ovi.dwMajorVersion << "." << ovi.dwMinorVersion << ")"; return rv.str(); #else //! _WIN32 -#ifdef HAVE_SYS_UTSNAME_H +# ifdef HAVE_SYS_UTSNAME_H struct utsname name; if (!uname(&name)) { if (!strstr(name.version, name.sysname) || @@ -367,9 +367,9 @@ std::string getOperatingSystemInfo() } return name.version; } -#endif // HAVE_SYS_UTSNAME_H +# endif // HAVE_SYS_UTSNAME_H return "Unknown system"; -#endif // !_WIN32 +#endif // !_WIN32 } } // namespace aria2 diff --git a/src/File.cc b/src/File.cc index 345c31f9..a98dca61 100644 --- a/src/File.cc +++ b/src/File.cc @@ -37,7 +37,7 @@ #include <stdlib.h> #include <sys/types.h> #ifdef HAVE_UTIME_H -#include <utime.h> +# include <utime.h> #endif // HAVE_UTIME_H #include <unistd.h> diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 415b8ebd..0893d294 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -369,16 +369,16 @@ int FtpConnection::receiveResponse() } #ifdef __MINGW32__ -#define LONGLONG_PRINTF "%I64d" -#define ULONGLONG_PRINTF "%I64u" -#define LONGLONG_SCANF "%I64d" -#define ULONGLONG_SCANF "%I64u" +# define LONGLONG_PRINTF "%I64d" +# define ULONGLONG_PRINTF "%I64u" +# define LONGLONG_SCANF "%I64d" +# define ULONGLONG_SCANF "%I64u" #else -#define LONGLONG_PRINTF "%" PRId64 "" -#define ULONGLONG_PRINTF "%llu" -#define LONGLONG_SCANF "%Ld" +# define LONGLONG_PRINTF "%" PRId64 "" +# define ULONGLONG_PRINTF "%llu" +# define LONGLONG_SCANF "%Ld" // Mac OSX uses "%llu" for 64bits integer. -#define ULONGLONG_SCANF "%Lu" +# define ULONGLONG_SCANF "%Lu" #endif // __MINGW32__ int FtpConnection::receiveSizeResponse(int64_t& size) diff --git a/src/FtpInitiateConnectionCommand.cc b/src/FtpInitiateConnectionCommand.cc index 604c9c0f..b41655f8 100644 --- a/src/FtpInitiateConnectionCommand.cc +++ b/src/FtpInitiateConnectionCommand.cc @@ -61,8 +61,8 @@ #include "FtpTunnelRequestConnectChain.h" #include "HttpRequestConnectChain.h" #ifdef HAVE_LIBSSH2 -#include "SftpNegotiationConnectChain.h" -#include "SftpNegotiationCommand.h" +# include "SftpNegotiationConnectChain.h" +# include "SftpNegotiationCommand.h" #endif // HAVE_LIBSSH2 namespace aria2 { diff --git a/src/FtpTunnelResponseCommand.cc b/src/FtpTunnelResponseCommand.cc index b9c34896..1e550ce5 100644 --- a/src/FtpTunnelResponseCommand.cc +++ b/src/FtpTunnelResponseCommand.cc @@ -41,7 +41,7 @@ #include "SocketCore.h" #include "SocketRecvBuffer.h" #ifdef HAVE_LIBSSH2 -#include "SftpNegotiationCommand.h" +# include "SftpNegotiationCommand.h" #endif // HAVE_LIBSSH2 namespace aria2 { diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index 3e140c4c..500cd64e 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -61,7 +61,7 @@ #include "array_fun.h" #include "MessageDigest.h" #ifdef HAVE_ZLIB -#include "GZipDecodingStreamFilter.h" +# include "GZipDecodingStreamFilter.h" #endif // HAVE_ZLIB namespace aria2 { diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index 6009dc2f..6e2a01d4 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -78,7 +78,7 @@ #include "Checksum.h" #include "ChecksumCheckIntegrityEntry.h" #ifdef HAVE_ZLIB -#include "GZipDecodingStreamFilter.h" +# include "GZipDecodingStreamFilter.h" #endif // HAVE_ZLIB namespace aria2 { diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 1496ee89..dc81b0c9 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -53,7 +53,7 @@ #include "array_fun.h" #include "JsonDiskWriter.h" #ifdef ENABLE_XML_RPC -#include "XmlRpcDiskWriter.h" +# include "XmlRpcDiskWriter.h" #endif // ENABLE_XML_RPC namespace aria2 { diff --git a/src/HttpServerBodyCommand.cc b/src/HttpServerBodyCommand.cc index 3665181e..e9e7b92a 100644 --- a/src/HttpServerBodyCommand.cc +++ b/src/HttpServerBodyCommand.cc @@ -61,8 +61,8 @@ #include "JsonDiskWriter.h" #include "ValueBaseJsonParser.h" #ifdef ENABLE_XML_RPC -#include "XmlRpcRequestParserStateMachine.h" -#include "XmlRpcDiskWriter.h" +# include "XmlRpcRequestParserStateMachine.h" +# include "XmlRpcDiskWriter.h" #endif // ENABLE_XML_RPC namespace aria2 { diff --git a/src/HttpServerCommand.cc b/src/HttpServerCommand.cc index f39d2fab..68293b39 100644 --- a/src/HttpServerCommand.cc +++ b/src/HttpServerCommand.cc @@ -54,7 +54,7 @@ #include "MessageDigest.h" #include "message_digest_helper.h" #ifdef ENABLE_WEBSOCKET -#include "WebSocketResponseCommand.h" +# include "WebSocketResponseCommand.h" #endif // ENABLE_WEBSOCKET namespace aria2 { diff --git a/src/KqueueEventPoll.cc b/src/KqueueEventPoll.cc index dc131fef..ef96478e 100644 --- a/src/KqueueEventPoll.cc +++ b/src/KqueueEventPoll.cc @@ -46,9 +46,9 @@ #include "fmt.h" #ifdef KEVENT_UDATA_INTPTR_T -#define PTR_TO_UDATA(X) (reinterpret_cast<intptr_t>(X)) +# define PTR_TO_UDATA(X) (reinterpret_cast<intptr_t>(X)) #else // !KEVENT_UDATA_INTPTR_T -#define PTR_TO_UDATA(X) (X) +# define PTR_TO_UDATA(X) (X) #endif // !KEVENT_UDATA_INTPTR_T namespace aria2 { diff --git a/src/KqueueEventPoll.h b/src/KqueueEventPoll.h index d1ef45ab..4225411e 100644 --- a/src/KqueueEventPoll.h +++ b/src/KqueueEventPoll.h @@ -46,7 +46,7 @@ #include "Event.h" #include "a2functional.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/LibgnutlsTLSContext.cc b/src/LibgnutlsTLSContext.cc index 7a6cc98c..8494ed75 100644 --- a/src/LibgnutlsTLSContext.cc +++ b/src/LibgnutlsTLSContext.cc @@ -37,8 +37,8 @@ #include <sstream> #ifdef HAVE_LIBGNUTLS -#include <gnutls/x509.h> -#include <gnutls/pkcs12.h> +# include <gnutls/x509.h> +# include <gnutls/pkcs12.h> #endif // HAVE_LIBGNUTLS #include "LogFactory.h" diff --git a/src/LibgnutlsTLSSession.cc b/src/LibgnutlsTLSSession.cc index 18a1309c..bd6b4eb0 100644 --- a/src/LibgnutlsTLSSession.cc +++ b/src/LibgnutlsTLSSession.cc @@ -91,7 +91,7 @@ GnuTLSSession::~GnuTLSSession() #if (GNUTLS_VERSION_NUMBER >= 0x030103 && \ GNUTLS_VERSION_NUMBER <= 0x030112) || \ (GNUTLS_VERSION_NUMBER >= 0x030200 && GNUTLS_VERSION_NUMBER <= 0x030208) -#define A2_DISABLE_OCSP 1 +# define A2_DISABLE_OCSP 1 #endif int GnuTLSSession::init(sock_t sockfd) @@ -99,11 +99,11 @@ int GnuTLSSession::init(sock_t sockfd) #if GNUTLS_VERSION_NUMBER >= 0x030000 unsigned int flags = tlsContext_->getSide() == TLS_CLIENT ? GNUTLS_CLIENT : GNUTLS_SERVER; -#ifdef A2_DISABLE_OCSP +# ifdef A2_DISABLE_OCSP if (tlsContext_->getSide() == TLS_CLIENT) { flags |= GNUTLS_NO_EXTENSIONS; } -#endif // A2_DISABLE_OCSP +# endif // A2_DISABLE_OCSP rv_ = gnutls_init(&sslSession_, flags); #else // GNUTLS_VERSION_NUMBER >= 0x030000 diff --git a/src/LibsslTLSContext.cc b/src/LibsslTLSContext.cc index 62a5577d..8cce672b 100644 --- a/src/LibsslTLSContext.cc +++ b/src/LibsslTLSContext.cc @@ -146,7 +146,7 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side, TLSVersion minVer) } #if OPENSSL_VERSION_NUMBER >= 0x0090800fL -#ifndef OPENSSL_NO_ECDH +# ifndef OPENSSL_NO_ECDH auto ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); if (ecdh == nullptr) { A2_LOG_WARN(fmt("Failed to enable ECDHE cipher suites. Cause: %s", @@ -156,8 +156,8 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side, TLSVersion minVer) SSL_CTX_set_tmp_ecdh(sslCtx_, ecdh); EC_KEY_free(ecdh); } -#endif // OPENSSL_NO_ECDH -#endif // OPENSSL_VERSION_NUMBER >= 0x0090800fL +# endif // OPENSSL_NO_ECDH +#endif // OPENSSL_VERSION_NUMBER >= 0x0090800fL } OpenSSLTLSContext::~OpenSSLTLSContext() { SSL_CTX_free(sslCtx_); } diff --git a/src/LibuvEventPoll.cc b/src/LibuvEventPoll.cc index 3b877fff..1b0b549d 100644 --- a/src/LibuvEventPoll.cc +++ b/src/LibuvEventPoll.cc @@ -35,10 +35,10 @@ /* copyright --> */ #ifdef __MINGW32__ -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif // _WIN32_WINNT -#define _WIN32_WINNT 0x0600 +# ifdef _WIN32_WINNT +# undef _WIN32_WINNT +# endif // _WIN32_WINNT +# define _WIN32_WINNT 0x0600 #endif // __MINGW32__ #include "LibuvEventPoll.h" diff --git a/src/LibuvEventPoll.h b/src/LibuvEventPoll.h index 23cccec3..42641d77 100644 --- a/src/LibuvEventPoll.h +++ b/src/LibuvEventPoll.h @@ -46,7 +46,7 @@ #include "a2functional.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/Lock.h b/src/Lock.h index 028100a4..26c1aa60 100644 --- a/src/Lock.h +++ b/src/Lock.h @@ -36,9 +36,9 @@ #define D_LOCK_H #if defined(_WIN32) -#include <windows.h> +# include <windows.h> #elif defined(ENABLE_PTHREAD) -#include <pthread.h> +# include <pthread.h> #endif namespace aria2 { diff --git a/src/LogFactory.cc b/src/LogFactory.cc index 3a38613b..48974f04 100644 --- a/src/LogFactory.cc +++ b/src/LogFactory.cc @@ -38,7 +38,7 @@ #include "RecoverableException.h" #ifdef HAVE_LIBGNUTLS -#include <gnutls/gnutls.h> +# include <gnutls/gnutls.h> #endif // HAVE_LIBGNUTLS namespace aria2 { diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc index 3c564d13..512b2a70 100644 --- a/src/Metalink2RequestGroup.cc +++ b/src/Metalink2RequestGroup.cc @@ -61,8 +61,8 @@ #include "download_handlers.h" #include "RequestGroupCriteria.h" #ifdef ENABLE_BITTORRENT -#include "BtDependency.h" -#include "download_helper.h" +# include "BtDependency.h" +# include "download_helper.h" #endif // ENABLE_BITTORRENT #include "Checksum.h" #include "ChunkChecksum.h" diff --git a/src/MetalinkParserController.cc b/src/MetalinkParserController.cc index 6082ce6a..aa5f236c 100644 --- a/src/MetalinkParserController.cc +++ b/src/MetalinkParserController.cc @@ -50,7 +50,7 @@ #include "ChunkChecksum.h" #include "MessageDigest.h" #ifdef ENABLE_BITTORRENT -#include "magnet.h" +# include "magnet.h" #endif // ENABLE_BITTORRENT namespace aria2 { diff --git a/src/MultiFileAllocationIterator.cc b/src/MultiFileAllocationIterator.cc index 6ed22444..d47a51ce 100644 --- a/src/MultiFileAllocationIterator.cc +++ b/src/MultiFileAllocationIterator.cc @@ -38,7 +38,7 @@ #include "AdaptiveFileAllocationIterator.h" #include "TruncFileAllocationIterator.h" #ifdef HAVE_SOME_FALLOCATE -#include "FallocFileAllocationIterator.h" +# include "FallocFileAllocationIterator.h" #endif // HAVE_SOME_FALLOCATE #include "DiskWriter.h" #include "DefaultDiskWriterFactory.h" diff --git a/src/MultiUrlRequestInfo.cc b/src/MultiUrlRequestInfo.cc index 240f1d23..833188e3 100644 --- a/src/MultiUrlRequestInfo.cc +++ b/src/MultiUrlRequestInfo.cc @@ -66,15 +66,15 @@ #include "Notifier.h" #include "console.h" #ifdef ENABLE_WEBSOCKET -#include "WebSocketSessionMan.h" +# include "WebSocketSessionMan.h" #else // !ENABLE_WEBSOCKET -#include "NullWebSocketSessionMan.h" +# include "NullWebSocketSessionMan.h" #endif // !ENABLE_WEBSOCKET #ifdef ENABLE_SSL -#include "TLSContext.h" +# include "TLSContext.h" #endif // ENABLE_SSL #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { @@ -389,10 +389,10 @@ void MultiUrlRequestInfo::setupSignalHandlers() #ifdef HAVE_SIGACTION sigaddset(&mask_, SIGINT); sigaddset(&mask_, SIGTERM); -#ifdef SIGHUP +# ifdef SIGHUP sigaddset(&mask_, SIGHUP); -#endif // SIGHUP -#endif // HAVE_SIGACTION +# endif // SIGHUP +#endif // HAVE_SIGACTION #ifdef SIGHUP util::setGlobalSignalHandler(SIGHUP, &mask_, handler, 0); diff --git a/src/NameResolveCommand.cc b/src/NameResolveCommand.cc index ec0ce044..f2c5d01c 100644 --- a/src/NameResolveCommand.cc +++ b/src/NameResolveCommand.cc @@ -47,7 +47,7 @@ #include "UDPTrackerClient.h" #include "BtRegistry.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolverMan.h" +# include "AsyncNameResolverMan.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 4339c912..3d76d338 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -87,11 +87,11 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers() #ifdef ENABLE_ASYNC_DNS { OptionHandler* op(new BooleanOptionHandler(PREF_ASYNC_DNS, TEXT_ASYNC_DNS, -#if defined(__ANDROID__) || defined(ANDROID) +# if defined(__ANDROID__) || defined(ANDROID) A2_V_FALSE, -#else // !__ANDROID__ && !ANDROID +# else // !__ANDROID__ && !ANDROID A2_V_TRUE, -#endif // !__ANDROID__ && !ANDROID +# endif // !__ANDROID__ && !ANDROID OptionHandler::OPT_ARG)); op->addTag(TAG_ADVANCED); op->setInitialOption(true); @@ -99,15 +99,15 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers() op->setChangeOptionForReserved(true); handlers.push_back(op); } -#if defined(HAVE_ARES_SET_SERVERS) && defined(HAVE_ARES_ADDR_NODE) +# if defined(HAVE_ARES_SET_SERVERS) && defined(HAVE_ARES_ADDR_NODE) { OptionHandler* op(new DefaultOptionHandler( PREF_ASYNC_DNS_SERVER, TEXT_ASYNC_DNS_SERVER, NO_DEFAULT_VALUE)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } -#endif // HAVE_ARES_SET_SERVERS && HAVE_ARES_ADDR_NODE -#endif // ENABLE_ASYNC_DNS +# endif // HAVE_ARES_SET_SERVERS && HAVE_ARES_ADDR_NODE +#endif // ENABLE_ASYNC_DNS { OptionHandler* op(new BooleanOptionHandler( PREF_AUTO_FILE_RENAMING, TEXT_AUTO_FILE_RENAMING, A2_V_TRUE, diff --git a/src/Platform.cc b/src/Platform.cc index 5833bb22..ea73b6c6 100644 --- a/src/Platform.cc +++ b/src/Platform.cc @@ -42,22 +42,22 @@ #include <iostream> #ifdef HAVE_OPENSSL -#include <openssl/err.h> -#include <openssl/ssl.h> +# include <openssl/err.h> +# include <openssl/ssl.h> #endif // HAVE_OPENSSL #ifdef HAVE_LIBGCRYPT -#include <gcrypt.h> +# include <gcrypt.h> #endif // HAVE_LIBGCRYPT #ifdef HAVE_LIBGNUTLS -#include <gnutls/gnutls.h> +# include <gnutls/gnutls.h> #endif // HAVE_LIBGNUTLS #ifdef ENABLE_ASYNC_DNS -#include <ares.h> +# include <ares.h> #endif // ENABLE_ASYNC_DNS #ifdef HAVE_LIBSSH2 -#include <libssh2.h> +# include <libssh2.h> #endif // HAVE_LIBSSH2 #include "a2netcompat.h" @@ -68,7 +68,7 @@ #include "OptionParser.h" #include "prefs.h" #ifdef HAVE_LIBGMP -#include "a2gmp.h" +# include "a2gmp.h" #endif // HAVE_LIBGMP #include "LogFactory.h" #include "util.h" diff --git a/src/PollEventPoll.h b/src/PollEventPoll.h index 2ae74fce..c9a27aff 100644 --- a/src/PollEventPoll.h +++ b/src/PollEventPoll.h @@ -44,7 +44,7 @@ #include "Event.h" #include "a2functional.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/PortEventPoll.h b/src/PortEventPoll.h index dabf6874..405da3c0 100644 --- a/src/PortEventPoll.h +++ b/src/PortEventPoll.h @@ -38,7 +38,7 @@ #include "EventPoll.h" #ifdef HAVE_PORT_H -#include <port.h> +# include <port.h> #endif // HAVE_PORT_H #include <set> @@ -46,7 +46,7 @@ #include "Event.h" #include "a2functional.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/ProtocolDetector.cc b/src/ProtocolDetector.cc index 81078f84..cc7016fc 100644 --- a/src/ProtocolDetector.cc +++ b/src/ProtocolDetector.cc @@ -44,7 +44,7 @@ #include "uri.h" #include "BufferedFile.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 { diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 379029ec..c05a8189 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -82,39 +82,39 @@ #include "CheckIntegrityCommand.h" #include "ChecksumCheckIntegrityEntry.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" -#include "BtRegistry.h" -#include "BtCheckIntegrityEntry.h" -#include "DefaultPeerStorage.h" -#include "DefaultBtAnnounce.h" -#include "BtRuntime.h" -#include "BtSetup.h" -#include "BtPostDownloadHandler.h" -#include "DHTSetup.h" -#include "DHTRegistry.h" -#include "DHTNode.h" -#include "DHTRoutingTable.h" -#include "DHTTaskQueue.h" -#include "DHTTaskFactory.h" -#include "DHTTokenTracker.h" -#include "DHTMessageDispatcher.h" -#include "DHTMessageReceiver.h" -#include "DHTMessageFactory.h" -#include "DHTMessageCallback.h" -#include "BtMessageFactory.h" -#include "BtRequestFactory.h" -#include "BtMessageDispatcher.h" -#include "BtMessageReceiver.h" -#include "PeerConnection.h" -#include "ExtensionMessageFactory.h" -#include "DHTPeerAnnounceStorage.h" -#include "DHTEntryPointNameResolveCommand.h" -#include "LongestSequencePieceSelector.h" -#include "PriorityPieceSelector.h" -#include "bittorrent_helper.h" +# include "bittorrent_helper.h" +# include "BtRegistry.h" +# include "BtCheckIntegrityEntry.h" +# include "DefaultPeerStorage.h" +# include "DefaultBtAnnounce.h" +# include "BtRuntime.h" +# include "BtSetup.h" +# include "BtPostDownloadHandler.h" +# include "DHTSetup.h" +# include "DHTRegistry.h" +# include "DHTNode.h" +# include "DHTRoutingTable.h" +# include "DHTTaskQueue.h" +# include "DHTTaskFactory.h" +# include "DHTTokenTracker.h" +# include "DHTMessageDispatcher.h" +# include "DHTMessageReceiver.h" +# include "DHTMessageFactory.h" +# include "DHTMessageCallback.h" +# include "BtMessageFactory.h" +# include "BtRequestFactory.h" +# include "BtMessageDispatcher.h" +# include "BtMessageReceiver.h" +# include "PeerConnection.h" +# include "ExtensionMessageFactory.h" +# include "DHTPeerAnnounceStorage.h" +# include "DHTEntryPointNameResolveCommand.h" +# include "LongestSequencePieceSelector.h" +# include "PriorityPieceSelector.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK -#include "MetalinkPostDownloadHandler.h" +# include "MetalinkPostDownloadHandler.h" #endif // ENABLE_METALINK namespace aria2 { diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 28a3e547..425351bb 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -86,7 +86,7 @@ #include "wallclock.h" #include "RpcMethodImpl.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 { diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc index 38156053..c2249202 100644 --- a/src/RpcMethodImpl.cc +++ b/src/RpcMethodImpl.cc @@ -70,12 +70,12 @@ #include "message_digest_helper.h" #include "OpenedFileCounter.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" -#include "BtRegistry.h" -#include "PeerStorage.h" -#include "Peer.h" -#include "BtRuntime.h" -#include "BtAnnounce.h" +# include "bittorrent_helper.h" +# include "BtRegistry.h" +# include "PeerStorage.h" +# include "Peer.h" +# include "BtRuntime.h" +# include "BtAnnounce.h" #endif // ENABLE_BITTORRENT #include "CheckIntegrityEntry.h" diff --git a/src/RpcResponse.cc b/src/RpcResponse.cc index fd3b2f10..bbeb4cf5 100644 --- a/src/RpcResponse.cc +++ b/src/RpcResponse.cc @@ -40,7 +40,7 @@ #include "util.h" #include "json.h" #ifdef HAVE_ZLIB -#include "GZipEncoder.h" +# include "GZipEncoder.h" #endif // HAVE_ZLIB namespace aria2 { diff --git a/src/SelectEventPoll.cc b/src/SelectEventPoll.cc index 38f9de4b..d9397b20 100644 --- a/src/SelectEventPoll.cc +++ b/src/SelectEventPoll.cc @@ -35,7 +35,7 @@ #include "SelectEventPoll.h" #ifdef __MINGW32__ -#include <cassert> +# include <cassert> #endif // __MINGW32__ #include <cstring> #include <algorithm> diff --git a/src/SelectEventPoll.h b/src/SelectEventPoll.h index d5753095..c09f423f 100644 --- a/src/SelectEventPoll.h +++ b/src/SelectEventPoll.h @@ -42,7 +42,7 @@ #include "a2functional.h" #ifdef ENABLE_ASYNC_DNS -#include "AsyncNameResolver.h" +# include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { diff --git a/src/SessionSerializer.cc b/src/SessionSerializer.cc index 6dbdabea..86c815d8 100644 --- a/src/SessionSerializer.cc +++ b/src/SessionSerializer.cc @@ -56,7 +56,7 @@ #include "SHA1IOFile.h" #if HAVE_ZLIB -#include "GZipFile.h" +# include "GZipFile.h" #endif namespace aria2 { diff --git a/src/SimpleRandomizer.cc b/src/SimpleRandomizer.cc index 5311ba6b..539855e5 100644 --- a/src/SimpleRandomizer.cc +++ b/src/SimpleRandomizer.cc @@ -46,9 +46,9 @@ #include "fmt.h" #ifdef HAVE_GETRANDOM_INTERFACE -#include <errno.h> -#include <linux/errno.h> -#include "getrandom_linux.h" +# include <errno.h> +# include <linux/errno.h> +# include "getrandom_linux.h" #endif namespace aria2 { @@ -97,7 +97,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len) BOOL r = CryptGenRandom(provider_, len, reinterpret_cast<BYTE*>(buf)); assert(r); #else // ! __MINGW32__ -#if defined(HAVE_GETRANDOM_INTERFACE) +# if defined(HAVE_GETRANDOM_INTERFACE) static bool have_random_support = true; if (have_random_support) { auto rv = getrandom_linux(buf, len); @@ -111,7 +111,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len) "implement this feature (ENOSYS)"); } // Fall through to generic implementation -#endif // defined(HAVE_GETRANDOM_INTERFACE) +# endif // defined(HAVE_GETRANDOM_INTERFACE) auto ubuf = reinterpret_cast<result_type*>(buf); size_t q = len / sizeof(result_type); auto dis = std::uniform_int_distribution<result_type>(); @@ -121,7 +121,7 @@ void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len) const size_t r = len % sizeof(result_type); auto last = dis(gen_); memcpy(ubuf, &last, r); -#endif // ! __MINGW32__ +#endif // ! __MINGW32__ } } // namespace aria2 diff --git a/src/SimpleRandomizer.h b/src/SimpleRandomizer.h index 7440dd36..aea6fe05 100644 --- a/src/SimpleRandomizer.h +++ b/src/SimpleRandomizer.h @@ -41,7 +41,7 @@ #include <random> #ifdef __MINGW32__ -#include <wincrypt.h> +# include <wincrypt.h> #endif namespace aria2 { diff --git a/src/SocketCore.cc b/src/SocketCore.cc index d0a205f1..77dc30cf 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -35,12 +35,12 @@ #include "SocketCore.h" #ifdef HAVE_IPHLPAPI_H -#include <iphlpapi.h> +# include <iphlpapi.h> #endif // HAVE_IPHLPAPI_H #include <unistd.h> #ifdef HAVE_IFADDRS_H -#include <ifaddrs.h> +# include <ifaddrs.h> #endif // HAVE_IFADDRS_H #include <cerrno> @@ -59,44 +59,44 @@ #include "LogFactory.h" #include "A2STR.h" #ifdef ENABLE_SSL -#include "TLSContext.h" -#include "TLSSession.h" +# include "TLSContext.h" +# include "TLSSession.h" #endif // ENABLE_SSL #ifdef HAVE_LIBSSH2 -#include "SSHSession.h" +# include "SSHSession.h" #endif // HAVE_LIBSSH2 namespace aria2 { #ifndef __MINGW32__ -#define SOCKET_ERRNO (errno) +# define SOCKET_ERRNO (errno) #else -#define SOCKET_ERRNO (WSAGetLastError()) +# define SOCKET_ERRNO (WSAGetLastError()) #endif // __MINGW32__ #ifdef __MINGW32__ -#define A2_EINPROGRESS WSAEWOULDBLOCK -#define A2_EWOULDBLOCK WSAEWOULDBLOCK -#define A2_EINTR WSAEINTR -#define A2_WOULDBLOCK(e) (e == WSAEWOULDBLOCK) +# define A2_EINPROGRESS WSAEWOULDBLOCK +# define A2_EWOULDBLOCK WSAEWOULDBLOCK +# define A2_EINTR WSAEINTR +# define A2_WOULDBLOCK(e) (e == WSAEWOULDBLOCK) #else // !__MINGW32__ -#define A2_EINPROGRESS EINPROGRESS -#ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN -#endif // EWOULDBLOCK -#define A2_EWOULDBLOCK EWOULDBLOCK -#define A2_EINTR EINTR -#if EWOULDBLOCK == EAGAIN -#define A2_WOULDBLOCK(e) (e == EWOULDBLOCK) -#else // EWOULDBLOCK != EAGAIN -#define A2_WOULDBLOCK(e) (e == EWOULDBLOCK || e == EAGAIN) -#endif // EWOULDBLOCK != EAGAIN -#endif // !__MINGW32__ +# define A2_EINPROGRESS EINPROGRESS +# ifndef EWOULDBLOCK +# define EWOULDBLOCK EAGAIN +# endif // EWOULDBLOCK +# define A2_EWOULDBLOCK EWOULDBLOCK +# define A2_EINTR EINTR +# if EWOULDBLOCK == EAGAIN +# define A2_WOULDBLOCK(e) (e == EWOULDBLOCK) +# else // EWOULDBLOCK != EAGAIN +# define A2_WOULDBLOCK(e) (e == EWOULDBLOCK || e == EAGAIN) +# endif // EWOULDBLOCK != EAGAIN +#endif // !__MINGW32__ #ifdef __MINGW32__ -#define CLOSE(X) ::closesocket(X) +# define CLOSE(X) ::closesocket(X) #else -#define CLOSE(X) close(X) +# define CLOSE(X) close(X) #endif // __MINGW32__ namespace { @@ -655,12 +655,12 @@ void SocketCore::closeConnection() } #ifndef __MINGW32__ -#define CHECK_FD(fd) \ - if (fd < 0 || FD_SETSIZE <= fd) { \ - logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \ - "Download may slow down or fail."); \ - return false; \ - } +# define CHECK_FD(fd) \ + if (fd < 0 || FD_SETSIZE <= fd) { \ + logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \ + "Download may slow down or fail."); \ + return false; \ + } #endif // !__MINGW32__ bool SocketCore::isWritable(time_t timeout) @@ -681,9 +681,9 @@ bool SocketCore::isWritable(time_t timeout) } throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str())); #else // !HAVE_POLL -#ifndef __MINGW32__ +# ifndef __MINGW32__ CHECK_FD(sockfd_); -#endif // !__MINGW32__ +# endif // !__MINGW32__ fd_set fds; FD_ZERO(&fds); FD_SET(sockfd_, &fds); @@ -705,7 +705,7 @@ bool SocketCore::isWritable(time_t timeout) return false; } throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str())); -#endif // !HAVE_POLL +#endif // !HAVE_POLL } bool SocketCore::isReadable(time_t timeout) @@ -726,9 +726,9 @@ bool SocketCore::isReadable(time_t timeout) } throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str())); #else // !HAVE_POLL -#ifndef __MINGW32__ +# ifndef __MINGW32__ CHECK_FD(sockfd_); -#endif // !__MINGW32__ +# endif // !__MINGW32__ fd_set fds; FD_ZERO(&fds); FD_SET(sockfd_, &fds); @@ -750,7 +750,7 @@ bool SocketCore::isReadable(time_t timeout) return false; } throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str())); -#endif // !HAVE_POLL +#endif // !HAVE_POLL } ssize_t SocketCore::writeVector(a2iovec* iov, size_t iovcnt) diff --git a/src/Sqlite3CookieParser.cc b/src/Sqlite3CookieParser.cc index 91cb4270..f096ec79 100644 --- a/src/Sqlite3CookieParser.cc +++ b/src/Sqlite3CookieParser.cc @@ -43,7 +43,7 @@ #include "A2STR.h" #include "cookie_helper.h" #ifndef HAVE_SQLITE3_OPEN_V2 -#include "File.h" +# include "File.h" #endif // !HAVE_SQLITE3_OPEN_V2 namespace aria2 { diff --git a/src/UriListParser.cc b/src/UriListParser.cc index 9ef0051c..ca021cb3 100644 --- a/src/UriListParser.cc +++ b/src/UriListParser.cc @@ -46,7 +46,7 @@ #include "OptionParser.h" #if HAVE_ZLIB -#include "GZipFile.h" +# include "GZipFile.h" #endif namespace aria2 { diff --git a/src/WatchProcessCommand.cc b/src/WatchProcessCommand.cc index d5067cb5..948951ec 100644 --- a/src/WatchProcessCommand.cc +++ b/src/WatchProcessCommand.cc @@ -58,9 +58,9 @@ #include "fmt.h" #ifdef __APPLE__ -#import <sys/types.h> -#import <sys/sysctl.h> -#define MIBSIZE 4 +# import <sys/types.h> +# import <sys/sysctl.h> +# define MIBSIZE 4 #endif namespace aria2 { diff --git a/src/WinTLSContext.cc b/src/WinTLSContext.cc index 56d25002..73679a2c 100644 --- a/src/WinTLSContext.cc +++ b/src/WinTLSContext.cc @@ -45,20 +45,20 @@ #include "util.h" #ifndef SP_PROT_TLS1_1_CLIENT -#define SP_PROT_TLS1_1_CLIENT 0x00000200 +# define SP_PROT_TLS1_1_CLIENT 0x00000200 #endif #ifndef SP_PROT_TLS1_1_SERVER -#define SP_PROT_TLS1_1_SERVER 0x00000100 +# define SP_PROT_TLS1_1_SERVER 0x00000100 #endif #ifndef SP_PROT_TLS1_2_CLIENT -#define SP_PROT_TLS1_2_CLIENT 0x00000800 +# define SP_PROT_TLS1_2_CLIENT 0x00000800 #endif #ifndef SP_PROT_TLS1_2_SERVER -#define SP_PROT_TLS1_2_SERVER 0x00000400 +# define SP_PROT_TLS1_2_SERVER 0x00000400 #endif #ifndef SCH_USE_STRONG_CRYPTO -#define SCH_USE_STRONG_CRYPTO 0x00400000 +# define SCH_USE_STRONG_CRYPTO 0x00400000 #endif #define WEAK_CIPHER_BITS 56 diff --git a/src/WinTLSSession.cc b/src/WinTLSSession.cc index d54890e5..353a4847 100644 --- a/src/WinTLSSession.cc +++ b/src/WinTLSSession.cc @@ -44,17 +44,17 @@ #include "util.h" #ifndef SECBUFFER_ALERT -#define SECBUFFER_ALERT 17 +# define SECBUFFER_ALERT 17 #endif #ifndef SZ_ALG_MAX_SIZE -#define SZ_ALG_MAX_SIZE 64 +# define SZ_ALG_MAX_SIZE 64 #endif #ifndef SECPKGCONTEXT_CIPHERINFO_V1 -#define SECPKGCONTEXT_CIPHERINFO_V1 1 +# define SECPKGCONTEXT_CIPHERINFO_V1 1 #endif #ifndef SECPKG_ATTR_CIPHER_INFO -#define SECPKG_ATTR_CIPHER_INFO 0x64 +# define SECPKG_ATTR_CIPHER_INFO 0x64 #endif namespace { diff --git a/src/XmlParser.h b/src/XmlParser.h index d55895d5..fc8c8eac 100644 --- a/src/XmlParser.h +++ b/src/XmlParser.h @@ -61,9 +61,9 @@ struct SessionData { } // namespace aria2 #ifdef HAVE_LIBXML2 -#include "Xml2XmlParser.h" +# include "Xml2XmlParser.h" #elif HAVE_LIBEXPAT -#include "ExpatXmlParser.h" +# include "ExpatXmlParser.h" #endif namespace aria2 { diff --git a/src/a2io.h b/src/a2io.h index 5b971609..ddd53db2 100644 --- a/src/a2io.h +++ b/src/a2io.h @@ -41,159 +41,159 @@ #include <fcntl.h> #include <cerrno> #ifdef HAVE_POLL_H -#include <poll.h> +# include <poll.h> #endif // HAVE_POLL_H #ifdef HAVE_IO_H -#include <io.h> +# include <io.h> #endif // HAVE_IO_H #ifdef HAVE_WINIOCTL_H -#include <winioctl.h> +# include <winioctl.h> #endif // HAVE_WINIOCTL_H #ifdef HAVE_SHARE_H -#include <share.h> +# include <share.h> #endif // HAVE_SHARE_H // in some platforms following definitions are missing: #ifndef EINPROGRESS -#define EINPROGRESS (WSAEINPROGRESS) +# define EINPROGRESS (WSAEINPROGRESS) #endif // EINPROGRESS #ifndef O_NONBLOCK -#define O_NONBLOCK (O_NDELAY) +# define O_NONBLOCK (O_NDELAY) #endif // O_NONBLOCK #ifndef O_BINARY -#define O_BINARY (0) +# define O_BINARY (0) #endif // O_BINARY // st_mode flags #ifndef S_IRUSR -#define S_IRUSR 0000400 /* read permission, owner */ -#endif /* S_IRUSR */ +# define S_IRUSR 0000400 /* read permission, owner */ +#endif /* S_IRUSR */ #ifndef S_IWUSR -#define S_IWUSR 0000200 /* write permission, owner */ -#endif /* S_IWUSR */ +# define S_IWUSR 0000200 /* write permission, owner */ +#endif /* S_IWUSR */ #ifndef S_IXUSR -#define S_IXUSR 0000100 /* execute/search permission, owner */ -#endif /* S_IXUSR */ +# define S_IXUSR 0000100 /* execute/search permission, owner */ +#endif /* S_IXUSR */ #ifndef S_IRWXU -#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) #endif /* S_IRWXU */ #ifndef S_IRGRP -#define S_IRGRP 0000040 /* read permission, group */ -#endif /* S_IRGRP */ +# define S_IRGRP 0000040 /* read permission, group */ +#endif /* S_IRGRP */ #ifndef S_IWGRP -#define S_IWGRP 0000020 /* write permission, group */ -#endif /* S_IWGRP */ +# define S_IWGRP 0000020 /* write permission, group */ +#endif /* S_IWGRP */ #ifndef S_IXGRP -#define S_IXGRP 0000010 /* execute/search permission, group */ -#endif /* S_IXGRP */ +# define S_IXGRP 0000010 /* execute/search permission, group */ +#endif /* S_IXGRP */ #ifndef S_IRWXG -#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) #endif /* S_IRWXG */ #ifndef S_IROTH -#define S_IROTH 0000004 /* read permission, other */ -#endif /* S_IROTH */ +# define S_IROTH 0000004 /* read permission, other */ +#endif /* S_IROTH */ #ifndef S_IWOTH -#define S_IWOTH 0000002 /* write permission, other */ -#endif /* S_IWOTH */ +# define S_IWOTH 0000002 /* write permission, other */ +#endif /* S_IWOTH */ #ifndef S_IXOTH -#define S_IXOTH 0000001 /* execute/search permission, other */ -#endif /* S_IXOTH */ +# define S_IXOTH 0000001 /* execute/search permission, other */ +#endif /* S_IXOTH */ #ifndef S_IRWXO -#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) +# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) #endif /* S_IRWXO */ // Use 'nul' instead of /dev/null in win32. #ifdef HAVE_WINSOCK2_H -#define DEV_NULL "nul" +# define DEV_NULL "nul" #else -#define DEV_NULL "/dev/null" +# define DEV_NULL "/dev/null" #endif // HAVE_WINSOCK2_H // Use 'con' instead of '/dev/stdin' and '/dev/stdout' in win32. #ifdef HAVE_WINSOCK2_H -#define DEV_STDIN "con" -#define DEV_STDOUT "con" +# define DEV_STDIN "con" +# define DEV_STDOUT "con" #else -#define DEV_STDIN "/dev/stdin" -#define DEV_STDOUT "/dev/stdout" +# define DEV_STDIN "/dev/stdin" +# define DEV_STDOUT "/dev/stdout" #endif // HAVE_WINSOCK2_H #ifdef __MINGW32__ -#define a2lseek(fd, offset, origin) _lseeki64(fd, offset, origin) -#define a2fseek(fd, offset, origin) _fseeki64(fd, offset, origin) -#define a2fstat(fd, buf) _fstati64(fd, buf) -#define a2ftell(fd) _ftelli64(fd) -#define a2wstat(path, buf) _wstati64(path, buf) -#ifdef stat -#undef stat -#endif // stat -#define a2_struct_stat struct _stati64 -#define a2stat(path, buf) _wstati64(path, buf) -#define a2tell(handle) _telli64(handle) -#define a2mkdir(path, openMode) _wmkdir(path) -#define a2utimbuf _utimbuf -#define a2utime(path, times) _wutime(path, times) -#define a2unlink(path) _wunlink(path) -#define a2rmdir(path) _wrmdir(path) +# define a2lseek(fd, offset, origin) _lseeki64(fd, offset, origin) +# define a2fseek(fd, offset, origin) _fseeki64(fd, offset, origin) +# define a2fstat(fd, buf) _fstati64(fd, buf) +# define a2ftell(fd) _ftelli64(fd) +# define a2wstat(path, buf) _wstati64(path, buf) +# ifdef stat +# undef stat +# endif // stat +# define a2_struct_stat struct _stati64 +# define a2stat(path, buf) _wstati64(path, buf) +# define a2tell(handle) _telli64(handle) +# define a2mkdir(path, openMode) _wmkdir(path) +# define a2utimbuf _utimbuf +# define a2utime(path, times) _wutime(path, times) +# define a2unlink(path) _wunlink(path) +# define a2rmdir(path) _wrmdir(path) // For Windows, we share files for reading and writing. -#define a2open(path, flags, mode) _wsopen(path, flags, _SH_DENYNO, mode) -#define a2fopen(path, mode) _wfsopen(path, mode, _SH_DENYNO) +# define a2open(path, flags, mode) _wsopen(path, flags, _SH_DENYNO, mode) +# define a2fopen(path, mode) _wfsopen(path, mode, _SH_DENYNO) // # define a2ftruncate(fd, length): We don't use ftruncate in Mingw build -#define a2_off_t off_t +# define a2_off_t off_t #elif defined(__ANDROID__) || defined(ANDROID) -#define a2lseek(fd, offset, origin) lseek64(fd, offset, origin) +# define a2lseek(fd, offset, origin) lseek64(fd, offset, origin) // # define a2fseek(fp, offset, origin): No fseek64 and not used in aria2 -#define a2fstat(fd, buf) fstat64(fd, buf) +# define a2fstat(fd, buf) fstat64(fd, buf) // # define a2ftell(fd): No ftell64 and not used in aria2 -#define a2_struct_stat struct stat -#define a2stat(path, buf) stat64(path, buf) -#define a2mkdir(path, openMode) mkdir(path, openMode) -#define a2utimbuf utimbuf -#define a2utime(path, times) ::utime(path, times) -#define a2unlink(path) unlink(path) -#define a2rmdir(path) rmdir(path) -#define a2open(path, flags, mode) open(path, flags, mode) -#define a2fopen(path, mode) fopen(path, mode) +# define a2_struct_stat struct stat +# define a2stat(path, buf) stat64(path, buf) +# define a2mkdir(path, openMode) mkdir(path, openMode) +# define a2utimbuf utimbuf +# define a2utime(path, times) ::utime(path, times) +# define a2unlink(path) unlink(path) +# define a2rmdir(path) rmdir(path) +# define a2open(path, flags, mode) open(path, flags, mode) +# define a2fopen(path, mode) fopen(path, mode) // Android NDK R8e does not provide ftruncate64 prototype, so let's // define it here. -#ifdef __cplusplus +# ifdef __cplusplus extern "C" { -#endif +# endif extern int ftruncate64(int fd, off64_t length); -#ifdef __cplusplus +# ifdef __cplusplus } -#endif -#define a2ftruncate(fd, length) ftruncate64(fd, length) +# endif +# define a2ftruncate(fd, length) ftruncate64(fd, length) // Use off64_t directly since android does not offer transparent // switching between off_t and off64_t. -#define a2_off_t off64_t +# define a2_off_t off64_t #else // !__MINGW32__ && !(defined(__ANDROID__) || defined(ANDROID)) -#define a2lseek(fd, offset, origin) lseek(fd, offset, origin) -#define a2fseek(fp, offset, origin) fseek(fp, offset, origin) -#define a2fstat(fp, buf) fstat(fp, buf) -#define a2ftell(fp) ftell(fp) -#define a2_struct_stat struct stat -#define a2stat(path, buf) stat(path, buf) -#define a2mkdir(path, openMode) mkdir(path, openMode) -#define a2utimbuf utimbuf -#define a2utime(path, times) ::utime(path, times) -#define a2unlink(path) unlink(path) -#define a2rmdir(path) rmdir(path) -#define a2open(path, flags, mode) open(path, flags, mode) -#define a2fopen(path, mode) fopen(path, mode) -#define a2ftruncate(fd, length) ftruncate(fd, length) -#define a2_off_t off_t +# define a2lseek(fd, offset, origin) lseek(fd, offset, origin) +# define a2fseek(fp, offset, origin) fseek(fp, offset, origin) +# define a2fstat(fp, buf) fstat(fp, buf) +# define a2ftell(fp) ftell(fp) +# define a2_struct_stat struct stat +# define a2stat(path, buf) stat(path, buf) +# define a2mkdir(path, openMode) mkdir(path, openMode) +# define a2utimbuf utimbuf +# define a2utime(path, times) ::utime(path, times) +# define a2unlink(path) unlink(path) +# define a2rmdir(path) rmdir(path) +# define a2open(path, flags, mode) open(path, flags, mode) +# define a2fopen(path, mode) fopen(path, mode) +# define a2ftruncate(fd, length) ftruncate(fd, length) +# define a2_off_t off_t #endif #define OPEN_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH #define DIR_OPEN_MODE S_IRWXU | S_IRWXG | S_IRWXO #ifdef __MINGW32__ -#define A2_BAD_FD INVALID_HANDLE_VALUE +# define A2_BAD_FD INVALID_HANDLE_VALUE #else // !__MINGW32__ -#define A2_BAD_FD -1 +# define A2_BAD_FD -1 #endif // !__MINGW32__ #endif // D_A2IO_H diff --git a/src/a2netcompat.h b/src/a2netcompat.h index 4c09da79..c9b5b7e0 100644 --- a/src/a2netcompat.h +++ b/src/a2netcompat.h @@ -38,78 +38,78 @@ #include "a2io.h" #ifdef __MINGW32__ -#ifdef HAVE_WS2TCPIP_H -#include <ws2tcpip.h> -#endif // HAVE_WS2TCPIP_H -#endif // __MINGW32__ +# ifdef HAVE_WS2TCPIP_H +# include <ws2tcpip.h> +# endif // HAVE_WS2TCPIP_H +#endif // __MINGW32__ #ifdef __MINGW32__ -#define a2_sockopt_t char* -#ifndef HAVE_GETADDRINFO -#define HAVE_GETADDRINFO -#endif // !HAVE_GETADDRINFO -#undef HAVE_GAI_STRERROR -#undef gai_strerror +# define a2_sockopt_t char* +# ifndef HAVE_GETADDRINFO +# define HAVE_GETADDRINFO +# endif // !HAVE_GETADDRINFO +# undef HAVE_GAI_STRERROR +# undef gai_strerror #else -#define a2_sockopt_t void* +# define a2_sockopt_t void* #endif // __MINGW32__ #ifdef HAVE_NETDB_H -#include <netdb.h> +# include <netdb.h> #endif // HAVE_NETDB_H #ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> +# include <sys/socket.h> #endif // HAVE_SYS_SOCKET_H #ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> +# include <netinet/in.h> #endif // HAVE_NETINET_IN_H #ifdef HAVE_NETINET_TCP_H -#include <netinet/tcp.h> +# include <netinet/tcp.h> #endif // HAVE_NETINET_TCP_H #ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> +# include <arpa/inet.h> #endif // HAVE_ARPA_INET_H #ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> +# include <netinet/in.h> #endif // HAVE_NETINET_IN_H #ifdef HAVE_SYS_UIO_H -#include <sys/uio.h> +# include <sys/uio.h> #endif // HAVE_SYS_UIO_H #ifndef HAVE_GETADDRINFO -#include "getaddrinfo.h" -#define HAVE_GAI_STRERROR +# include "getaddrinfo.h" +# define HAVE_GAI_STRERROR #endif // HAVE_GETADDRINFO #ifndef HAVE_GAI_STRERROR -#include "gai_strerror.h" +# include "gai_strerror.h" #endif // HAVE_GAI_STRERROR #include <string> #ifdef HAVE_WINSOCK2_H -#define sock_t SOCKET +# define sock_t SOCKET #else -#define sock_t int +# define sock_t int #endif #ifndef AI_ADDRCONFIG -#define AI_ADDRCONFIG 0 +# define AI_ADDRCONFIG 0 #endif // !AI_ADDRCONFIG #define DEFAULT_AI_FLAGS AI_ADDRCONFIG #ifdef __MINGW32__ -#ifndef SHUT_WR -#define SHUT_WR SD_SEND -#endif // !SHUT_WR -#endif // __MINGW32__ +# ifndef SHUT_WR +# define SHUT_WR SD_SEND +# endif // !SHUT_WR +#endif // __MINGW32__ union sockaddr_union { sockaddr sa; @@ -136,19 +136,19 @@ struct Endpoint { #define A2_DEFAULT_IOV_MAX 128 #if defined(IOV_MAX) && IOV_MAX < A2_DEFAULT_IOV_MAX -#define A2_IOV_MAX IOV_MAX +# define A2_IOV_MAX IOV_MAX #else -#define A2_IOV_MAX A2_DEFAULT_IOV_MAX +# define A2_IOV_MAX A2_DEFAULT_IOV_MAX #endif #ifdef __MINGW32__ typedef WSABUF a2iovec; -#define A2IOVEC_BASE buf -#define A2IOVEC_LEN len +# define A2IOVEC_BASE buf +# define A2IOVEC_LEN len #else // !__MINGW32__ typedef struct iovec a2iovec; -#define A2IOVEC_BASE iov_base -#define A2IOVEC_LEN iov_len +# define A2IOVEC_BASE iov_base +# define A2IOVEC_LEN iov_len #endif // !__MINGW32__ #endif // D_A2NETCOMPAT_H diff --git a/src/a2time.h b/src/a2time.h index c430b5b3..3b407608 100644 --- a/src/a2time.h +++ b/src/a2time.h @@ -41,31 +41,31 @@ #include <chrono> #ifndef HAVE_LOCALTIME_R -#include "localtime_r.h" +# include "localtime_r.h" #endif // HAVE_LOCALTIME_R #ifndef HAVE_GETTIMEOFDAY -#include "gettimeofday.h" +# include "gettimeofday.h" #endif // HAVE_GETTIMEOFDAY #ifndef HAVE_STRPTIME -#include "strptime.h" +# include "strptime.h" #endif // HAVE_STRPTIME #ifndef HAVE_TIMEGM -#include "timegm.h" +# include "timegm.h" #endif // HAVE_TIMEGM #ifndef HAVE_ASCTIME_R -#include "asctime_r.h" +# include "asctime_r.h" #endif // HAVE_ASCTIME_R #ifdef __MINGW32__ -#define suseconds_t uint64_t +# define suseconds_t uint64_t #endif #ifndef HAVE_A2_STRUCT_TIMESPEC -#include "timespec.h" +# include "timespec.h" #endif // !HAVE_A2_STRUCT_TIMESPEC // Rounding error in millis diff --git a/src/alloca.c b/src/alloca.c index aa30eb66..6c930caa 100644 --- a/src/alloca.c +++ b/src/alloca.c @@ -22,18 +22,18 @@ your main control loop, etc. to force garbage collection. */ #ifdef HAVE_CONFIG_H -#include <config.h> +# include <config.h> #endif #if HAVE_STRING_H -#include <string.h> +# include <string.h> #endif #if HAVE_STDLIB_H -#include <stdlib.h> +# include <stdlib.h> #endif #ifdef emacs -#include "blockinput.h" +# include "blockinput.h" #endif /* If compiling with GCC 2, this file's not needed. */ @@ -41,40 +41,40 @@ /* If someone has defined alloca as a macro, there must be some other way alloca is supposed to work. */ -#ifndef alloca +# ifndef alloca -#ifdef emacs -#ifdef static +# ifdef emacs +# ifdef static /* actually, only want this if static is defined as "" -- this is for usg, in which emacs must undefine static in order to make unexec workable */ -#ifndef STACK_DIRECTION +# ifndef STACK_DIRECTION you lose-- must know STACK_DIRECTION at compile - time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ +# endif /* STACK_DIRECTION undefined */ +# endif /* static */ +# endif /* emacs */ /* If your stack is a linked list of frames, you have to provide an "address metric" ADDRESS_FUNCTION macro. */ -#if defined(CRAY) && defined(CRAY_STACKSEG_END) +# if defined(CRAY) && defined(CRAY_STACKSEG_END) long i00afunc(); -#define ADDRESS_FUNCTION(arg) (char*)i00afunc(&(arg)) -#else -#define ADDRESS_FUNCTION(arg) &(arg) -#endif +# define ADDRESS_FUNCTION(arg) (char*)i00afunc(&(arg)) +# else +# define ADDRESS_FUNCTION(arg) &(arg) +# endif -#if __STDC__ +# if __STDC__ typedef void* pointer; -#else +# else typedef char* pointer; -#endif +# endif -#ifndef NULL -#define NULL 0 -#endif +# ifndef NULL +# define NULL 0 +# endif /* Different portions of Emacs need to call different versions of malloc. The Emacs executable needs alloca to call xmalloc, because @@ -86,10 +86,10 @@ typedef char* pointer; Callers below should use malloc. */ -#ifndef emacs -#undef malloc -#define malloc xmalloc -#endif +# ifndef emacs +# undef malloc +# define malloc xmalloc +# endif extern pointer malloc(); /* Define STACK_DIRECTION if you know the direction of stack @@ -100,18 +100,18 @@ extern pointer malloc(); STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* Direction unknown. */ -#endif +# ifndef STACK_DIRECTION +# define STACK_DIRECTION 0 /* Direction unknown. */ +# endif -#if STACK_DIRECTION != 0 +# if STACK_DIRECTION != 0 -#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ +# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ -#else /* STACK_DIRECTION == 0; need run-time code. */ +# else /* STACK_DIRECTION == 0; need run-time code. */ static int stack_dir; /* 1 or -1 once known. */ -#define STACK_DIR stack_dir +# define STACK_DIR stack_dir static void find_stack_direction() { @@ -132,7 +132,7 @@ static void find_stack_direction() } } -#endif /* STACK_DIRECTION == 0 */ +# endif /* STACK_DIRECTION == 0 */ /* An "alloca header" is used to: (a) chain together all alloca'ed blocks; @@ -141,9 +141,9 @@ static void find_stack_direction() It is very important that sizeof(header) agree with malloc alignment chunk size. The following default should work okay. */ -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif +# ifndef ALIGN_SIZE +# define ALIGN_SIZE sizeof(double) +# endif typedef union hdr { char align[ALIGN_SIZE]; /* To force sizeof(header). */ @@ -167,10 +167,10 @@ pointer alloca(size_t size) auto char probe; /* Probes stack depth: */ register char* depth = ADDRESS_FUNCTION(probe); -#if STACK_DIRECTION == 0 +# if STACK_DIRECTION == 0 if (STACK_DIR == 0) /* Unknown growth direction. */ find_stack_direction(); -#endif +# endif /* Reclaim garbage, defined as all alloca'd storage that was allocated from deeper in the stack than currently. */ @@ -178,9 +178,9 @@ pointer alloca(size_t size) { register header* hp; /* Traverses linked list. */ -#ifdef emacs +# ifdef emacs BLOCK_INPUT; -#endif +# endif for (hp = last_alloca_header; hp != NULL;) if ((STACK_DIR > 0 && hp->h.deep > depth) || @@ -196,9 +196,9 @@ pointer alloca(size_t size) last_alloca_header = hp; /* -> last valid storage. */ -#ifdef emacs +# ifdef emacs UNBLOCK_INPUT; -#endif +# endif } if (size == 0) @@ -224,15 +224,15 @@ pointer alloca(size_t size) } } -#if defined(CRAY) && defined(CRAY_STACKSEG_END) +# if defined(CRAY) && defined(CRAY_STACKSEG_END) -#ifdef DEBUG_I00AFUNC -#include <stdio.h> -#endif +# ifdef DEBUG_I00AFUNC +# include <stdio.h> +# endif -#ifndef CRAY_STACK -#define CRAY_STACK -#ifndef CRAY2 +# ifndef CRAY_STACK +# define CRAY_STACK +# ifndef CRAY2 /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ struct stack_control_header { long shgrow : 32; /* Number of times stack has grown. */ @@ -282,7 +282,7 @@ struct stack_segment_linkage { long sss7; }; -#else /* CRAY2 */ +# else /* CRAY2 */ /* The following structure defines the vector of words returned by the STKSTAT library routine. */ struct stk_stat { @@ -333,10 +333,10 @@ struct stk_trailer { long unknown14; }; -#endif /* CRAY2 */ -#endif /* not CRAY_STACK */ +# endif /* CRAY2 */ +# endif /* not CRAY_STACK */ -#ifdef CRAY2 +# ifdef CRAY2 /* Determine a "stack measure" for an arbitrary ADDRESS. I doubt that "lint" will like this much. */ @@ -401,7 +401,7 @@ static long i00afunc(long* address) return (result); } -#else /* not CRAY2 */ +# else /* not CRAY2 */ /* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. Determine the number of the cell within the stack, given the address of the cell. The purpose of this @@ -444,9 +444,9 @@ static long i00afunc(long address) contain the target address. */ while (!(this_segment <= address && address <= stkl)) { -#ifdef DEBUG_I00AFUNC +# ifdef DEBUG_I00AFUNC fprintf(stderr, "%011o %011o %011o\n", this_segment, address, stkl); -#endif +# endif if (pseg == 0) break; stkl = stkl - pseg; @@ -464,9 +464,9 @@ static long i00afunc(long address) a cycle somewhere. */ while (pseg != 0) { -#ifdef DEBUG_I00AFUNC +# ifdef DEBUG_I00AFUNC fprintf(stderr, "%011o %011o\n", pseg, size); -#endif +# endif stkl = stkl - pseg; ssptr = (struct stack_segment_linkage*)stkl; size = ssptr->sssize; @@ -476,8 +476,8 @@ static long i00afunc(long address) return (result); } -#endif /* not CRAY2 */ -#endif /* CRAY */ +# endif /* not CRAY2 */ +# endif /* CRAY */ -#endif /* no alloca */ -#endif /* not GCC version 2 */ +# endif /* no alloca */ +#endif /* not GCC version 2 */ diff --git a/src/aria2api.cc b/src/aria2api.cc index bf079277..c8113986 100644 --- a/src/aria2api.cc +++ b/src/aria2api.cc @@ -63,7 +63,7 @@ #include "Notifier.h" #include "ApiCallbackDownloadEventListener.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 { diff --git a/src/asctime_r.c b/src/asctime_r.c index 4c50475a..176c3c29 100644 --- a/src/asctime_r.c +++ b/src/asctime_r.c @@ -37,8 +37,8 @@ #include <stdlib.h> #ifdef __MINGW32__ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> +# define WIN32_LEAN_AND_MEAN +# include <windows.h> #endif // __MINGW32__ #include "asctime_r.h" diff --git a/src/common.h b/src/common.h index 19095568..d1a99719 100644 --- a/src/common.h +++ b/src/common.h @@ -36,34 +36,34 @@ #define D_COMMON_H #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #ifdef __MINGW32__ -#ifdef malloc -#undef malloc -#endif -#ifdef realloc -#undef realloc -#endif +# ifdef malloc +# undef malloc +# endif +# ifdef realloc +# undef realloc +# endif #endif // __MINGW32__ #ifdef __MINGW32__ -#define WIN32_LEAN_AND_MEAN -#ifndef WINVER -#define WINVER 0x501 -#endif // !WINVER -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x501 -#endif // _WIN32_WINNT -#ifdef HAVE_WINSOCK2_H -#ifndef FD_SETSIZE -#define FD_SETSIZE 32768 -#endif // !FD_SETSIZE -#include <winsock2.h> -#undef ERROR -#endif // HAVE_WINSOCK2_H -#include <windows.h> +# define WIN32_LEAN_AND_MEAN +# ifndef WINVER +# define WINVER 0x501 +# endif // !WINVER +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x501 +# endif // _WIN32_WINNT +# ifdef HAVE_WINSOCK2_H +# ifndef FD_SETSIZE +# define FD_SETSIZE 32768 +# endif // !FD_SETSIZE +# include <winsock2.h> +# undef ERROR +# endif // HAVE_WINSOCK2_H +# include <windows.h> #endif // __MINGW32__ #ifdef ENABLE_NLS @@ -75,27 +75,27 @@ // it is defined as non-function form, this causes compile error. User // reported gcc-4.2.2 has this problem. But gcc-4.4.5 does not suffer // from this problem. -#include <gettext.h> -#define _(String) gettext(String) +# include <gettext.h> +# define _(String) gettext(String) #else // ENABLE_NLS -#define _(String) String +# define _(String) String #endif // use C99 limit macros #define __STDC_LIMIT_MACROS // included here for compatibility issues with old compiler/libraries. #ifdef HAVE_STDINT_H -#include <stdint.h> +# include <stdint.h> #endif // HAVE_STDINT_H // For PRId64 #define __STDC_FORMAT_MACROS #ifdef HAVE_INTTYPES_H -#include <inttypes.h> +# include <inttypes.h> #endif // HAVE_INTTYPES_H #ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> +# include <sys/types.h> #endif #endif // D_COMMON_H diff --git a/src/console.cc b/src/console.cc index fe519bf5..6147bbb8 100644 --- a/src/console.cc +++ b/src/console.cc @@ -35,9 +35,9 @@ #include "console.h" #include "NullOutputFile.h" #ifdef __MINGW32__ -#include "WinConsoleFile.h" +# include "WinConsoleFile.h" #else // !__MINGW32__ -#include "BufferedFile.h" +# include "BufferedFile.h" #endif // !__MINGW32__ namespace aria2 { diff --git a/src/crypto_endian.h b/src/crypto_endian.h index 9f05451a..95f82f4b 100644 --- a/src/crypto_endian.h +++ b/src/crypto_endian.h @@ -12,11 +12,11 @@ namespace crypto { #if defined(__GNUG__) -#define forceinline __attribute__((always_inline)) inline +# define forceinline __attribute__((always_inline)) inline #elif defined(_MSC_VER) -#define forceinline __forceinline +# define forceinline __forceinline #else // ! _MSC_VER -#define forceinline inline +# define forceinline inline #endif // ! _MSC_VER /* In order for this implementation to work your system (or you yourself) must @@ -29,18 +29,18 @@ namespace crypto { */ #if defined(_WIN32) || defined(__INTEL_COMPILER) || defined(_MSC_VER) // Itanium is dead! -#define LITTLE_ENDIAN 1234 -#define BIG_ENDIAN 4321 -#define BYTE_ORDER LITTLE_ENDIAN +# define LITTLE_ENDIAN 1234 +# define BIG_ENDIAN 4321 +# define BYTE_ORDER LITTLE_ENDIAN #else // ! defined(_WIN32) || defined(__INTEL_COMPILER) || defined (_MSC_VER) -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif // HAVE_SYS_PARAM_H +# ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +# endif // HAVE_SYS_PARAM_H #endif // ! defined(_WIN32) || defined(__INTEL_COMPILER) || defined (_MSC_VER) #if !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) || !defined(BYTE_ORDER) || \ (LITTLE_ENDIAN != BYTE_ORDER && BIG_ENDIAN != BYTE_ORDER) -#error Unsupported byte order/endianness +# error Unsupported byte order/endianness #endif // Lets spend some quality time mucking around with byte swap and endian-ness. @@ -52,7 +52,7 @@ forceinline uint32_t __crypto_bswap32(uint32_t p) return p; } #elif defined(__GNUG__) -#define __crypto_bswap32 __builtin_bswap32 +# define __crypto_bswap32 __builtin_bswap32 #else // defined(__GNUG__) forceinline uint32_t __crypto_bswap32(uint32_t n) { @@ -69,7 +69,7 @@ forceinline uint64_t __crypto_bswap64(uint64_t p) return p; } #elif defined(__GNUG__) -#define __crypto_bswap64 __builtin_bswap64 +# define __crypto_bswap64 __builtin_bswap64 #else // defined(__GNUG__) forceinline uint64_t __crypto_bswap64(uint64_t n) { @@ -99,11 +99,11 @@ template <> inline uint64_t __crypto_bswap(uint64_t n) // __crypto_le and __crypto_be depending on byte order #if LITTLE_ENDIAN == BYTE_ORDER -#define __crypto_be(n) __crypto_bswap(n) -#define __crypto_le(n) (n) +# define __crypto_be(n) __crypto_bswap(n) +# define __crypto_le(n) (n) #else // LITTLE_ENDIAN != WORD_ORDER -#define __crypto_be(n) (n) -#define __crypto_le(n) __crypto_bswap(n) +# define __crypto_be(n) (n) +# define __crypto_le(n) __crypto_bswap(n) #endif // LITTLE_ENDIAN != WORD_ORDER } // namespace crypto diff --git a/src/crypto_hash.cc b/src/crypto_hash.cc index 3a343397..ac82e7a1 100644 --- a/src/crypto_hash.cc +++ b/src/crypto_hash.cc @@ -12,11 +12,11 @@ // Compiler hints #if defined(__GNUG__) -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) #else // ! __GNUG_ -#define likely(x) (x) -#define unlikely(x) (x) +# define likely(x) (x) +# define unlikely(x) (x) #endif // ! __GNUG__ // Basic operations @@ -52,9 +52,9 @@ template <typename T> static forceinline T par(T b, T c, T d) } #ifdef __GNUG__ -#define __hash_maybe_memfence __asm__("" ::: "memory") +# define __hash_maybe_memfence __asm__("" ::: "memory") #else // __GNUG__ -#define __hash_maybe_memfence +# define __hash_maybe_memfence #endif // __GNUG__ // Template for the |::transform|s diff --git a/src/download_handlers.cc b/src/download_handlers.cc index b31ba065..57816933 100644 --- a/src/download_handlers.cc +++ b/src/download_handlers.cc @@ -38,12 +38,12 @@ #include "MemoryBufferPreDownloadHandler.h" #include "a2functional.h" #ifdef ENABLE_METALINK -#include "MetalinkPostDownloadHandler.h" +# include "MetalinkPostDownloadHandler.h" #endif // ENABLE_METALINK #ifdef ENABLE_BITTORRENT -#include "BtPostDownloadHandler.h" -#include "MemoryBencodePreDownloadHandler.h" -#include "UTMetadataPostDownloadHandler.h" +# include "BtPostDownloadHandler.h" +# include "MemoryBencodePreDownloadHandler.h" +# include "UTMetadataPostDownloadHandler.h" #endif // ENABLE_BITTORRENT namespace aria2 { diff --git a/src/download_helper.cc b/src/download_helper.cc index 7caf8c43..6118aa14 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -64,9 +64,9 @@ #include "download_handlers.h" #include "SimpleRandomizer.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" -#include "BtConstants.h" -#include "ValueBaseBencodeParser.h" +# include "bittorrent_helper.h" +# include "BtConstants.h" +# include "ValueBaseBencodeParser.h" #endif // ENABLE_BITTORRENT namespace aria2 { diff --git a/src/gai_strerror.c b/src/gai_strerror.c index 16bd3568..a76e4c5a 100644 --- a/src/gai_strerror.c +++ b/src/gai_strerror.c @@ -29,20 +29,20 @@ #include "gai_strerror.h" #ifdef ENABLE_NLS -#include <libintl.h> +# include <libintl.h> #endif #ifdef ENABLE_NLS -#define _(string) gettext(string) -#ifdef gettext_noop -#define N_(string) gettext_noop(string) +# define _(string) gettext(string) +# ifdef gettext_noop +# define N_(string) gettext_noop(string) +# else +# define N_(string) (string) +# endif #else -#define N_(string) (string) -#endif -#else -#define gettext(string) (string) -#define _(string) (string) -#define N_(string) (string) +# define gettext(string) (string) +# define _(string) (string) +# define N_(string) (string) #endif /* diff --git a/src/gai_strerror.h b/src/gai_strerror.h index 9b3bf704..da7b6ca7 100644 --- a/src/gai_strerror.h +++ b/src/gai_strerror.h @@ -34,15 +34,15 @@ extern "C" { #endif /* __cplusplus */ #ifdef __MINGW32__ -#undef SIZE_MAX +# undef SIZE_MAX #endif // __MINGW32__ #ifndef EAI_SYSTEM -#define EAI_SYSTEM -11 /* System error returned in `errno'. */ +# define EAI_SYSTEM -11 /* System error returned in `errno'. */ #endif #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif // HAVE_CONFIG_H /* @@ -50,7 +50,7 @@ extern "C" { * <netdb.h> might declares all or some of them. */ #if defined(HAVE_GAI_STRERROR) -#define gai_strerror my_gai_strerror +# define gai_strerror my_gai_strerror #endif /* diff --git a/src/getaddrinfo.c b/src/getaddrinfo.c index 49e79cc9..bfa3b4a3 100644 --- a/src/getaddrinfo.c +++ b/src/getaddrinfo.c @@ -76,66 +76,66 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #ifdef __MINGW32__ -#include <winsock2.h> -#undef ERROR -#include <ws2tcpip.h> +# include <winsock2.h> +# undef ERROR +# include <ws2tcpip.h> #endif #ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> +# include <sys/socket.h> #endif #ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> +# include <netinet/in.h> #endif #ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> +# include <arpa/inet.h> #endif #ifdef HAVE_NETDB_H -#include <netdb.h> +# include <netdb.h> #endif #include <sys/types.h> #include <stdio.h> #if defined(STDC_HEADERS) || defined(HAVE_STRING_H) -#include <string.h> -#if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) -#include <memory.h> -#endif /* not STDC_HEADERS and HAVE_MEMORY_H */ -#else /* not STDC_HEADERS and not HAVE_STRING_H */ -#include <strings.h> +# include <string.h> +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include <memory.h> +# endif /* not STDC_HEADERS and HAVE_MEMORY_H */ +#else /* not STDC_HEADERS and not HAVE_STRING_H */ +# include <strings.h> #endif /* not STDC_HEADERS and not HAVE_STRING_H */ #ifdef HAVE_STDLIB_H -#include <stdlib.h> +# include <stdlib.h> #endif #ifdef ENABLE_PTHREAD -#include <pthread.h> +# include <pthread.h> #endif #ifdef ENABLE_NLS -#include <libintl.h> +# include <libintl.h> #endif #ifndef HAVE_MEMCPY -#define memcpy(d, s, n) bcopy((s), (d), (n)) -#ifdef __STDC__ +# define memcpy(d, s, n) bcopy((s), (d), (n)) +# ifdef __STDC__ void* memchr(const void*, int, size_t); int memcmp(const void*, const void*, size_t); void* memmove(void*, const void*, size_t); void* memset(void*, int, size_t); -#else /* not __STDC__ */ +# else /* not __STDC__ */ char* memchr(); int memcmp(); char* memmove(); char* memset(); -#endif /* not __STDC__ */ -#endif /* not HAVE_MEMCPY */ +# endif /* not __STDC__ */ +#endif /* not HAVE_MEMCPY */ #ifndef H_ERRNO_DECLARED extern int h_errno; @@ -144,16 +144,16 @@ extern int h_errno; #include "getaddrinfo.h" #ifdef ENABLE_NLS -#define _(string) gettext(string) -#ifdef gettext_noop -#define N_(string) gettext_noop(string) +# define _(string) gettext(string) +# ifdef gettext_noop +# define N_(string) gettext_noop(string) +# else +# define N_(string) (string) +# endif #else -#define N_(string) (string) -#endif -#else -#define gettext(string) (string) -#define _(string) (string) -#define N_(string) (string) +# define gettext(string) (string) +# define _(string) (string) +# define N_(string) (string) #endif /* diff --git a/src/getaddrinfo.h b/src/getaddrinfo.h index 35257670..d841d4be 100644 --- a/src/getaddrinfo.h +++ b/src/getaddrinfo.h @@ -34,27 +34,27 @@ extern "C" { #endif /* __cplusplus */ #ifdef __MINGW32__ -#undef SIZE_MAX +# undef SIZE_MAX #endif // __MINGW32__ #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif // HAVE_CONFIG_H #ifdef __MINGW32__ -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x501 -#endif // _WIN32_WINNT -#include <winsock2.h> -#undef ERROR -#include <ws2tcpip.h> +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x501 +# endif // _WIN32_WINNT +# include <winsock2.h> +# undef ERROR +# include <ws2tcpip.h> #endif // __MINGW32__ #ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> +# include <sys/socket.h> #endif // HAVE_SYS_SOCKET_H #ifdef HAVE_NETDB_H -#include <netdb.h> +# include <netdb.h> #endif // HAVE_NETDB_H #include <sys/types.h> @@ -65,88 +65,88 @@ extern "C" { * <netdb.h> might defines some of them. */ #ifdef EAI_ADDRFAMILY -#undef EAI_ADDRFAMILY +# undef EAI_ADDRFAMILY #endif #ifdef EAI_AGAIN -#undef EAI_AGAIN +# undef EAI_AGAIN #endif #ifdef EAI_BADFLAGS -#undef EAI_BADFLAGS +# undef EAI_BADFLAGS #endif #ifdef EAI_FAIL -#undef EAI_FAIL +# undef EAI_FAIL #endif #ifdef EAI_FAMILY -#undef EAI_FAMILY +# undef EAI_FAMILY #endif #ifdef EAI_MEMORY -#undef EAI_MEMORY +# undef EAI_MEMORY #endif #ifdef EAI_NONAME -#undef EAI_NONAME +# undef EAI_NONAME #endif #ifdef EAI_OVERFLOW -#undef EAI_OVERFLOW +# undef EAI_OVERFLOW #endif #ifdef EAI_SERVICE -#undef EAI_SERVICE +# undef EAI_SERVICE #endif #ifdef EAI_SOCKTYPE -#undef EAI_SOCKTYPE +# undef EAI_SOCKTYPE #endif #ifdef EAI_SYSTEM -#undef EAI_SYSTEM +# undef EAI_SYSTEM #endif #ifdef AI_PASSIVE -#undef AI_PASSIVE +# undef AI_PASSIVE #endif #ifdef AI_CANONNAME -#undef AI_CANONNAME +# undef AI_CANONNAME #endif #ifdef AI_NUMERICHOST -#undef AI_NUMERICHOST +# undef AI_NUMERICHOST #endif #ifdef AI_NUMERICSERV -#undef AI_NUMERICSERV +# undef AI_NUMERICSERV #endif #ifdef AI_V4MAPPED -#undef AI_V4MAPPED +# undef AI_V4MAPPED #endif #ifdef AI_ALL -#undef AI_ALL +# undef AI_ALL #endif #ifdef AI_ADDRCONFIG -#undef AI_ADDRCONFIG +# undef AI_ADDRCONFIG #endif #ifdef AI_DEFAULT -#undef AI_DEFAULT +# undef AI_DEFAULT #endif #ifdef NI_NOFQDN -#undef NI_NOFQDN +# undef NI_NOFQDN #endif #ifdef NI_NUMERICHOST -#undef NI_NUMERICHOST +# undef NI_NUMERICHOST #endif #ifdef NI_NAMEREQD -#undef NI_NAMEREQD +# undef NI_NAMEREQD #endif #ifdef NI_NUMERICSERV -#undef NI_NUMERICSERV +# undef NI_NUMERICSERV #endif #ifdef NI_NUMERICSCOPE -#undef NI_NUMERICSCOPE +# undef NI_NUMERICSCOPE #endif #ifdef NI_DGRAM -#undef NI_DGRAM +# undef NI_DGRAM #endif #ifdef NI_MAXHOST -#undef NI_MAXHOST +# undef NI_MAXHOST #endif #ifdef NI_MAXSERV -#undef NI_MAXSERV +# undef NI_MAXSERV #endif /* @@ -154,11 +154,11 @@ extern "C" { * <netdb.h> might declares all or some of them. */ #if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO) -#define addrinfo my_addrinfo -#define gai_strerror my_gai_strerror -#define freeaddrinfo my_freeaddrinfo -#define getaddrinfo my_getaddrinfo -#define getnameinfo my_getnameinfo +# define addrinfo my_addrinfo +# define gai_strerror my_gai_strerror +# define freeaddrinfo my_freeaddrinfo +# define getaddrinfo my_getaddrinfo +# define getnameinfo my_getnameinfo #endif /* <from linux's netdb.h> */ @@ -172,17 +172,17 @@ extern "C" { 0x0020 /* Use configuration of this host to choose \ returned address type.. */ #ifdef __USE_GNU -#define AI_IDN \ - 0x0040 /* IDN encode input (assuming it is encoded \ - in the current locale's character set) \ - before looking it up. */ -#define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */ -#define AI_IDN_ALLOW_UNASSIGNED \ - 0x0100 /* Don't reject unassigned Unicode \ - code points. */ -#define AI_IDN_USE_STD3_ASCII_RULES \ - 0x0200 /* Validate strings according to \ - STD3 rules. */ +# define AI_IDN \ + 0x0040 /* IDN encode input (assuming it is encoded \ + in the current locale's character set) \ + before looking it up. */ +# define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */ +# define AI_IDN_ALLOW_UNASSIGNED \ + 0x0100 /* Don't reject unassigned Unicode \ + code points. */ +# define AI_IDN_USE_STD3_ASCII_RULES \ + 0x0200 /* Validate strings according to \ + STD3 rules. */ #endif #define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ @@ -200,12 +200,12 @@ extern "C" { #define EAI_SYSTEM -11 /* System error returned in `errno'. */ #define EAI_OVERFLOW -12 /* Argument buffer overflow. */ #ifdef __USE_GNU -#define EAI_INPROGRESS -100 /* Processing request in progress. */ -#define EAI_CANCELED -101 /* Request canceled. */ -#define EAI_NOTCANCELED -102 /* Request not canceled. */ -#define EAI_ALLDONE -103 /* All requests done. */ -#define EAI_INTR -104 /* Interrupted by a signal. */ -#define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ +# define EAI_INPROGRESS -100 /* Processing request in progress. */ +# define EAI_CANCELED -101 /* Request canceled. */ +# define EAI_NOTCANCELED -102 /* Request not canceled. */ +# define EAI_ALLDONE -103 /* All requests done. */ +# define EAI_INTR -104 /* Interrupted by a signal. */ +# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ #endif #define NI_MAXHOST 1025 @@ -217,13 +217,13 @@ extern "C" { #define NI_NAMEREQD 8 /* Don't return numeric addresses. */ #define NI_DGRAM 16 /* Look up UDP service rather than TCP. */ #ifdef __USE_GNU -#define NI_IDN 32 /* Convert name from IDN format. */ -#define NI_IDN_ALLOW_UNASSIGNED \ - 64 /* Don't reject unassigned Unicode \ - code points. */ -#define NI_IDN_USE_STD3_ASCII_RULES \ - 128 /* Validate strings according to \ - STD3 rules. */ +# define NI_IDN 32 /* Convert name from IDN format. */ +# define NI_IDN_ALLOW_UNASSIGNED \ + 64 /* Don't reject unassigned Unicode \ + code points. */ +# define NI_IDN_USE_STD3_ASCII_RULES \ + 128 /* Validate strings according to \ + STD3 rules. */ #endif /* </from linux's netdb.h> */ @@ -233,10 +233,10 @@ extern "C" { * Address families and Protocol families. */ #ifndef AF_UNSPEC -#define AF_UNSPEC AF_INET +# define AF_UNSPEC AF_INET #endif #ifndef PF_UNSPEC -#define PF_UNSPEC PF_INET +# define PF_UNSPEC PF_INET #endif /* Nexenta OS(GNU/Solaris OS) defines `struct addrinfo' in netdb.h */ diff --git a/src/gettimeofday.c b/src/gettimeofday.c index 92305e09..db292d94 100644 --- a/src/gettimeofday.c +++ b/src/gettimeofday.c @@ -27,11 +27,11 @@ #ifdef __MINGW32__ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> +# define WIN32_LEAN_AND_MEAN +# include <windows.h> /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ -#define _W32_FT_OFFSET (116444736000000000ULL) +# define _W32_FT_OFFSET (116444736000000000ULL) int __cdecl gettimeofday(struct timeval* __restrict__ tp, void* __restrict__ tzp __attribute__((unused))) diff --git a/src/gettimeofday.h b/src/gettimeofday.h index 57aa1f47..c5231e9f 100644 --- a/src/gettimeofday.h +++ b/src/gettimeofday.h @@ -37,11 +37,11 @@ #define _D_GETTIMEOFDAY_H 1 #ifdef __MINGW32__ -#undef SIZE_MAX +# undef SIZE_MAX #endif // __MINGW32__ #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif // HAVE_CONFIG_H #include <sys/time.h> diff --git a/src/libgen.c b/src/libgen.c index e08bbe62..dfdf8689 100644 --- a/src/libgen.c +++ b/src/libgen.c @@ -38,9 +38,9 @@ #include <libgen.h> #if defined(__CYGWIN__) || defined(__DJGPP__) || defined(__MINGW32__) -#define IS_PATH_SEPARATOR(c) (((c) == '/') || ((c) == '\\')) +# define IS_PATH_SEPARATOR(c) (((c) == '/') || ((c) == '\\')) #else -#define IS_PATH_SEPARATOR(c) ((c) == '/') +# define IS_PATH_SEPARATOR(c) ((c) == '/') #endif /* per http://www.scit.wlv.ac.uk/cgi-bin/mansec?3C+basename */ diff --git a/src/libssl_compat.h b/src/libssl_compat.h index 0e03bfd7..2d131069 100644 --- a/src/libssl_compat.h +++ b/src/libssl_compat.h @@ -38,9 +38,9 @@ #include <openssl/opensslv.h> #if defined(LIBRESSL_VERSION_NUMBER) -#define LIBRESSL_IN_USE 1 +# define LIBRESSL_IN_USE 1 #else // !defined(LIBRESSL_VERSION_NUMBER) -#define LIBRESSL_IN_USE 0 +# define LIBRESSL_IN_USE 0 #endif // !defined(LIBRESSL_VERSION_NUMBER) #define OPENSSL_101_API \ diff --git a/src/localtime_r.c b/src/localtime_r.c index b9ecc62f..47294558 100644 --- a/src/localtime_r.c +++ b/src/localtime_r.c @@ -37,8 +37,8 @@ #include <stdlib.h> #ifdef __MINGW32__ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> +# define WIN32_LEAN_AND_MEAN +# include <windows.h> #endif // __MINGW32__ #include "localtime_r.h" diff --git a/src/main.cc b/src/main.cc index dcd4bca0..1d4d24dd 100644 --- a/src/main.cc +++ b/src/main.cc @@ -37,7 +37,7 @@ #include <unistd.h> #ifdef __MINGW32__ -#include <shellapi.h> +# include <shellapi.h> #endif // __MINGW32__ #include <aria2/aria2.h> diff --git a/src/option_processing.cc b/src/option_processing.cc index 652a3bd3..f9891fed 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -61,7 +61,7 @@ #include "array_fun.h" #include "LogFactory.h" #ifndef HAVE_DAEMON -#include "daemon.h" +# include "daemon.h" #endif // !HAVE_DAEMON namespace aria2 { @@ -322,12 +322,12 @@ error_code::Value option_processing(Option& op, bool standalone, #if defined(__GNUC__) && defined(__APPLE__) // daemon() is deprecated on OSX since... forever. // Silence the warning for good, so that -Werror becomes feasible. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif // defined(__GNUC__) && defined(__APPLE__) const auto daemonized = daemon(0, 0); #if defined(__GNUC__) && defined(__APPLE__) -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif // defined(__GNUC__) && defined(__APPLE__) if (daemonized < 0) { diff --git a/src/strptime.c b/src/strptime.c index 0b232b93..a27e6aa5 100644 --- a/src/strptime.c +++ b/src/strptime.c @@ -31,15 +31,15 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif // HAVE_CONFIG_H #ifndef HAVE_LOCALTIME_R -#include "localtime_r.h" +# include "localtime_r.h" #endif // HAVE_LOCALTIME_R #ifndef HAVE_TIMEGM -#include "timegm.h" +# include "timegm.h" #endif // HAVE_TIMEGM #include <stddef.h> @@ -50,11 +50,11 @@ #include <stdlib.h> #ifdef HAVE_ALLOCA_H -#include <alloca.h> +# include <alloca.h> #endif // HAVE_ALLOCA_H #ifdef HAVE_MALLOC_H -#include <malloc.h> +# include <malloc.h> #endif // HAVE_MALLOC_H #include "strptime.h" diff --git a/src/timegm.h b/src/timegm.h index b34b435a..aa546100 100644 --- a/src/timegm.h +++ b/src/timegm.h @@ -35,7 +35,7 @@ #define D_TIMEGM_H #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif // HAVE_CONFIG_H #ifdef __cplusplus diff --git a/src/util.cc b/src/util.cc index be73a6e4..2e700de4 100644 --- a/src/util.cc +++ b/src/util.cc @@ -36,21 +36,21 @@ #ifdef __sun // For opensolaris, just include signal.h which includes sys/signal.h -#ifdef HAVE_SIGNAL_H -#include <signal.h> -#endif // HAVE_SIGNAL_H -#else // !__sun -#ifdef HAVE_SYS_SIGNAL_H -#include <sys/signal.h> -#endif // HAVE_SYS_SIGNAL_H -#ifdef HAVE_SIGNAL_H -#include <signal.h> -#endif // HAVE_SIGNAL_H -#endif // !__sun +# ifdef HAVE_SIGNAL_H +# include <signal.h> +# endif // HAVE_SIGNAL_H +#else // !__sun +# ifdef HAVE_SYS_SIGNAL_H +# include <sys/signal.h> +# endif // HAVE_SYS_SIGNAL_H +# ifdef HAVE_SIGNAL_H +# include <signal.h> +# endif // HAVE_SIGNAL_H +#endif // !__sun #include <sys/types.h> #ifdef HAVE_PWD_H -#include <pwd.h> +# include <pwd.h> #endif // HAVE_PWD_H #include <array> @@ -91,7 +91,7 @@ // For libc6 which doesn't define ULLONG_MAX properly because of broken limits.h #ifndef ULLONG_MAX -#define ULLONG_MAX 18446744073709551615ULL +# define ULLONG_MAX 18446744073709551615ULL #endif // ULLONG_MAX namespace aria2 { @@ -1749,12 +1749,12 @@ std::string getHomeDir() if (p) { return p; } -#ifdef HAVE_PWD_H +# ifdef HAVE_PWD_H auto pw = getpwuid(geteuid()); if (pw && pw->pw_dir) { return pw->pw_dir; } -#endif // HAVE_PWD_H +# endif // HAVE_PWD_H return A2STR::NIL; } @@ -1894,7 +1894,7 @@ void sleep(long seconds) #elif defined(HAVE_USLEEP) ::usleep(seconds * 1000000); #else -#error no sleep function is available (nanosleep?) +# error no sleep function is available (nanosleep?) #endif } @@ -1935,7 +1935,7 @@ void usleep(long microseconds) if (msec) Sleep(msec); #else -#error no usleep function is available (nanosleep?) +# error no usleep function is available (nanosleep?) #endif } diff --git a/src/util.h b/src/util.h index 2fc8ca40..bb7d8d3e 100644 --- a/src/util.h +++ b/src/util.h @@ -65,11 +65,11 @@ #include "prefs.h" #ifdef ENABLE_SSL -#include "TLSContext.h" +# include "TLSContext.h" #endif // ENABLE_SSL #ifndef HAVE_SIGACTION -#define sigset_t int +# define sigset_t int #endif // HAVE_SIGACTION namespace aria2 { @@ -105,8 +105,8 @@ std::string wCharToUtf8(const std::wstring& wsrc); // replace any backslash '\' in |src| with '/' and returns it. std::string toForwardSlash(const std::string& src); #else // !__MINGW32__ -#define utf8ToWChar(src) src -#define utf8ToNative(src) src +# define utf8ToWChar(src) src +# define utf8ToNative(src) src #endif // !__MINGW32__ namespace util { diff --git a/test/Aria2ApiTest.cc b/test/Aria2ApiTest.cc index f85f6dd1..3e899c1e 100644 --- a/test/Aria2ApiTest.cc +++ b/test/Aria2ApiTest.cc @@ -79,11 +79,11 @@ void Aria2ApiTest::testAddMetalink() KeyVals options; #ifdef ENABLE_METALINK CPPUNIT_ASSERT_EQUAL(0, addMetalink(session_, &gids, metalinkPath, options)); -#ifdef ENABLE_BITTORRENT +# ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((size_t)2, gids.size()); -#else // !ENABLE_BITTORRENT +# else // !ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((size_t)1, gids.size()); -#endif // !ENABLE_BITTORRENT +# endif // !ENABLE_BITTORRENT gids.clear(); options.push_back(KeyVals::value_type("file-allocation", "foo")); diff --git a/test/DefaultBtProgressInfoFileTest.cc b/test/DefaultBtProgressInfoFileTest.cc index df4c7e44..e22fb188 100644 --- a/test/DefaultBtProgressInfoFileTest.cc +++ b/test/DefaultBtProgressInfoFileTest.cc @@ -14,9 +14,9 @@ #include "FileEntry.h" #include "array_fun.h" #ifdef ENABLE_BITTORRENT -#include "MockPeerStorage.h" -#include "BtRuntime.h" -#include "bittorrent_helper.h" +# include "MockPeerStorage.h" +# include "BtRuntime.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 { @@ -27,10 +27,10 @@ class DefaultBtProgressInfoFileTest : public CppUnit::TestFixture { #ifdef ENABLE_BITTORRENT CPPUNIT_TEST(testSave); CPPUNIT_TEST(testLoad); -#ifndef WORDS_BIGENDIAN +# ifndef WORDS_BIGENDIAN CPPUNIT_TEST(testLoad_compat); -#endif // !WORDS_BIGENDIAN -#endif // ENABLE_BITTORRENT +# endif // !WORDS_BIGENDIAN +#endif // ENABLE_BITTORRENT CPPUNIT_TEST(testSave_nonBt); CPPUNIT_TEST(testLoad_nonBt); #ifndef WORDS_BIGENDIAN @@ -89,10 +89,10 @@ public: #ifdef ENABLE_BITTORRENT void testSave(); void testLoad(); -#ifndef WORDS_BIGENDIAN +# ifndef WORDS_BIGENDIAN void testLoad_compat(); -#endif // !WORDS_BIGENDIAN -#endif // ENABLE_BITTORRENT +# endif // !WORDS_BIGENDIAN +#endif // ENABLE_BITTORRENT void testSave_nonBt(); void testLoad_nonBt(); #ifndef WORDS_BIGENDIAN @@ -111,7 +111,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DefaultBtProgressInfoFileTest); // Because load.aria2 is made for little endian systems, exclude // testLoad_compat() for big endian systems. -#ifndef WORDS_BIGENDIAN +# ifndef WORDS_BIGENDIAN void DefaultBtProgressInfoFileTest::testLoad_compat() { initializeMembers(1_k, 80_k); @@ -159,7 +159,7 @@ void DefaultBtProgressInfoFileTest::testLoad_compat() CPPUNIT_ASSERT_EQUAL((size_t)2, piece2->getIndex()); CPPUNIT_ASSERT_EQUAL((int64_t)512, piece2->getLength()); } -#endif // !WORDS_BIGENDIAN +# endif // !WORDS_BIGENDIAN void DefaultBtProgressInfoFileTest::testLoad() { diff --git a/test/DownloadHelperTest.cc b/test/DownloadHelperTest.cc index e7da8177..6a8ab8d2 100644 --- a/test/DownloadHelperTest.cc +++ b/test/DownloadHelperTest.cc @@ -15,7 +15,7 @@ #include "util.h" #include "FileEntry.h" #ifdef ENABLE_BITTORRENT -#include "bittorrent_helper.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 { @@ -215,11 +215,11 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink() // group1: http://alpha/file, ... // group2-7: 6 file entry in Metalink and 1 torrent file download -#ifdef ENABLE_BITTORRENT +# ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((size_t)7, result.size()); -#else // !ENABLE_BITTORRENT +# else // !ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((size_t)6, result.size()); -#endif // !ENABLE_BITTORRENT +# endif // !ENABLE_BITTORRENT std::shared_ptr<RequestGroup> group = result[0]; auto xuris = group->getDownloadContext()->getFirstFileEntry()->getUris(); @@ -349,11 +349,11 @@ void DownloadHelperTest::testCreateRequestGroupForMetalink() createRequestGroupForMetalink(result, option_); -#ifdef ENABLE_BITTORRENT +# ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((size_t)6, result.size()); -#else // !ENABLE_BITTORRENT +# else // !ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((size_t)5, result.size()); -#endif // !ENABLE_BITTORRENT +# endif // !ENABLE_BITTORRENT std::shared_ptr<RequestGroup> group = result[0]; auto uris = group->getDownloadContext()->getFirstFileEntry()->getUris(); std::sort(uris.begin(), uris.end()); diff --git a/test/Metalink2RequestGroupTest.cc b/test/Metalink2RequestGroupTest.cc index b370b705..47e1e213 100644 --- a/test/Metalink2RequestGroupTest.cc +++ b/test/Metalink2RequestGroupTest.cc @@ -209,7 +209,7 @@ void Metalink2RequestGroupTest::testGenerate_groupByMetaurl() void Metalink2RequestGroupTest::testGenerate_dosDirTraversal() { #ifdef __MINGW32__ -#ifdef ENABLE_BITTORRENT +# ifdef ENABLE_BITTORRENT std::vector<std::shared_ptr<RequestGroup>> groups; option_->put(PREF_DIR, "/tmp"); Metalink2RequestGroup().generate( @@ -228,8 +228,8 @@ void Metalink2RequestGroupTest::testGenerate_dosDirTraversal() file = rg->getDownloadContext()->getFileEntries()[1]; CPPUNIT_ASSERT_EQUAL(std::string("/tmp/..%5C..%5Cfile2.ext"), file->getPath()); -#endif // ENABLE_BITTORRENT -#endif // __MINGW32__ +# endif // ENABLE_BITTORRENT +#endif // __MINGW32__ } } // namespace aria2 diff --git a/test/MockPeerStorage.h b/test/MockPeerStorage.h index f5604599..d68715dd 100644 --- a/test/MockPeerStorage.h +++ b/test/MockPeerStorage.h @@ -1,11 +1,11 @@ #ifndef D_MOCK_PEER_STORAGE_H -#define D_MOCK_PEER_STORAGE_H +# define D_MOCK_PEER_STORAGE_H -#include "PeerStorage.h" +# include "PeerStorage.h" -#include <algorithm> +# include <algorithm> -#include "Peer.h" +# include "Peer.h" namespace aria2 { diff --git a/test/RpcHelperTest.cc b/test/RpcHelperTest.cc index 1ee601de..ba40e526 100644 --- a/test/RpcHelperTest.cc +++ b/test/RpcHelperTest.cc @@ -5,7 +5,7 @@ #include "RpcRequest.h" #include "RecoverableException.h" #ifdef ENABLE_XML_RPC -#include "XmlRpcRequestParserStateMachine.h" +# include "XmlRpcRequestParserStateMachine.h" #endif // ENABLE_XML_RPC namespace aria2 { diff --git a/test/RpcMethodTest.cc b/test/RpcMethodTest.cc index dbdccf74..44bae5fe 100644 --- a/test/RpcMethodTest.cc +++ b/test/RpcMethodTest.cc @@ -22,9 +22,9 @@ #include "FileEntry.h" #include "RpcMethodFactory.h" #ifdef ENABLE_BITTORRENT -#include "BtRegistry.h" -#include "BtRuntime.h" -#include "bittorrent_helper.h" +# include "BtRegistry.h" +# include "BtRuntime.h" +# include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT namespace aria2 {