From: Ian Jackson Date: Fri, 5 Feb 2016 19:59:17 +0000 (+0000) Subject: commitid.scad.pl: Introduce genform() (nfc) X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=reprap-play.git;a=commitdiff_plain;h=d7c014f47126ae74aec94aa004f46b459bb1facd commitid.scad.pl: Introduce genform() (nfc) --- diff --git a/commitid.scad.pl b/commitid.scad.pl index 6838365..3c409f5 100755 --- a/commitid.scad.pl +++ b/commitid.scad.pl @@ -267,7 +267,12 @@ sub ljustt ($$;$) { return sprintf "%-${sz}.${sz}s%s", $whole, $suffix; } -sub gentextmodule_q ($$$) { +sub genform ($@) { + my ($form, @lines) = @_; + gentextmodule($form, @lines); +} + +sub genform_q ($$$) { my ($form, $s, $lines) = @_; $gtm_demo_j++; my $l = length $s; @@ -275,14 +280,14 @@ sub gentextmodule_q ($$$) { my $e = $l/$lines; return if $e < 2; $gtm_demo_j--; - gentextmodule($form, $s =~ m/.{$e}/g); + genform($form, $s =~ m/.{$e}/g); } -sub gentextmodule_plusq ($$) { +sub genform_plusq ($$) { my ($form, $s) = @_; - gentextmodule($form, $s); - gentextmodule_q("${form}S", $s, 2); - gentextmodule_q("${form}T", $s, 3); + genform($form, $s); + genform_q("${form}S", $s, 2); + genform_q("${form}T", $s, 3); } our @gcmd; @@ -341,22 +346,22 @@ sub do_git () { foreach my $sz (2..10) { gentextmodule_demo_start_batch(); - gentextmodule_plusq("Small$sz", rjustt($sz, $git_count, $git_dirty)) + genform_plusq("Small$sz", rjustt($sz, $git_count, $git_dirty)) if defined $git_count; - gentextmodule_plusq("Git$sz", ljustt($sz, $git_object, $git_dirty)) + genform_plusq("Git$sz", ljustt($sz, $git_object, $git_dirty)) if defined $git_object; if (defined $git_count && defined $git_object) { - gentextmodule("Full".($sz*2), - ljustt($sz, $git_object), - rjustt($sz, $git_count, $git_dirty)); + genform("Full".($sz*2), + ljustt($sz, $git_object), + rjustt($sz, $git_count, $git_dirty)); my $e = $sz; - gentextmodule("Full".($e*3)."T", - ljustt($e*2, $git_object, $git_dirty) - =~ m/.{$e}/g, - rjustt($e, $git_count)); + genform("Full".($e*3)."T", + ljustt($e*2, $git_object, $git_dirty) + =~ m/.{$e}/g, + rjustt($e, $git_count)); } } }