aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2018-01-10 22:05:57 +0100
committerDaniel Gröber <dxld@darkboxed.org>2018-01-18 14:10:26 +0100
commitcb5c401a93c764a732c06d1b45edc02787700dbb (patch)
treeff787b2c21cb5c68b462201796a5a59aa258c2ec /scripts
parentbc60a1bfdf223fef44ee9c3a60686160af909906 (diff)
Cleanup section sharing for tests in cabal file
Diffstat (limited to 'scripts')
-rw-r--r--scripts/update-cabal-common-section-instantiations.awk34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/update-cabal-common-section-instantiations.awk b/scripts/update-cabal-common-section-instantiations.awk
new file mode 100644
index 0000000..0bfacae
--- /dev/null
+++ b/scripts/update-cabal-common-section-instantiations.awk
@@ -0,0 +1,34 @@
+BEGIN {
+ delete sections;
+ section="";
+ ignoring=0;
+}
+
+/^[[:space:]]*$/ {
+ section="";
+ ignoring=0;
+}
+
+{
+ if(section) {
+ tmp = sections[section];
+ sections[section] = tmp (tmp ? RS : "") $0;
+ }
+}
+
+/^[[:space:]]*-- *Common/ {
+ section = $3
+}
+
+/^[[:space:]]*-- *Instantiate *common/ {
+ ignoring=1
+
+ print $0;
+ print sections[$4];
+}
+
+{
+ if(!ignoring) {
+ print $0;
+ }
+}