chiark / gitweb /
prepare to generalise generator
authorIan Jackson <ian@davenant.relativity.greenend.org.uk>
Tue, 1 Jan 2008 22:34:22 +0000 (22:34 +0000)
committerIan Jackson <ian@davenant.relativity.greenend.org.uk>
Tue, 1 Jan 2008 22:34:22 +0000 (22:34 +0000)
Makefile
generator

index f4c0ebc875e28a7d6294b4091201d7d492391745..b19bbaf5f2f26ee72b17872eb7b1cd560a18ca75 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ view:         view.o common.o mgraph.o
                $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) -L/usr/X11R6/lib -lX11
 
 initial:       generator primer sgtatham/z.typescript
-               ./$^ -o$@
+               ./$^ -T -o$@
 
 clean:
                rm -f *.o $(TARGETS) *.new *.tmp *.rej *.orig core vgcore.*
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 $!;