From cb5c401a93c764a732c06d1b45edc02787700dbb Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Wed, 10 Jan 2018 22:05:57 +0100 Subject: Cleanup section sharing for tests in cabal file --- .../update-cabal-common-section-instantiations.awk | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 scripts/update-cabal-common-section-instantiations.awk (limited to 'scripts') 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; + } +} -- cgit v1.2.3