chiark / gitweb /
commitid.scad.pl: Introduce genform() (nfc)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 5 Feb 2016 19:59:17 +0000 (19:59 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 5 Feb 2016 19:59:17 +0000 (19:59 +0000)
commitid.scad.pl

index 6838365d9b2999404f988ba187240d9b3cf2ae50..3c409f5416925e1ba548eaf9f2ba824f5588e991 100755 (executable)
@@ -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));
        }
     }
 }