From 34d4e73d72c20f0994b57e3e7092d76a2e39d679 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 5 Feb 2016 18:40:14 +0000 Subject: [PATCH] commitid.scad.pl: refactor gentextmodule_plusq as prep for T (three line) --- commitid.scad.pl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/commitid.scad.pl b/commitid.scad.pl index c09ce6a..dc589fe 100755 --- a/commitid.scad.pl +++ b/commitid.scad.pl @@ -269,16 +269,21 @@ sub ljustt ($$$) { # always includes $suffix return sprintf "%-${sz}.${sz}s%s", $whole, $suffix; } +sub gentextmodule_q ($$$) { + my ($form, $s, $lines) = @_; + $gtm_demo_j++; + my $l = length $s; + return if $l % $lines; + my $e = $l/$lines; + return if $e < 2; + $gtm_demo_j--; + gentextmodule($form, $s =~ m/.{$e}/g); +} + sub gentextmodule_plusq ($$) { my ($form, $s) = @_; - my $l = length $s; gentextmodule($form, $s); - if (!($l & 1) && $l>=4) { - my $e = $l/2; - gentextmodule("${form}S", $s =~ m/.{$e}/g); - } else { - $gtm_demo_j++; - } + gentextmodule_q("${form}S", $s, 2); } our @gcmd; -- 2.30.2