------------------------------------------------------------ revno: 14014 revision-id: squid3@treenet.co.nz-20160330132534-cy3jwop0nsf1406o parent: squid3@treenet.co.nz-20160330113827-rx8t2a8xr2btyxii author: Alex Rousskov committer: Amos Jeffries branch nick: 3.5 timestamp: Thu 2016-03-31 02:25:34 +1300 message: Cleanup: Automatically remove duplicated #include lines. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20160330132534-cy3jwop0nsf1406o # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: bb4be35a385ae5ba409d6b18e98dd6d665b88e5f # timestamp: 2016-03-30 13:48:29 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20160330113827-\ # rx8t2a8xr2btyxii # # Begin patch === modified file 'scripts/sort-includes.pl' --- scripts/sort-includes.pl 2016-01-01 00:14:27 +0000 +++ scripts/sort-includes.pl 2016-03-30 13:25:34 +0000 @@ -7,8 +7,6 @@ ## Please see the COPYING and CONTRIBUTORS files for details. ## -# AUTHOR: Francesco Chemolli -# # USAGE: sort-includes.pl filename.cc >filename.cc.sorted # # This tool helps to sort the #include directives in a c or c++ source file @@ -24,23 +22,34 @@ use strict; use warnings; -my @acc=(); #if empty, we're not accumulating + +my %Seen = (); # preprocessor #include lines, indexed by file name + while (<>) { - if (m!^#include "!) { - if (m!squid.h!) { - print; - } else { - push @acc,$_; + if (/^\s*#\s*include\s*"(.+?)"/) { + my $fname = $1; + # skip repeated file names that have identical #include lines + if (defined $Seen{$fname}) { + next if $Seen{$fname} eq $_; + warn("$ARGV:$.: Warning: inconsistent $fname #include lines:\n"); + warn(" $Seen{$fname}"); + warn(" $_"); + # fall through to preserve every unique #include line } + $Seen{$fname} = $_; } else { - &dump_acc; + &dumpSeen(); print; } } -&dump_acc; +&dumpSeen(); -sub dump_acc { - return unless @acc; - print sort {lc($a) cmp lc($b)} @acc; - @acc=(); +sub dumpSeen { + my $alwaysFirst = 'squid.h'; + if (defined $Seen{$alwaysFirst}) { + print $Seen{$alwaysFirst}; + delete $Seen{$alwaysFirst}; + } + print sort { lc($a) cmp lc($b) } values %Seen; + %Seen = (); } === modified file 'src/acl/Asn.cc' --- src/acl/Asn.cc 2016-01-01 00:14:27 +0000 +++ src/acl/Asn.cc 2016-03-30 13:25:34 +0000 @@ -26,7 +26,6 @@ #include "SquidConfig.h" #include "Store.h" #include "StoreClient.h" -#include "StoreClient.h" #define WHOIS_PORT 43 #define AS_REQBUF_SZ 4096 === modified file 'src/client_side_reply.cc' --- src/client_side_reply.cc 2016-01-01 00:14:27 +0000 +++ src/client_side_reply.cc 2016-03-30 13:25:34 +0000 @@ -20,7 +20,6 @@ #include "format/Token.h" #include "FwdState.h" #include "globals.h" -#include "globals.h" #include "HttpHeaderTools.h" #include "HttpReply.h" #include "HttpRequest.h" === modified file 'src/log/access_log.cc' --- src/log/access_log.cc 2016-01-01 00:14:27 +0000 +++ src/log/access_log.cc 2016-03-30 13:25:34 +0000 @@ -17,8 +17,6 @@ #include "CachePeer.h" #include "err_detail_type.h" #include "errorpage.h" -#include "errorpage.h" -#include "errorpage.h" #include "format/Token.h" #include "globals.h" #include "hier_code.h"