From: Francesco Chemolli Date: Fri, 24 Aug 2012 09:57:00 +0000 (+0200) Subject: Prep work for automatic sorting of include directives. X-Git-Tag: sourceformat-review-1~64^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d41e53a14fb1c19b547d1cd48b3a3da3d61490b;p=thirdparty%2Fsquid.git Prep work for automatic sorting of include directives. Automatic sorting of include files reveals some indirect inclusions, which would break the build. scripts/sort-includes.pl is the tool to do the automatic header include order sorting. The other changes in this set fix the issues which that be introduced by running the sorting. --- diff --git a/include/snmp_msg.h b/include/snmp_msg.h index 414d18f522..b4fbe23ba5 100644 --- a/include/snmp_msg.h +++ b/include/snmp_msg.h @@ -30,6 +30,8 @@ * **********************************************************************/ +#include "snmp_pdu.h" + #define SNMP_VERSION_1 0 /* RFC 1157 */ #define SNMP_VERSION_2 1 /* RFC 1901 */ diff --git a/scripts/sort-includes.pl b/scripts/sort-includes.pl new file mode 100644 index 0000000000..35c0d98f11 --- /dev/null +++ b/scripts/sort-includes.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl +# +# AUTHOR: Francesco Chemolli +# +# Part of the Squid Web Cache project, licensed for use and distribution +# under the terms of the Squid Web Cache; please refer to the files COPYING +# and COPYRIGHT. +# +# +# USAGE: sort-includes.pl filename.cc >filename.cc.sorted +# +# This tool helps to sort the #include directives in a c or c++ source file +# according to the Squid Coding guidelines. +# +# The output of the tool is a source file where each block of consecutive +# include directives for project-specific files (#include "header.h") +# is sorted with this specification: squid.h (if present) is alwasy first, +# then the other directives are sorted in case-insensitive alphabetical order. +# +# Suggested usage: +# for file in $(find . -name \*.cc); do /full/path/to/sort-includes.pl $file >$file.sorted; mv $file.sorted $file; done + +use strict; +use warnings; +my @acc=(); #if empty, we're not accumulating +while (<>) { + if (m!^#include "!) { + if (m!squid.h!) { + print; + } else { + push @acc,$_; + } + } else { + &dump_acc; + print; + } +} +&dump_acc; + +sub dump_acc { + return unless @acc; + print sort {lc($a) cmp lc($b)} @acc; + @acc=(); +} diff --git a/snmplib/parse.c b/snmplib/parse.c index a9316d1490..b1792ff163 100644 --- a/snmplib/parse.c +++ b/snmplib/parse.c @@ -24,6 +24,13 @@ SOFTWARE. * parse.c */ #include "squid.h" +#include "asn1.h" +#include "cache_snmp.h" +#include "parse.h" +#include "snmp_debug.h" +#include "snmp_pdu.h" +#include "snmp_vars.h" +#include "util.h" #include @@ -78,14 +85,7 @@ SOFTWARE. #include #endif -#include "asn1.h" -#include "snmp_vars.h" -#include "parse.h" -#include "snmp_debug.h" -#include "util.h" - -#include "cache_snmp.h" /* * This is one element of an object identifier with either an integer subidentifier, * or a textual string label, or both. diff --git a/src/DescriptorSet.h b/src/DescriptorSet.h index 302529b3f9..c1e710d945 100644 --- a/src/DescriptorSet.h +++ b/src/DescriptorSet.h @@ -1,6 +1,7 @@ #ifndef SQUID_DESCRIPTOR_SET_H #define SQUID_DESCRIPTOR_SET_H +#include /** \ingroup Comm diff --git a/src/DiskIO/DiskDaemon/DiskdFile.cc b/src/DiskIO/DiskDaemon/DiskdFile.cc index 22bccd176f..be11f34f2f 100644 --- a/src/DiskIO/DiskDaemon/DiskdFile.cc +++ b/src/DiskIO/DiskDaemon/DiskdFile.cc @@ -34,20 +34,19 @@ */ #include "squid.h" - -#include -#include -#include - #include "DiskdFile.h" #include "ConfigOption.h" #include "diomsg.h" - #include "DiskdIOStrategy.h" #include "DiskIO/IORequestor.h" #include "DiskIO/ReadRequest.h" #include "DiskIO/WriteRequest.h" #include "StatCounters.h" + +#include +#include +#include + CBDATA_CLASS_INIT(DiskdFile); void * diff --git a/src/LeakFinder.cc b/src/LeakFinder.cc index b889e88d1e..e245430bf3 100644 --- a/src/LeakFinder.cc +++ b/src/LeakFinder.cc @@ -37,11 +37,13 @@ */ #include "squid.h" + +#if USE_LEAKFINDER + #include "LeakFinder.h" #include "Store.h" #include "SquidTime.h" -#if USE_LEAKFINDER /* ========================================================================= */ LeakFinderPtr::LeakFinderPtr(void *p , const char *f, const int l) : diff --git a/src/acl/HttpStatus.cc b/src/acl/HttpStatus.cc index 05fc730fc7..03cb5d76b8 100644 --- a/src/acl/HttpStatus.cc +++ b/src/acl/HttpStatus.cc @@ -35,7 +35,6 @@ */ #include "squid.h" - #include "acl/HttpStatus.h" #include "acl/FilledChecklist.h" #include "Debug.h" diff --git a/src/adaptation/AccessRule.cc b/src/adaptation/AccessRule.cc index 5dc1861144..8c9b53e816 100644 --- a/src/adaptation/AccessRule.cc +++ b/src/adaptation/AccessRule.cc @@ -1,6 +1,5 @@ #include "squid.h" #include "structs.h" - #include "ConfigParser.h" #include "acl/Gadgets.h" #include "adaptation/AccessRule.h" diff --git a/src/adaptation/ecap/Config.cc b/src/adaptation/ecap/Config.cc index e6cd269cae..d8b6bf77c7 100644 --- a/src/adaptation/ecap/Config.cc +++ b/src/adaptation/ecap/Config.cc @@ -3,7 +3,6 @@ * DEBUG: section 93 eCAP Interface */ #include "squid.h" - #include "adaptation/ecap/Host.h" #include "adaptation/ecap/ServiceRep.h" #include "adaptation/ecap/Config.h" diff --git a/src/adaptation/icap/Config.cc b/src/adaptation/icap/Config.cc index 8555301653..6bed045743 100644 --- a/src/adaptation/icap/Config.cc +++ b/src/adaptation/icap/Config.cc @@ -33,7 +33,6 @@ */ #include "squid.h" - #include "ConfigParser.h" #include "Store.h" #include "Array.h" diff --git a/src/client_side_request.cci b/src/client_side_request.cci index ddbbc078ff..5e0a69f4c0 100644 --- a/src/client_side_request.cci +++ b/src/client_side_request.cci @@ -34,6 +34,8 @@ * Copyright (c) 2003, Robert Collins */ +#include "Store.h" + StoreEntry * ClientHttpRequest::storeEntry() const { diff --git a/src/comm/IoCallback.h b/src/comm/IoCallback.h index ab21066154..116d3497cd 100644 --- a/src/comm/IoCallback.h +++ b/src/comm/IoCallback.h @@ -2,8 +2,9 @@ #define _SQUID_COMM_IOCALLBACK_H #include "base/AsyncCall.h" -#include "comm_err_t.h" #include "comm/forward.h" +#include "comm_err_t.h" +#include "typedefs.h" namespace Comm { diff --git a/src/esi/Module.cc b/src/esi/Module.cc index 71b9be035e..b8269342a3 100644 --- a/src/esi/Module.cc +++ b/src/esi/Module.cc @@ -2,7 +2,9 @@ #include "esi/Module.h" #include "esi/CustomParser.h" #include "esi/Libxml2Parser.h" -#include "esi/ExpatParser.h" /* must follow esi/Libxml2Parser.h */ +/* include for esi/ExpatParser.h must follow esi/Libxml2Parser.h */ +/* do not remove this comment, as it acts as barrier for the autmatic sorting */ +#include "esi/ExpatParser.h" static ESIParser::Register *prCustom = 0; #if HAVE_LIBXML2 diff --git a/src/fs/diskd/StoreFSdiskd.cc b/src/fs/diskd/StoreFSdiskd.cc index 01d20c87c8..16ce6df6de 100644 --- a/src/fs/diskd/StoreFSdiskd.cc +++ b/src/fs/diskd/StoreFSdiskd.cc @@ -36,11 +36,6 @@ /* TODO: remove this file as unused */ #include "squid.h" -#if 0 -#include "StoreFileSystem.h" -#include "DiskIO/DiskIOModule.h" -#endif - #include "fs/ufs/StoreFSufs.h" #include "fs/ufs/UFSSwapDir.h" diff --git a/src/ipc/ReadWriteLock.cc b/src/ipc/ReadWriteLock.cc index f319264f88..981a85447d 100644 --- a/src/ipc/ReadWriteLock.cc +++ b/src/ipc/ReadWriteLock.cc @@ -5,7 +5,6 @@ */ #include "squid.h" - #include "Store.h" #include "ipc/ReadWriteLock.h" diff --git a/src/ipc/SharedListen.cc b/src/ipc/SharedListen.cc index eaedc02dc0..a90e02f143 100644 --- a/src/ipc/SharedListen.cc +++ b/src/ipc/SharedListen.cc @@ -6,7 +6,6 @@ */ #include "squid.h" -#include #include "comm.h" #include "base/TextException.h" #include "comm/Connection.h" @@ -19,6 +18,8 @@ #include "ipc/SharedListen.h" #include "protos.h" +#include + /// holds information necessary to handle JoinListen response class PendingOpenRequest { diff --git a/src/ipc/StoreMap.cc b/src/ipc/StoreMap.cc index 22185ed0f9..a0b999af49 100644 --- a/src/ipc/StoreMap.cc +++ b/src/ipc/StoreMap.cc @@ -5,7 +5,6 @@ */ #include "squid.h" - #include "protos.h" #include "Store.h" #include "ipc/StoreMap.h" diff --git a/src/ipc/TypedMsgHdr.cc b/src/ipc/TypedMsgHdr.cc index bb653742cd..74e7181768 100644 --- a/src/ipc/TypedMsgHdr.cc +++ b/src/ipc/TypedMsgHdr.cc @@ -7,11 +7,12 @@ #include "squid.h" -#include #include "protos.h" #include "base/TextException.h" #include "ipc/TypedMsgHdr.h" +#include + Ipc::TypedMsgHdr::TypedMsgHdr() { xmemset(this, 0, sizeof(*this)); diff --git a/src/log/access_log.cc b/src/log/access_log.cc index b30d9eefd4..997dc477d1 100644 --- a/src/log/access_log.cc +++ b/src/log/access_log.cc @@ -35,18 +35,11 @@ #include "squid.h" #include "AccessLogEntry.h" - -// Store.h Required by configuration directives parsing/dumping only #include "Store.h" - #include "errorpage.h" #include "err_detail_type.h" #include "acl/Checklist.h" #include "errorpage.h" -#if USE_SQUID_EUI -#include "eui/Eui48.h" -#include "eui/Eui64.h" -#endif #include "format/Token.h" #include "globals.h" #include "hier_code.h" @@ -60,6 +53,11 @@ #include "rfc1738.h" #include "SquidTime.h" +#if USE_SQUID_EUI +#include "eui/Eui48.h" +#include "eui/Eui64.h" +#endif + #if HEADERS_LOG static Logfile *headerslog = NULL; #endif diff --git a/src/ssl/ErrorDetailManager.h b/src/ssl/ErrorDetailManager.h index 1a0be59261..334c80f46c 100644 --- a/src/ssl/ErrorDetailManager.h +++ b/src/ssl/ErrorDetailManager.h @@ -1,8 +1,11 @@ #ifndef _SQUID_SSL_ERRORDETAILMANAGER_H #define _SQUID_SSL_ERRORDETAILMANAGER_H -#include "ssl/support.h" #include "ssl/gadgets.h" +#include "ssl/support.h" +#include "RefCount.h" +#include "SquidString.h" + #if HAVE_MAP #include #endif @@ -10,6 +13,8 @@ #include #endif +class HttpRequest; + namespace Ssl { diff --git a/src/tests/testCacheManager.cc b/src/tests/testCacheManager.cc index 702a88fb69..308ba35431 100644 --- a/src/tests/testCacheManager.cc +++ b/src/tests/testCacheManager.cc @@ -1,14 +1,13 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" -#include #include "mgr/Action.h" - #include "Mem.h" #include "testCacheManager.h" #include "CacheManager.h" #include "Store.h" +#include CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager ); diff --git a/src/tests/testConfigParser.cc b/src/tests/testConfigParser.cc index b17fd7a4d8..a3a58fe251 100644 --- a/src/tests/testConfigParser.cc +++ b/src/tests/testConfigParser.cc @@ -1,6 +1,5 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" - #include "testConfigParser.h" #include "SquidString.h" #include "Mem.h" diff --git a/src/tests/testDiskIO.cc b/src/tests/testDiskIO.cc index b06b5a1aa8..32ed5cdccf 100644 --- a/src/tests/testDiskIO.cc +++ b/src/tests/testDiskIO.cc @@ -5,9 +5,6 @@ #include "Store.h" #include "SwapDir.h" #include "DiskIO/DiskIOModule.h" -#if 0 // AYJ: COSS in Squid-3 is disabled. -#include "fs/coss/CossSwapDir.h" -#endif #include "Mem.h" #include "MemObject.h" #include "HttpHeader.h" @@ -15,6 +12,11 @@ #include "StoreFileSystem.h" #include "testStoreSupport.h" +#if 0 +// AYJ: COSS in Squid-3 is disabled. +#include "fs/coss/CossSwapDir.h" +#endif + #if HAVE_STDEXCEPT #include #endif diff --git a/src/tests/testStoreController.cc b/src/tests/testStoreController.cc index d1e7bd411e..5ee8b6d54d 100644 --- a/src/tests/testStoreController.cc +++ b/src/tests/testStoreController.cc @@ -1,7 +1,6 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" - #include "testStoreController.h" #include "Store.h" #include "SwapDir.h" diff --git a/src/tests/testStoreHashIndex.cc b/src/tests/testStoreHashIndex.cc index 3a2169ff4f..a6ed69f848 100644 --- a/src/tests/testStoreHashIndex.cc +++ b/src/tests/testStoreHashIndex.cc @@ -1,7 +1,6 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" - #include "testStoreHashIndex.h" #include "Store.h" #include "SwapDir.h" diff --git a/src/tests/testString.cc b/src/tests/testString.cc index 32d3e9a6c6..0ca8cb01b4 100644 --- a/src/tests/testString.cc +++ b/src/tests/testString.cc @@ -1,6 +1,6 @@ #define SQUID_UNIT_TEST 1 -#include "squid.h" +#include "squid.h" #include "testString.h" #include "SquidString.h" #include "Mem.h"