--- /dev/null
+#!/usr/bin/perl
+#
+## Copyright (C) 1996-2020 The Squid Software Foundation and contributors
+##
+## Squid software is distributed under GPLv2+ license and includes
+## contributions from numerous individuals and organizations.
+## Please see the COPYING and CONTRIBUTORS files for details.
+##
+
+use strict;
+use warnings;
+
+my $current_source_section='';
+while (<>) {
+ chomp;
+ if (m!^#!) {
+ print "$_\n";
+ next;
+ }
+ # accumulate files and prep for sorting
+ my %files = ();
+ if (/^(\S+_SOURCES)\s*(\+?=)\s*(.*[^\\])$/ ) {
+ my @parts = split(/\s+/, $3);
+ if ($#parts == 0) { # one file only specified on same line as SOURCES
+ print "$1 $2 $3\n";
+ next;
+ }
+ foreach my $file (@parts) {
+ &addfile(\%files, $file, $1);
+ }
+ print "$1 $2 \\\n";
+ &print_files(\%files);
+ next;
+ }
+ if (/^(\S+_SOURCES)\s*(\+?=)\s*(.*?)\s*\\$/) {
+ $current_source_section=$1;
+ print "$1 $2 \\\n";
+ if (defined $3) {
+ foreach my $file (split(/\s+/, $3)) {
+ &addfile(\%files, $file, $current_source_section);
+ }
+ }
+ } else {
+ print "$_\n";
+ next;
+ }
+ while (<>) {
+ chomp;
+ m!^\s+(.*?)\s*\\?$!;
+ foreach my $file (split(/\s+/, $1)) {
+ &addfile(\%files, $file, $current_source_section) if (length $file);
+ }
+ if (! /\\$/ ) { # last line in the list
+ &print_files(\%files);
+ last;
+ }
+ }
+}
+
+exit 0;
+
+# arg: ref to hash to add the file to, filename
+sub addfile
+{
+ my $files = shift @_;
+ my $fn = shift @_;
+ my $current_source_section = shift @_;
+
+ $fn =~ m!\s*(tests/stub_|tests/test)?(\S+)(\s+\\\s*)?$! || die "no parse";
+ my $prefix = (defined $1) ? $1 : '';
+ my $filename = (defined $2) ? $2 : '';
+
+ print STDERR "WARNING: duplicate $prefix$filename ".
+ "detected in $current_source_section\n"
+ if exists($files->{"$filename.$prefix"});
+
+ $files->{"$filename.$prefix"}="$prefix$filename";
+}
+
+# arg is hash ref, print values in order of key
+sub print_files
+{
+ my %files=%{$_[0]};
+ my @q=();
+ foreach my $k (sort keys %files) {
+ push @q, "\t".$files{$k};
+ }
+ print join(" \\\n", @q)."\n";
+}
updateIfChanged "$source" "$new" "by $script"
}
+# updates the given source file using the given script(s)
+applyPluginsTo ()
+{
+ source="$1"
+ shift
+
+ for script in `git ls-files "$@"`; do
+ run_ applyPlugin $script $source || return
+ done
+}
+
srcFormat ()
{
#
#
# Code Style formatting maintenance
#
- for SCRIPT in `git ls-files scripts/maintenance/`; do
- run_ applyPlugin ${SCRIPT} "${FILENAME}" || return
- done
+ applyPluginsTo ${FILENAME} scripts/maintenance/ || return
if test "${ASVER}"; then
./scripts/formater.pl ${FILENAME}
if test -e $FILENAME -a -e "$FILENAME.astylebak"; then
chmod 755 ${FILENAME}
;;
- Makefile.am)
-
- perl -p -e 's/@([A-Z0-9_]+)@/\$($1)/g' <${FILENAME} >${FILENAME}.styled
- mv ${FILENAME}.styled ${FILENAME}
+ *.am)
+ applyPluginsTo ${FILENAME} scripts/format-makefile-am.pl || return
;;
ChangeLog|CREDITS|CONTRIBUTORS|COPYING|*.list|*.png|*.po|*.pot|rfcs/|*.txt|test-suite/squidconf/empty|.bzrignore)