chiark / gitweb /
prepare to generalise generator
[moebius2.git] / generator
index 1933c55ccb895aee36d08b505fe562a06c60cf7b..4dab49c4262a82936c65c4c05d000684700f3633 100755 (executable)
--- a/generator
+++ b/generator
@@ -1,22 +1,32 @@
 #!/usr/bin/perl
-die unless @ARGV==3;
-($primer,$ztype,$output) = @ARGV;
+die unless @ARGV==4;
+($primer,$zinput,$options,$output) = @ARGV;
 $output =~ s/^\-o// or die "$output ?";
+die if $primer =~ m/^\-/;
+die if $zinput =~ m/^\-/;
+
+die unless $options =~ m/^\-([lT])$/;
+$ztype= $1;
 
 $gnuplot= "$output.gnuplot.tmp";
 $initdata= "$output.initdata.tmp";
 
-open Z, "$ztype" or die "$ztype $!";
+open Z, "$zinput" or die "$zinput $!";
 open G, ">$gnuplot" or die $!;
 
 sub pg ($$) { printf G "%s(u,v) = %s\n", @_ or die $!; }
 
 for (;;) {
-    $!=0; defined($_= <Z>) or die "$ztype $!";
+    $!=0; defined($_= <Z>) or die "$zinput $!";
     s/\r$//;
-    next unless m/^splot\s+([^,]+),([^,]+),([^,]+)\s*$/;
-    pg('x',$1); pg('y',$2); pg('z',$3);
-    last;
+    if ($ztype eq 'l') {
+       print G or die $!;
+       last if m/^END$/;
+    } elsif ($ztype eq 'T') {
+       next unless m/^splot\s+([^,]+),([^,]+),([^,]+)\s*$/;
+       pg('x',$1); pg('y',$2); pg('z',$3);
+       last;
+    }
 }
 
 printf G "set print \"-\"\n" or die $!;