From: Ian Jackson Date: Tue, 1 Jan 2008 22:34:22 +0000 (+0000) Subject: prepare to generalise generator X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=627738e9ff5827c6238abd5186f94489438ab1c6;p=moebius2.git prepare to generalise generator --- diff --git a/Makefile b/Makefile index f4c0ebc..b19bbaf 100644 --- 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.* diff --git a/generator b/generator index 1933c55..4dab49c 100755 --- 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($_= ) or die "$ztype $!"; + $!=0; defined($_= ) 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 $!;