diff --git a/.editorconfig b/.editorconfig index b8a739d..af3a9c5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,5 +12,8 @@ indent_size = 4 [*.md] indent_size = 2 +[.gitmodules] +indent_style = tab + [{Makefile,*.mak}] indent_style = tab diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8afe3ee --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "perl-squasher"] + path = util/perl-squasher + url = https://codeberg.org/h3xx/perl-squasher.git + branch = main diff --git a/make-allinone.sh b/make-allinone.sh index 4fe10d9..8f3e79a 100755 --- a/make-allinone.sh +++ b/make-allinone.sh @@ -5,7 +5,7 @@ OUT=$WORKDIR/simplify_static_dir.pl echo "Outputting to $OUT" >&2 shopt -s globstar -"$WORKDIR/util/squash" \ +"$WORKDIR/util/perl-squasher/squash" \ "$WORKDIR/simplify_static_dir-main.pl" \ "$WORKDIR"/lib/**/*.pm \ > "$OUT" diff --git a/util/perl-squasher b/util/perl-squasher new file mode 160000 index 0000000..9d414ab --- /dev/null +++ b/util/perl-squasher @@ -0,0 +1 @@ +Subproject commit 9d414ab346caed6035db5a0512d6c89912a8826c diff --git a/util/squash b/util/squash deleted file mode 100755 index c0bd4af..0000000 --- a/util/squash +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/perl - -# Squashes together the parts of the app into the single script. -# (Adapted from the script that squashes App::Ack - see https://github.com/beyondgrep/ack3) -use warnings; -use strict; - -my $code; -for my $arg (@ARGV) { - my $filename = $arg; - if ($arg =~ /::/) { - my $key = "$arg.pm"; - $key =~ s{::}{/}g; - $filename = $INC{$key} or die "Can't find the file for $arg"; - } - - warn "Reading $filename\n"; - open my $fh, '<', $filename or die "Can't open $filename: $!"; - my $in_pod = 0; - my $in_section = ''; - my $ignore_lines = 0; - my $empty_lines = 0; - while (<$fh>) { - if (/#.*:squash-ignore-start:$/) { - $in_section = 'ignore'; - $ignore_lines = 1; - } elsif (/#.*:squash-ignore-end:$/) { - $in_section = ''; - $ignore_lines = 1; - } - if ($ignore_lines > 0) { - $ignore_lines--; - next; - } - - if ($in_section eq 'ignore') { - $empty_lines = 0 unless /^$/; - $code .= $_; - next; - } - - # Remove repeated newlines between paragraphs - # (Provided of course we're not in an 'ignore' section) - if (/^$/) { - ++$empty_lines; - if ($empty_lines > 1) { - next; - } - } else { - $empty_lines = 0; - } - - if (/#.*:squash-remove-start:$/) { - $in_section = 'remove'; - next; - } elsif (/#.*:squash-remove-end:$/) { - $in_section = ''; - next; - } - next if $in_section eq 'remove'; - next if /#.*:squash-remove-line:$/; - - next if /^\s*1;$/; - - if ($filename =~ /\.pm$/) { - # See if we're in module POD blocks - if (/^=(\w+)/) { - $in_pod = ($1 ne 'cut'); - next; - } - elsif ($in_pod) { - next; - } - next if /^# vi:/; - } - - # Remove Perl::Critic comments. - # I'd like to remove all comments, but this is a start - s{\s*##.+critic.*}{}; - $code .= $_; - } - - # Warn if there were unterminated :squash-*: sections - warn "$filename: Unterminated :squash-$in_section-start: section" if $in_section; - - close $fh; -} - -print $code; - -exit 0;