Index: /trunk/Jgraph/README
===================================================================
--- /trunk/Jgraph/README	(revision 418)
+++ /trunk/Jgraph/README	(revision 419)
@@ -47,7 +47,10 @@
 
 Author: Jim Plank
-Email:  jsp@princeton.edu
-USmail:	Department of Computer Science
-	Princeton University
-	35 Olden St.
-	Princeton, NJ 08544-2087
+Page:   http://www.cs.utk.edu/~plank
+Email:  plank@cs.utk.edu
+USmail: Associate Professor
+        Department of Computer Science
+        University of Tennessee
+        203 Claxton Complex
+        1122 Volunteer Blvd.
+        Knoxville, TN 37996-3450
Index: /trunk/Jgraph/complex-examples/README
===================================================================
--- /trunk/Jgraph/complex-examples/README	(revision 419)
+++ /trunk/Jgraph/complex-examples/README	(revision 419)
@@ -0,0 +1,65 @@
+This directory contains a few examples of using jgraph to draw figures.
+They range from relatively simple to quite complex.
+
+I can't claim that jgraph is a better way to draw pictures than normal
+WYSIWYG editors like MacDraw or xfig or idraw.  However, it has a few
+advantages.  First, because of jgraph's string justification and rotation
+commands, jgraph plots text more reliably than other tools.  Since you
+must specify exact points with jgraph, arrows are guaranteed to go to
+the right places and so on.  Although it's more cumbersome, it is also
+more precise.
+
+Second, because jgraph is essentially a programming language, it makes
+it easier to use tools like awk and nawk and sed to draw pictures which
+have iterative structure.  This is a failing of most WYSIWYG editors.
+Drawing a picture like those in tree.awk would be quite difficult and
+tedious in your standard WYSIWYG editor.
+
+The files are: from simplest to most complex:
+
+
+
+---- Straight jgraph files
+
+mlti.jgr -- A graph plotting a simple multicomputer incterconnection
+timeline.jgr -- A graph plotting a time line of three computers
+                sending messages to one another
+wedmap.jgr -- A map made with jgraph
+
+
+
+---- Jgraph mixed with awk/nawk/sh
+
+tree.awk -- This is an nawk file which will create a jgraph for any
+            m-level n-ary tree, where m and n are specified in the
+            command line arguments
+
+grtoj.sh -- This is a shell script mixed with nawk written by Adam 
+            Buchsbaum at Princeton which is a jgraph preprocessor
+            for drawing graphs (the kind with nodes and edges, not
+            the kind with points and hash marks).  He hasn't written
+            up a man page for it, but you can see how much of it works
+            with the example file grex.gtj.
+
+diskarray.jgr -- This is a jgraph file which shows a very neat mixture
+                 of jgraph and awk.  First, there is the file convert.awk,
+                 which takes a jgraph file, and converts it into an awk
+                 file.  This awk file takes as input a pair of x and y 
+                 coordinates on the command line arguments, and then 
+                 produces the jgraph to plot the original jgraph file 
+                 at those coordinates in the new jgraph file.  In this
+                 file, disk.jgr is plotted 6 times to make a disk array.
+
+ckpov.jgr -- This is a similar jgraph file, which uses the more complex
+             file srm.jgr, depicting a computer screen to make a nice
+             picture.
+
+seq.jgr
+conc.jgr
+cow.jgr
+cll.jgr 
+alg.jgr -- These are all files which comprise alg.jgr.  Note that
+           they are standalone pictures.  Alg.jgr simply plots all
+           of them together.  Thus they show a neat way that jgraph
+           makes it easy to not duplicate work when duplicating pictures.
+
Index: /trunk/Jgraph/complex-examples/alg.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/alg.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/alg.jgr	(revision 419)
@@ -0,0 +1,51 @@
+(* This is a very complex jgraph picture used in a paper on checkpointing.
+   Basically, it is a graphic representation of four checkpointing algorithms.
+
+   The four algorithms are in the files seq.jgr, conc.jgr, cow.jgr, and 
+   cll.jgr.  This file lays those four algorithms out on the page, gives
+   them titles, and then draws a legend at the bottom.  It ends up calling
+   the shell construct 24 times, forking off 72 processes, which might seem
+   like a lot, but it only takes 9 seconds to produce the output on a
+   DECstation 5000.
+
+   Note that in this file, the y-axis if the drawings is shrunk, so that
+   they all fit better on the page.
+*)
+
+include seq.jgr
+yaxis size 1.5
+title y -.5 : Sequential Algorithm
+x_translate -1.5
+y_translate 2.5
+
+include conc.jgr
+yaxis size 1.5
+x_translate 1.5
+y_translate 2.5
+title y -.5 : Main Memory Algorithm
+
+include cow.jgr
+yaxis size 1.5
+title y -.5 : Copy-on-write Algorithm
+x_translate -1.5
+
+include cll.jgr
+yaxis size 1.5
+title y -.5 : CLL Algorithm
+x_translate 1.5
+
+newgraph
+y_translate -1.9 
+x_translate -1
+xaxis max 2 min 0 size 2 nodraw
+yaxis max 2 min 0 size 2 nodraw
+
+newline linetype solid rarrow asize .07 .04  label fontsize 10
+  : Bytes copied / written when all processors are frozen
+newline linetype dotted rarrow asize .07 .04  label fontsize 10
+  : Bytes copied / written after the processors are restarted
+newline linetype longdash rarrow asize .07 .04  label fontsize 10
+  : Bytes written after the main memory checkpoint is complete
+
+legend on x 0 y 1
+  linelength 1
Index: /trunk/Jgraph/complex-examples/ckpov.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/ckpov.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/ckpov.jgr	(revision 419)
@@ -0,0 +1,69 @@
+(* This is a pretty ugly file, which prints an overview of checkpointing.
+   It's interesting because like diskarray.jgr, it makes use of convert.awk
+   to plot disk drives, and computer screens (from srm.awk)
+*)
+
+
+(* Draw the top time line *)
+
+newgraph
+xaxis min 0 max 13 size 6 nodraw
+yaxis min 0 max 4 size 2.5 nodraw
+
+shell : echo "0 1.5" | awk -f srm.awk
+newcurve marktype box fill .8 marksize .8 .7 pts 0.9 3.15
+
+newline linethickness 3 
+  pts 2.5 2.5   3.0 3.0   3.5 3.0   4.0 3.2   4.5 3.0   5.0 3.5
+      5.5 3.2   6.0 2.7   6.5 2.8   7.0 2.5   7.5 2.8   8.0 3.2
+      8.5 2.9   9.0 3.1   9.5 2.8   10.0 2.7
+newline linethickness 3 rarrows asize .3 .2 pts 10.0 2.7   10.5 2.5
+
+shell : echo "11 1.5" | awk -f srm.awk
+
+
+(* Draw the middle time line, with checkpoints and a failure *)
+
+copygraph
+y_translate -2.2
+
+shell : echo "0 1.5" | awk -f srm.awk
+newcurve marktype box fill .8 marksize .8 .7 pts 0.9 3.15
+
+newline linethickness 3 
+  pts 2.5 2.5   3.0 3.0   3.5 3.0   4.0 3.2   4.5 3.0   5.0 3.5
+      5.5 3.2   6.0 2.7   6.5 2.8   7.0 2.5   7.5 2.8   8.0 3.2
+newline linethickness 3 rarrows asize .3 .2 pts 8.0 3.2   8.5 2.9
+newstring x 8.8 y 2.9 hjl vjc fontsize 14 : Failure
+
+newline rarrows pts 3.5 3.0  3.4 1.6
+shell : echo "3.2 1.1" | awk -f disk.awk
+
+newline rarrows pts 5.5 3.2  5.4 1.6
+shell : echo "5.2 1.1" | awk -f disk.awk
+
+newline rarrows pts 7.5 2.8  7.4 1.6
+shell : echo "7.2 1.1" | awk -f disk.awk
+
+newstring x 5.5 y 4.5 fontsize 12 hjc vjb : Checkpoints
+newline rarrows pts 5.5 4.3 3.6 3.2
+newline rarrows pts 5.5 4.3 5.5 3.4
+newline rarrows pts 5.5 4.3 7.4 3.0
+
+
+(* Draw the bottom time line, which recovers from the checkpoint *)
+
+copygraph
+y_translate -4.4
+
+newline linethickness 3 
+  pts 7.5 2.8   8.0 3.2   8.5 2.9   9.0 3.1   9.5 2.8   10.0 2.7
+newline linethickness 3 rarrows asize .3 .2 pts 10.0 2.7   10.5 2.5
+
+shell : echo "11 1.5" | awk -f srm.awk
+
+newline larrows pts 7.5 2.7  7.4 1.6
+shell : echo "7.2 1.2" | awk -f disk.awk
+
+newstring fontsize 12 hjr vjc x 7.3 y 2.8 : Recover
+
Index: /trunk/Jgraph/complex-examples/cll.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/cll.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/cll.jgr	(revision 419)
@@ -0,0 +1,59 @@
+(* This is a picture of the Concurrent, low-latency checkpointing algorithm. *)
+
+newgraph
+xaxis min 0 max 3 size 2.5 nodraw
+yaxis min 0 max 2.0 size 2.0 nodraw
+
+(* Draw the address space *)
+newstring fontsize 9 hjc vjt x 0.25 y -0.07 : Address\
+Space
+
+newcurve marktype ellipse marksize 0.1 .14 fill 1 pts
+shell : echo "" | awk '{ for (i = 0.67; i < 1.37; i += 0.14) printf("0.5 %f\n", i, i);}'
+
+newcurve marktype box fill 1 marksize 0.5 0.6 pts 0.25 0.3
+newcurve marktype box fill 0.5 marksize 0.5 0.14 pts 
+
+
+shell : echo "" | awk '{ for (i = 0.67; i < 1.37; i += 0.14) printf("0.25 %f\n", i);}'
+copycurve fill 1 pts
+shell : echo "" | awk '{ for (i = 1.37; i < 2.00; i += 0.14) printf("0.25 %f\n", i);}'
+
+(* Draw the registers *)
+newline pts 0.0 0.6    0.5 0.6
+shell : echo "0.7 0" | awk -f regs.awk
+newstring hjc vjc fontsize 7 x 1.3 y 0.3 : . . .
+newstring fontsize 9 hjc vjt x 1.05 y -0.07 : CPU\
+States
+
+(* Draw the pool of page buffers *)
+
+newcurve marktype ellipse fill 1 marksize 0.1 0.14 pts
+shell : echo "" | awk '{ for (i = 0.67; i < 1.09; i += 0.14) printf("2.2 %f\n", i);}'
+newcurve marktype box marksize 0.5 0.14 fill 1 pts
+shell : echo "" | awk '{ for (i = 0.67; i < 1.09; i += 0.14) printf("1.95 %f\n", i);}'
+shell : echo "" | awk '{ for (i = 1.51; i < 1.79; i += 0.14) printf("1.95 %f\n", i);}'
+copycurve fill .5 pts
+shell : echo "" | awk '{ for (i = 1.09; i < 1.51; i += 0.14) printf("1.95 %f\n", i);}'
+newstring fontsize 9 hjc vjt x 1.95 y 0.53 : Page\
+Pool
+
+
+(* Draw arrows *)
+newcurve marktype text hjl vjc x 0 y 0 rotate 90 fontsize 7 : . . . 
+  pts 0.9 1.35   2.5 1.05
+shell : echo "" | awk '{ for (i = 0.67; i < 1.37; i += 0.14) printf("newline linetype dotted rarrow asize .07 .04  pts 0.55 %f 1.6 %f\n", i, i+.14);}'
+
+newline pts 1.3 0.635   1.22  0.4
+newline pts 1.3 0.635   1.3  0.4
+newline pts 1.3 0.635   1.38  0.4
+newline rarrow asize .07 .04  pts 1.0 0.6   1.3 0.635   1.6 0.67
+
+(* Draw the bezier to disk *)
+
+newline linetype dotted 
+shell : echo "" | awk '{ for (i = 0.67; i < 1.09; i += 0.14) printf("copycurve bezier pts 2.25 %f 2.6 %f 2.7 %f 2.7 %f\n", i, i+.1, i, i-.1);}' 
+copycurve nobezier rarrow asize .07 .04  pts 2.7 0.85 2.7 0.45
+
+(* Draw the disk *)
+shell : echo "2.5 0.0" | awk -f disk.awk
Index: /trunk/Jgraph/complex-examples/conc.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/conc.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/conc.jgr	(revision 419)
@@ -0,0 +1,40 @@
+(* This is a picture of the concurrent checkpointing algorithm. *)
+
+newgraph
+xaxis min 0 max 3 size 2.5 nodraw
+yaxis min 0 max 2.0 size 2 nodraw
+
+(* Draw the address space *)
+
+newstring fontsize 9 hjc vjt x 0.25 y -0.07 : Address\
+Space
+
+newcurve fill 1 marktype ellipse marksize 0.2 1.4 pts 0.5 1.3
+newcurve marktype box fill 1 marksize 0.5 2.0 pts 0.25 1
+newline pts 0.0 0.6    0.5 0.6
+
+(* Draw the registers *)
+shell : echo "0.7 0" | awk -f regs.awk
+newstring hjc vjc fontsize 7 x 1.3 y 0.3 : . . .
+newstring fontsize 9 hjc vjt x 1.05 y -0.07 : CPU\
+States
+
+(* Draw the second address space *)
+newcurve fill 1 marktype ellipse marksize 0.2 1.5 pts 2.2 1.25
+newcurve marktype box marksize 0.5 2.0 fill 1 pts 1.95 1
+copycurve marksize 0.5 1.4 fill .5 pts 1.95 1.3
+copycurve marksize 0.5 0.1 pts 1.95 0.55
+newstring fontsize 9 hjc vjt x 1.95 y -0.07 : New Address\
+Space
+
+(* Draw all the arrows *)
+newline rarrow asize .07 .04  pts 0.6 1.3   1.60 1.3
+newline pts 1.3 0.575   1.22  0.4
+newline pts 1.3 0.575   1.3  0.4
+newline pts 1.3 0.575   1.38  0.4
+newline rarrow asize .07 .04  pts 1.0 0.6   1.3 0.575   1.6 0.55
+
+newline linetype longdash rarrow asize .07 .04  pts 2.3 1.25 2.6 0.45
+
+(* Draw the disk *)
+shell : echo "2.5 0.0" | awk -f disk.awk
Index: /trunk/Jgraph/complex-examples/convert.awk
===================================================================
--- /trunk/Jgraph/complex-examples/convert.awk	(revision 419)
+++ /trunk/Jgraph/complex-examples/convert.awk	(revision 419)
@@ -0,0 +1,42 @@
+BEGIN	{ printf("{ x = $1; y = $2; \\\n"); }
+	{ inpts = 0; instr = 0; npts = 0; inx = 0; \
+          iny = 0;\
+          printf("  printf(\"");\
+          for (i = 1; i <= NF; i++) {\
+            if (instr) { \
+              printf(" %s", $i); \
+            } else if (inpts > 0) {\
+              printf(" %%f");\
+              pts[npts] = $i;\
+              if (inpts % 2) x[npts] = "x"; else x[npts] = "y";\
+              inpts++;\
+              npts++;\
+            } else if (inx) {\
+              printf(" %%f");\
+              pts[npts] = $i;\
+              x[npts] = "x";\
+              npts++;\
+              inx = 0;\
+            } else if (iny) {\
+              printf(" %%f");\
+              pts[npts] = $i;\
+              x[npts] = "y";\
+              npts++;\
+              iny = 0;\
+            } else {\
+              printf(" %s", $i);\
+              if ($i == ":") instr = 1;\
+              if ($i == "x") inx = 1;\
+              if ($i == "y") iny = 1;\
+              if ($i == "pts") inpts = 1; \
+            }\
+          }\
+          printf("\\n\"");\
+          if (npts > 0) {\
+            for (i = 0; i < npts; i++) {\
+              printf(", %s + %f", x[i], pts[i]);\
+            }\
+          }\
+          printf(");\\\n");\
+        }
+END	{ printf("}\n"); }
Index: /trunk/Jgraph/complex-examples/cow.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/cow.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/cow.jgr	(revision 419)
@@ -0,0 +1,48 @@
+(* This is a picture of the Copy-on-write checkpointing algorithm. *)
+
+newgraph
+xaxis min 0 max 3 size 2.5 nodraw
+yaxis min 0 max 2.0 size 2 nodraw
+
+(* Draw the address space *)
+newstring fontsize 9 hjc vjt x 0.25 y -0.07 : Address\
+Space
+
+(* Draw the page boundaries with awk *)
+
+newcurve marktype ellipse marksize 0.1 .14 fill 1 pts
+shell : echo "" | awk '{ for (i = 0.67; i < 2.0; i += 0.14) printf("0.5 %f\n", i, i);}'
+newcurve marktype box fill 1 marksize 0.5 2.0 pts 0.25 1
+shell : echo "" | awk '{ for (i = 0.6; i < 2.0; i += 0.14) printf("newline pts 0 %f 0.5 %f\n", i, i);}'
+
+(* Draw the registers *)
+newline pts 0.0 0.6    0.5 0.6
+shell : echo "0.7 0" | awk -f regs.awk
+newstring hjc vjc fontsize 7 x 1.3 y 0.3 : . . .
+newstring fontsize 9 hjc vjt x 1.05 y -0.07 : CPU\
+States
+
+(* Draw the second address space *)
+newcurve fill 1 marktype ellipse marksize 0.2 1.5 pts 2.2 1.25
+newcurve marktype box marksize 0.5 2.0 fill 1 pts 1.95 1
+copycurve marksize 0.5 1.4 fill .5 pts 1.95 1.3
+copycurve marksize 0.5 0.1 pts 1.95 0.55
+
+(* Draw the second address space's page boundaries *)
+
+shell : echo "" | awk '{ for (i = 0.6; i < 2.0; i += 0.14) printf("newline pts 1.7 %f 2.2 %f\n", i, i);}'
+shell : echo "" | awk '{ for (i = 0.67; i < 2.0; i += 0.14) printf("newline linetype dotted rarrow asize .07 .04  pts 0.55 %f 1.65 %f\n", i, i);}'
+
+newstring fontsize 9 hjc vjt x 1.95 y -0.07 : New Address\
+Space
+
+(* Draw the arrows *)
+newline pts 1.3 0.575   1.22  0.4
+newline pts 1.3 0.575   1.3  0.4
+newline pts 1.3 0.575   1.38  0.4
+newline rarrow asize .07 .04  pts 1.0 0.6   1.3 0.575   1.6 0.55
+
+newline linetype longdash rarrow asize .07 .04  pts 2.3 1.25 2.6 0.45
+
+(* Draw the disk *)
+shell : echo "2.5 0.0" | awk -f disk.awk
Index: /trunk/Jgraph/complex-examples/disk.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/disk.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/disk.jgr	(revision 419)
@@ -0,0 +1,9 @@
+(* Picture of a disk:
+   0 0 to 0.4 0.4 *)
+
+newcurve marktype ellipse fill .5 marksize 0.4 0.2 pts 0.2 0.1
+newcurve marktype box fill .5 gray .5 marksize 0.4 0.2 pts 0.2 0.2
+newline pts 0.0 0.1   0.0 0.3
+newline pts 0.4 0.1   0.4 0.3
+newcurve marktype ellipse fill 1 marksize 0.4 0.2 pts 0.2 0.3
+
Index: /trunk/Jgraph/complex-examples/diskarray.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/diskarray.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/diskarray.jgr	(revision 419)
@@ -0,0 +1,26 @@
+(* This is an example of using convert.awk to convert a jgraph file to
+   an awk script and then use that awk script to plot several instances 
+   of the original jgraph file.  Here, disk.awk is used to plot a disk
+   drive 6 times.
+*)
+
+newgraph
+xaxis size 4 min 0 max 5.4 nodraw
+yaxis size 2 min 0 max 2 nodraw
+
+newcurve marktype box marksize 2 .5 fill 1 pts 2.75 1.5
+
+shell : echo "0 0" | awk -f disk.awk
+shell : echo "1 0" | awk -f disk.awk
+shell : echo "2 0" | awk -f disk.awk
+shell : echo "3 0" | awk -f disk.awk
+shell : echo "4 0" | awk -f disk.awk
+shell : echo "5 0" | awk -f disk.awk
+
+shell : echo "" | \
+        awk ' {for (i = 0; i < 6; i++) { \
+                 printf("newline rarrows pts 2.75 1.25 %d.2 .4\n", i) }} '
+
+newstring hjc vjc fontsize 12 x 2.75 y 1.5 : Controller
+
+title fontsize 16 : Disk Array
Index: /trunk/Jgraph/complex-examples/grex.gtj
===================================================================
--- /trunk/Jgraph/complex-examples/grex.gtj	(revision 419)
+++ /trunk/Jgraph/complex-examples/grex.gtj	(revision 419)
@@ -0,0 +1,132 @@
+lab 0
+marksize .05 .05
+fill 0
+xs 1.25
+ys 1.25
+
+3.4 3
+3.1 2.7
+3.4 2.7
+3.7 2.7
+2.9 2.4
+3.1 2.4
+3.3 2.4
+3.5 2.4
+3.7 2.4
+3.9 2.4
+3 2.1
+3.2 2.1
+3.6 2.1
+3.8 2.1
+
+4.95 3
+4.5 2.7
+4.8 2.7
+5.1 2.7
+5.4 2.7
+4.7 2.4
+4.9 2.4
+5.2 2.4
+5.4 2.4
+5.6 2.4
+4.6 2.1
+4.8 2.1
+5.3 2.1
+5.5 2.1
+
+6.8 3
+6.2 2.7
+6.5 2.7
+6.8 2.7
+7.1 2.7
+7.4 2.7
+6.4 2.4
+6.6 2.4
+7.2 2.4
+7.4 2.4
+7.6 2.4
+7.3 2.1
+7.5 2.1
+
+edges
+
+0 1
+0 2
+0 3
+1 4
+1 5
+1 6
+5 10
+5 11
+3 7
+3 8
+3 9
+8 12
+8 13
+
+14 15
+14 16
+14 17
+14 18
+16 19
+16 20
+19 24
+19 25
+18 21
+18 22
+18 23
+22 26
+22 27
+
+28 29
+28 30
+28 31
+28 32
+28 33
+30 34
+30 35
+33 36
+33 37
+33 38
+37 39
+37 40
+
+raw
+
+yaxis min 2 max 3 size 1.25 nodraw
+
+newstring x 2.9 y 2.3 vjc hjc fontsize 10 : a
+copystring x 3 y 2 : b
+copystring x 3.2 y 2 : c
+copystring x 3.3 y 2.3 : d
+copystring x 3.4 y 2.6 : e
+copystring x 3.5 y 2.3 : f
+copystring x 3.6 y 2 : g
+copystring x 3.8 y 2 : h
+copystring x 3.9 y 2.3 : i
+
+copystring x 4.5 y 2.6 : a
+copystring x 4.6 y 2 : b
+copystring x 4.8 y 2 : c
+copystring x 4.9 y 2.3 : d
+copystring x 5.1 y 2.6 : e
+copystring x 5.2 y 2.3 : f
+copystring x 5.3 y 2 : g
+copystring x 5.5 y 2 : h
+copystring x 5.6 y 2.3 : i
+
+copystring x 6.2 y 2.6 : a
+copystring x 6.4 y 2.3 : b
+copystring x 6.6 y 2.3 : c
+copystring x 6.8 y 2.6 : d
+copystring x 7.1 y 2.6 : e
+copystring x 7.2 y 2.3 : f
+copystring x 7.3 y 2 : g
+copystring x 7.5 y 2 : h
+copystring x 7.6 y 2.3 : i
+
+newline marktype none rarrows asize .1 .05 pts 4 2.55 4.4 2.55
+copycurve pts 5.7 2.55 6.1 2.55
+newstring x 4.2 y 2.65 vjc hjc fontsize 10 : pull
+copystring x 5.9
+
Index: /trunk/Jgraph/complex-examples/grtoj.sh
===================================================================
--- /trunk/Jgraph/complex-examples/grtoj.sh	(revision 419)
+++ /trunk/Jgraph/complex-examples/grtoj.sh	(revision 419)
@@ -0,0 +1,117 @@
+#!/bin/sh
+
+nawk '
+
+BEGIN {
+	xmarksize = ymarksize = .3
+	marktype = "circle"
+	vfont = "Times-Roman"
+	vfontsize = 8
+	efont = "Times-Roman"
+	efontsize = 8
+	fill = 1.
+	xs = ys = 1.
+	xmin = ymin = 999999.
+	xmax = ymax = -999999.
+	n = 0
+	m = 0
+	mode = 0
+	NOLABEL = "_NOLABEL"
+	pi = 3.141593
+	deg90 = pi / 2.
+	elabdist = .1
+	vlab = elab = 1
+	larrows = rarrows = 0
+}
+
+NF == 0 || substr($1, 1, 1) == "#" { next }
+
+$1 == "xmarksize" { xmarksize = $2 ; next }
+$1 == "ymarksize" { ymarksize = $2 ; next }
+$1 == "marksize" { xmarksize = ymarksize = $2 ; next }
+$1 == "marktype" { marktype = $2 ; next }
+$1 == "vfont" { vfont = $2 ; next }
+$1 == "vfontsize" { vfontsize = $2 ; next }
+$1 == "efont" { efont = $2 ; next }
+$1 == "efontsize" { efontsize = $2 ; next }
+$1 == "font" { vfont = efont = $2 ; next }
+$1 == "fontsize" { vfontsize = efontsize = $2 ; next }
+$1 == "fill" { fill = $2 ; next }
+$1 == "xs" { xs = $2 ; next }
+$1 == "ys" { ys = $2 ; next }
+$1 == "scale" { xs = ys = $2 ; next }
+$1 == "elabdist" { elabdist = $2 ; next }
+$1 == "vlab" { vlab = $2 ; next }
+$1 == "elab" { elab = $2 ; next }
+$1 == "lab" { vlab = elab = $2 ; next }
+$1 == "larrows" { larrows = $2 ; next }
+$1 == "rarrows" { rarrows = $2 ; next }
+$1 == "arrows" { larrows = rarrows = $2 ; next }
+
+$1 == "edges" {
+	mode = 1
+	printf "newgraph\n"
+	printf "xaxis min %f max %f size %f nodraw\n", xmin, xmax, (xmax - xmin) * xs
+	printf "yaxis min %f max %f size %f nodraw\n\n", ymin, ymax, (ymax - ymin) * ys
+	next
+}
+
+$1 == "raw" { mode = 2 ; next }
+
+{
+	if (!mode) {
+		x[n] = $1
+		y[n] = $2
+		vlabel[n] = (NF == 3 ? $3 : n)
+		if (x[n] < xmin) xmin = x[n]
+		else if (x[n] > xmax) xmax = x[n]
+		if (y[n] < ymin) ymin = y[n]
+		else if (y[n] > ymax) ymax = y[n]
+		n++
+	}
+	else if (mode == 1) {
+		src[m] = label_to_node($1)
+		dst[m] = label_to_node($2)
+		elabel[m] = (NF == 3 ? $3 : NOLABEL)
+		m++
+	}
+	else
+		print $0
+}
+
+END {
+	printf "\n"
+	for (i = 0; i < n; i++) {
+		printf "newline marktype %s marksize %f %f fill %f pts %f %f\n", marktype, xmarksize, ymarksize, fill, x[i], y[i]
+		if (vlab)
+			printf "newstring x %f y %f vjc hjc font %s fontsize %d : %s\n", x[i], y[i], vfont, vfontsize, vlabel[i]
+	}
+	printf "\n"
+	for (i = 0; i < m; i++) {
+		printf "newline marktype %s marksize %f %f fill %f pts %f %f %f %f ", marktype, xmarksize, ymarksize, fill, x[src[i]], y[src[i]], x[dst[i]], y[dst[i]]
+		if (larrows) printf "larrows "
+		if (rarrows) printf "rarrows "
+		printf "\n"
+		if (elab && elabel[i] != NOLABEL) {
+			midx = (x[src[i]] + x[dst[i]]) / 2.
+			midy = (y[src[i]] + y[dst[i]]) / 2.
+			ang = atan2(y[dst[i]] - y[src[i]], x[dst[i]] - x[src[i]])
+			nang = ang - deg90
+			px = midx + elabdist * cos(nang)
+			py = midy + elabdist * sin(nang)
+			rot = ang * 180. / pi
+			rot = (rot < 0. ? rot + 360. : rot)
+			rot = (rot >= 90. && rot <= 270. ? rot + 180. : rot);
+			printf "newstring x %f y %f vjc hjc rotate %f font %s fontsize %d : %s\n", px, py, rot, efont, efontsize, elabel[i]
+		}
+	}
+}
+
+function label_to_node(label) {
+	for (i = 0; i < n; i++)
+		if (vlabel[i] == label)
+			return(i)
+	return(-1)
+}
+
+'
Index: /trunk/Jgraph/complex-examples/makefile
===================================================================
--- /trunk/Jgraph/complex-examples/makefile	(revision 419)
+++ /trunk/Jgraph/complex-examples/makefile	(revision 419)
@@ -0,0 +1,93 @@
+STANDARD_EXAMPLES = \
+	acc.jps		\
+	acc.eps		\
+	alb.jps		\
+	ad.jps		\
+	bailey.jps	\
+	ebars.jps	\
+	ex1.jps		\
+	ex2.jps		\
+	g8.jps		\
+	g8col.jps	\
+	g9n10.jps	\
+	gpaper.jps	\
+	hypercube.jps	\
+	mab2.jps	\
+	nr.jps	\
+	sin.jps		\
+	sin1.jps	\
+	sin2.jps	\
+	sin3.jps	\
+	wortman.jps
+
+COMPLEX_EXAMPLES = 	\
+	seq.jps		\
+	conc.jps	\
+	cow.jps		\
+	cll.jps		\
+	alg.jps		\
+	tree1.jps	\
+	tree2.jps	\
+	wedmap.jps	\
+	diskarray.jps	\
+	mlti.jps	\
+	ckpov.jps	\
+	timeline.jps	\
+	grex.jps
+
+TMPFILES = \
+	regs.awk 	\
+	srm.awk 	\
+	disk.awk
+
+ALL = $(STANDARD_EXAMPLES) $(COMPLEX_EXAMPLES)
+
+all: $(ALL)
+
+clean:
+	rm -f $(ALL) $(TMPFILES) sin.o
+
+sin:	sin.o
+	cc -o sin sin.o -lm
+
+ad.jps: cube.eps disk.eps
+bailey.jps: bailey.pts
+ex2.jps: data.txt
+mab2.jps: mab2.times
+sin.jps: sin
+sin2.jps: sin2.pts
+sin3.jps: sin3.pts
+
+seq.jps:  regs.awk convert.awk disk.awk
+conc.jps: regs.awk convert.awk disk.awk
+cow.jps:  regs.awk convert.awk disk.awk
+cll.jps:  regs.awk convert.awk disk.awk
+
+alg.jps: convert.awk regs.awk cow.jgr cll.jgr seq.jgr conc.jgr disk.awk
+
+diskarray.jps: disk.awk convert.awk
+
+ckpov.jps: srm.awk disk.awk convert.awk
+
+tree1.jps: tree.awk
+	( echo "4 3" | awk -f tree.awk ; echo "xaxis size 5.4" ) |\
+		jgraph -P > tree1.jps
+	( echo "5 2" | awk -f tree.awk ; echo "xaxis size 5" ) |\
+		jgraph -P > tree2.jps
+
+.SUFFIXES: .c .o .h .gtj .jgr .jps .awk .eps .tex .dvi
+
+.jgr.jps:
+	jgraph -P < $*.jgr > $*.jps
+
+.jgr.awk:
+	sed 's/\\/\\\\/g' $*.jgr | awk -f convert.awk > $*.awk
+
+.gtj.jps:
+	sh grtoj.sh < $*.gtj | jgraph -P > $*.jps
+
+.jgr.eps:
+	jgraph < $*.jgr > $*.eps
+
+.tex.dvi:
+	latex $*.tex
Index: /trunk/Jgraph/complex-examples/mlti.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/mlti.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/mlti.jgr	(revision 419)
@@ -0,0 +1,35 @@
+(* 
+
+  Jgraph file for the simple multicomputer picture:
+
+  Pc--P1--P2
+
+ *)
+
+newgraph
+  xaxis size 1.5 min 0 max 2 nodraw
+  yaxis size 0.4 min 0 max 1 nodraw
+
+(* Draw the lines connecting the processors *)
+
+newcurve
+  marktype none
+  linetype solid
+  pts
+    0 0   1 0   2 0
+
+(* Draw circles for the processors on top of the lines *)
+
+newcurve 
+  marktype circle
+  marksize .3
+  linetype none
+  fill 1
+  pts
+    0 0   1 0   2 0
+
+(* Draw the labels for the processors *)
+
+newstring fontsize 9 x 0   y 0 hjc vjc : Pc
+newstring fontsize 9 x 1   y 0 hjc vjc : P1
+newstring fontsize 9 x 2   y 0 hjc vjc : P2
Index: /trunk/Jgraph/complex-examples/regs.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/regs.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/regs.jgr	(revision 419)
@@ -0,0 +1,11 @@
+(* Picture of process state: 0 0.0 to 0.3 0.6 *)
+
+newcurve marktype box fill 1 marksize 0.3 0.6 pts 0.15 0.3
+newline pts 0.0 0.15   0.3 0.15
+newline pts 0.0 0.30   0.3 0.30
+newline pts 0.0 0.45   0.3 0.45
+newstring fontsize 7 hjc vjc x 0.15 y 0.075 : PC
+copystring y 0.225 : . . .
+copystring y 0.375 : R1
+copystring y 0.525 : R0
+
Index: /trunk/Jgraph/complex-examples/seq.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/seq.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/seq.jgr	(revision 419)
@@ -0,0 +1,41 @@
+(* This is a picture of the sequential checkpointing algorithm. *)
+   
+newgraph 
+xaxis min 0 max 3 size 2.5 nodraw
+yaxis min 0 max 2.0 size 2 nodraw
+
+
+newstring fontsize 7 hjc vjc x 0.25 y 0.3 : Code
+copystring y 1.3 : Globals,\
+Heap\
+&\
+Stack
+newstring fontsize 9 hjc vjt x 0.25 y -0.07 : Address\
+Space
+
+(* Draw the address space *)
+newcurve fill 1 marktype ellipse marksize 0.2 1.4 pts 0.5 1.3
+newcurve marktype box fill 1 marksize 0.5 2.0 pts 0.25 1
+newline pts 0.0 0.6    0.5 0.6
+
+(* Draw the registers *)
+shell : echo "0.7 0" | awk -f regs.awk
+shell : echo "1.1 0" | awk -f regs.awk
+shell : echo "1.5 0" | awk -f regs.awk
+shell : echo "2.1 0" | awk -f regs.awk
+newstring hjc vjc fontsize 7 x 1.95 y 0.3 : . . .
+newstring fontsize 9 hjc vjt x 1.55 y -0.07 : CPU\
+States
+
+(* Draw the disk *)
+shell : echo "2.1 1.6" | awk -f disk.awk
+
+(* Draw the arrows to the disk *)
+
+newline rarrow asize .07 .04  pts 0.6 1.3   2.0 1.8
+
+newline rarrow asize .07 .04 pts 1.45 0.9   2.15 1.57
+newline pts 1.0 0.6   1.45 0.9
+newline pts 1.4 0.6   1.45 0.9
+newline pts 1.5 0.6   1.45 0.9
+newline pts 2.1 0.6   1.45 0.9
Index: /trunk/Jgraph/complex-examples/srm.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/srm.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/srm.jgr	(revision 419)
@@ -0,0 +1,68 @@
+(* newgraph *)
+(* xaxis min 0 max 2 size 2 nodraw *)
+(* yaxis min 0 max 2.5 size 2.5 nodraw *)
+
+(* This is a picture of the SRM for the hypercube *)
+
+newcurve linetype solid linethickness .7 marktype none
+  pts 0.00 0.95   0.00 0.50   1.75 0.50   1.75 0.95   0.00 0.95
+ pts 0.25 1.45   0.40 1.45
+newcurve linetype solid linethickness .7 marktype none
+  pts 1.55 1.45   2.00 1.45   2.00 1.00   1.75 0.50   1.75 0.95
+ pts 2.00 1.45
+
+(* Knobs *)
+newcurve marktype circle fill 0 marksize .07 linetype none
+  pts 0.15 0.60   0.25 0.60   0.35 0.60
+
+newcurve marktype box fill 0 marksize .5 .45 pts .80 0.725
+newcurve marktype circle fill 1 marksize .07 linetype none
+  pts 0.95 0.85
+
+newcurve marktype box fill 0 marksize .4 .025 linetype none 
+  pts 1.40 0.80   1.40 0.70
+
+(* Terminal *)
+newcurve marktype box fill 1 marksize 1 1 pts .9 1.6
+newcurve marktype box fill .8 marksize .8 .7 pts .9 1.65
+newline pts 0.60 1.90  1.20 1.90
+newline pts 0.60 1.85  1.00 1.85
+newline pts 0.60 1.80  0.70 1.80
+newline pts 0.60 1.75  1.00 1.75
+newline pts 0.60 1.70  0.80 1.70
+newline pts 0.60 1.65  1.20 1.65
+newline pts 0.60 1.60  0.60 1.60
+newline pts 0.60 1.55  0.80 1.55
+newline pts 0.60 1.50  0.80 1.50
+newline pts 0.60 1.45  1.10 1.45
+newline pts 0.60 1.40  1.10 1.40
+newcurve linetype solid linethickness .7 marktype none
+  pts 0.40 2.10   0.55 2.30   1.55 2.30   1.55 1.30  1.40 1.10 
+ pts 1.40 2.10   1.55 2.30
+
+newcurve marktype circle fill 0 marksize .07 linetype none
+  pts 1.00 1.20   1.10 1.20   1.20 1.20
+
+(* Keyboard *)
+      
+newcurve linetype solid linethickness .7 marktype none
+  pts 0.20 0.05   0.20 0.00   1.30 0.00   1.30 0.05   0.20 0.05
+ pts 0.35 0.35   1.45 0.35   1.45 0.30   1.30 0.00   1.30 0.05
+ pts 1.45 0.35
+
+newcurve linetype solid linethickness .7 marktype none
+  pts 0.30 0.12   0.38 0.28   1.28 0.28   1.20 0.12  0.30 0.12
+newcurve linetype solid linethickness .7 marktype none 
+   pts 0.3267 0.1733   1.2267 0.1733 
+newcurve linetype solid linethickness .7 marktype none 
+   pts 0.3533 0.2267   1.2533 0.2267
+newcurve linetype solid linethickness .7 marktype none 
+   pts 0.40 0.12  0.48 0.28   0.58 0.28   0.50 0.12
+ pts 0.60 0.12  0.68 0.28   0.78 0.28   0.70 0.12
+ pts 0.80 0.12  0.88 0.28   0.98 0.28   0.90 0.12
+ pts 1.00 0.12  1.08 0.28   1.18 0.28   1.10 0.12
+
+newcurve linetype solid linethickness .7 marktype none 
+  pts 0.31 0.27   0.01 0.30   0.00 0.31 -0.10 0.60  0.00 0.90
+
+
Index: /trunk/Jgraph/complex-examples/timeline.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/timeline.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/timeline.jgr	(revision 419)
@@ -0,0 +1,90 @@
+(* This is a jgraph of the sending of messages in a multicomputer over
+   a period of time.  It is a good mixture of picture drawing and graph-
+   drawing:  Note that hash marks and a legend is employed, as is the drawing
+   of multiple arrowed lines, and some text.
+ *)
+newgraph
+
+(* Draw the three time lines with hash ticks.  Only draw hash labels on
+   the bottom-most one *)
+
+yaxis size 1.6 min 0 max 2 nodraw
+xaxis size 4.5 min 0.5 max 10.5 nodraw 
+   draw_hash_marks draw_hash_labels draw_axis_label
+   hash 1 mhash 0 shash 0 hash_scale -.4
+   label : Time
+copygraph xaxis draw_at 1 nodraw draw_hash_marks
+copygraph xaxis draw_at 2
+
+(* Reset the axes to draw the picture *)
+
+copygraph
+xaxis size 4.5 min 99.5 max 109.5 nodraw
+
+(* Define the legend entries *)
+
+newline linethickness .5 linetype dashed 
+         rarrows asize 0.19 0.04 label font Times-Italic : mCL Marker
+copycurve linetype dotdash label : mNSmarker
+copycurve linetype dotted label : mS Message
+copycurve linetype solid label : Normal Message
+legend linelength 1
+
+(* Draw each process's time line arrow *)
+
+newline linethickness .5 rarrows 
+  pts 99.5 0 109.5 0
+copycurve pts 99.5 1 109.5 1
+copycurve pts 99.5 2 109.5 2
+
+(* Draw the time line processor labels *)
+
+newstring fontsize 9 hjl vjc x 99 y 2 : Pc
+copystring y 1 : P1
+copystring y 0 : P2
+
+(* Draw the initial broadcast of mcl messages *)
+
+newline linethickness .5 linetype dashed 
+         rarrows asize 0.19 0.04 pts 100 2 102 1
+copycurve pts 100 2 102 0
+
+(* Draw Message from p2 -> p1 *)
+
+copycurve linetype solid pts 101 0 103 1
+
+(* Draw mns messages to p1 *)
+
+copycurve linetype dotdash pts 100 2 104 1
+copycurve pts 102 0 104 1
+
+(* Draw Message from p2 -> pc *)
+
+copycurve linetype dashed pts 105 0 106 2
+copycurve linetype solid pts 105.1 0 106.1 2
+
+(* Draw mns messages from p1 *)
+
+copycurve linetype dotdash pts 104 1 107 0
+copycurve pts 104 1 107 2
+
+(* Draw mc's -> pc *)
+
+copycurve linetype dotted pts 104 1 108 2
+copycurve pts 107 0 108 2
+
+(* Draw mc from pc *)
+
+copycurve pts 108 2 109 1
+copycurve pts 108 2 109 0
+
+(* Draw labels for m and m' *)
+
+newstring fontsize 9 font Times-Italic x 102.05 y .5 hjl vjt : m
+copystring x 105.6 y .75 hjl vjc : m'
+
+copystring x 105.6 y 2.15 hjr vjc : Pc doesn't log m'
+copystring x 103.4 y 1.35 hjl vjb : P1 logs m
+
+copycurve linetype solid pts 105.7 2.15 106.1 2
+copycurve pts 103.38 1.32 103 1
Index: /trunk/Jgraph/complex-examples/tree.awk
===================================================================
--- /trunk/Jgraph/complex-examples/tree.awk	(revision 419)
+++ /trunk/Jgraph/complex-examples/tree.awk	(revision 419)
@@ -0,0 +1,53 @@
+# This is an awk script for plotting m-level n-ary trees in jgraph.
+# For each line of input, it will produce a new jgraph.  The line must
+# contain two numbers: m and n, separated by white-space.
+#
+# Two nice outputs of this are: 
+#
+# ( echo "4 3" | awk -f tree.awk ; echo "xaxis size 5.4" ) | jgraph -P
+#
+# and
+# ( echo "5 2" | awk -f tree.awk ; echo "xaxis size 5" ) | jgraph -P
+#
+
+{ m = $1
+  n = $2
+
+  printf("newgraph xaxis nodraw yaxis nodraw\n")
+  k = 0
+  for (j = 0; j < m; j++) {
+
+# Calculate node locations
+
+    if (j == 0) {
+      numleaves = n ^ (m - 1)
+      for (i = 0; i < numleaves; i++) newleafloc[i] = i
+    } else {
+      numleaves = numleaves / n
+      for (i = 0; i < numleaves; i++) {
+        newleafloc[i] =  (oldleafloc[i*n] + oldleafloc[i*n+n-1]) / 2.0
+      }
+    }
+
+# Print the nodes and labels 
+
+    for (i = 0; i < numleaves; i++) {
+      printf("newcurve marktype box marksize 0.6 0.4 fill 1 pts %f %f\n",
+              newleafloc[i], j)
+      printf("newstring x %f y %f hjc vjc fontsize 6 : %d\n",
+              newleafloc[i], j, ++k)
+
+# Print the arcs to children nodes
+
+      if (j > 0) {
+        for (l = 0; l < n; l++) {
+          printf("newcurve marktype none linetype solid pts %f %f  %f %f\n",
+              newleafloc[i], j-.2, oldleafloc[i*n+l], j-.8)
+        }
+      }
+    }
+    for (i = 0; i < numleaves; i++) {
+      oldleafloc[i] = newleafloc[i]
+    }
+  }
+}
Index: /trunk/Jgraph/complex-examples/wedmap.jgr
===================================================================
--- /trunk/Jgraph/complex-examples/wedmap.jgr	(revision 419)
+++ /trunk/Jgraph/complex-examples/wedmap.jgr	(revision 419)
@@ -0,0 +1,210 @@
+(* This is a jgraph file which draws a map to some major places in New
+   Jersey (the Princeton Quaker Meeting House and the Griggstown Fire House).
+   I can't say that this would have been harder to draw with a WYSIWYG 
+   editor, but the result is very nice.   I drew this by plotting it first
+   on graph paper, and then transferring it to jgraph.  The whole process
+   took a bit more than an hour.
+*)
+
+newgraph
+
+xaxis size 7 min 0 max 7 hash .5 mhash 4 nodraw
+yaxis size 9 min 0 max 9 hash .5 mhash 4 nodraw
+
+(* 
+(*  If this portion is uncommented,  it will print a grid, to help lay
+    out points *)
+
+newgraph inherit_axes
+xaxis hash .5 mhash 4 draw 
+  grid_lines grid_gray .5 mgrid_lines mgrid_gray .8
+yaxis hash .5 mhash 4 draw 
+  grid_lines grid_gray .5 mgrid_lines mgrid_gray .8
+
+copygraph 
+xaxis hash_scale 1 no_grid_lines no_mgrid_lines
+yaxis hash_scale 1 no_grid_lines no_mgrid_lines
+*)
+
+(* I-95 *)
+newcurve marktype none linetype solid larrows linethickness 2.2
+  pts 1.72 1.00   1.86 1.30
+newcurve marktype none linetype solid linethickness 2.2
+  pts 1.86 1.30   2.05 1.50   2.25 1.65 
+      2.67 1.74   3.10 1.70   3.50 1.55
+      3.75 1.25   3.90 1.00
+newcurve marktype none linetype solid rarrows linethickness 2.2
+  pts 3.90 1.00   3.95 0.75
+
+(* Route 206 *)
+newcurve marktype none linetype solid
+  pts 2.67 1.74   2.82 2.70
+newcurve marktype none linetype dotted
+  pts 2.82 2.70   3.20 3.50
+newcurve marktype none linetype solid
+  pts 3.20 3.50   3.40 3.80   3.72 4.22
+      4.18 4.65   4.00 4.92
+newcurve marktype none linetype dotted
+  pts 4.00 4.92   3.77 5.30
+newcurve marktype none linetype solid
+  pts 3.77 5.30   3.45 5.80   3.08 6.35
+
+(* Route 27 *)
+newcurve marktype none linetype solid
+  pts 4.18 4.65   4.24 4.70   5.30 5.69
+
+(* Route 1 *)
+newcurve marktype none linetype solid linethickness 1.5
+  pts 3.50 1.55   3.77 1.90
+newcurve marktype none linetype dotted linethickness 1.5
+  pts 3.77 1.90   4.05 2.30
+newcurve marktype none linetype solid linethickness 1.5
+  pts 4.05 2.30   4.47 2.87   4.70 3.15   5.25 3.90
+newcurve rarrows marktype none linetype solid linethickness 1.5
+  pts 5.25 3.90   5.48 4.20
+
+(* Mercer Road/Princeton Pike *)
+newcurve marktype none linetype solid
+  pts 3.10 1.70   3.20 2.08
+newcurve marktype none linetype dotted
+  pts 3.20 2.08   3.33 2.60
+newcurve marktype none linetype solid
+  pts 3.33 2.60   3.55 3.45   3.65 3.55   3.78 3.55   3.85 3.60
+      3.87 3.67   4.00 4.08   4.22 4.60   4.24 4.70
+
+(* Lover's Lane *)
+newcurve marktype none linetype solid
+  pts 3.72 4.22   4.00 4.08
+
+(* Quakerbridge Road, etc *)
+newcurve marktype none linetype solid linethickness 0.6
+  pts 3.85 3.60   3.92 3.60   3.90 3.65   3.87 3.68
+newcurve marktype none linetype solid
+  pts 3.92 3.60   4.00 3.60   4.40 3.32   4.47 3.17   
+      4.30 2.95   4.10 2.70
+newcurve marktype none linetype solid
+  pts 4.30 2.95   4.47 2.87   4.90 2.70
+
+(* The Bridge *)
+newcurve marktype none linetype solid linethickness 0.4
+  pts 3.65 3.59   3.66 3.57   3.77 3.57 3.78 3.59
+newcurve marktype none linetype solid linethickness 0.4
+  pts 3.65 3.51   3.66 3.53   3.77 3.53 3.78 3.51
+
+(* The Meeting House *)
+newcurve marktype none linetype solid linethickness 0.6
+  pts 3.90 3.65   4.0 3.72
+newcurve marktype box fill 1 linetype none marksize .1 .1
+  pts 4.05 3.78
+
+(* D&R Canal, minus Lake Carnegie *)
+newcurve marktype none linetype dotted linethickness 0.6
+  pts 4.60 7.82   4.90 6.40   4.90 6.28
+newcurve marktype none linetype dotted linethickness 0.6
+  pts 4.90 6.22   4.90 6.10   4.93 5.95
+
+(* D&R Bridge *)
+newcurve marktype none linetype solid linethickness 0.5
+  pts 4.75 6.19   4.77 6.22   5.03 6.22   5.05 6.19
+newcurve marktype none linetype solid linethickness 0.5
+  pts 4.75 6.31   4.77 6.28   5.03 6.28   5.05 6.31
+
+(* Route 518 *)
+newcurve marktype none linetype solid
+  pts 2.95 5.68   3.45 5.80   4.00 6.00
+newcurve marktype none linetype dotted
+  pts 4.00 6.00   4.50 6.20
+newcurve marktype none linetype solid
+  pts 4.50 6.20   4.70 6.25   5.10 6.25   5.20 6.27
+      5.50 6.40
+
+(* Canal Road *)
+newcurve marktype none linetype solid
+  pts 5.20 6.27   5.00 7.50   4.95 7.80
+newcurve marktype none linetype solid
+  pts 4.85 7.50   5.00 7.50
+
+(* Fire House *)
+newcurve marktype box fill 1 linetype none marksize .15 .1
+  pts 5.12 7.70
+
+(* Alexander Road *)
+newcurve marktype none linetype solid
+  pts 4.22 4.60   5.25 3.90
+
+(* Exits *)
+
+newcurve marktype box linetype none fill 1 
+  pts 5.25 3.90 (* Alexander Road / Rt 1 *)
+      4.47 2.87 (* Quakerbridge / Rt 1 *)
+      2.67 1.74 (* 206 / I95 *)
+      3.10 1.70 (* Princeton Pike / I95 *)
+      3.50 1.55 (* Rt 1 / I95 *)
+
+(* Traffic Lights *)
+newcurve marktype box linetype none fill 1 marksize .1 .2
+  pts 3.10 6.00   3.80 4.60
+newcurve marktype circle linetype none fill 0 marksize .03
+  pts 3.10 6.00   3.80 4.60
+      3.10 6.06   3.80 4.66
+      3.10 5.94   3.80 4.54
+newcurve marktype none linetype solid rarrows linethickness .04
+  pts 3.17 5.97   3.40 5.83
+newcurve marktype none linetype solid rarrows linethickness .04
+  pts 3.87 4.60   4.14 4.65
+
+(* Labels *)
+
+newstring hjc vjb fontsize 9 rotate 64 x 2.97 y 3.1 : US Rt. 206
+copystring rotate -57 x 3.82 y 5.3 : US Rt. 206
+copystring font Times-Italic rotate -57 vjt x 3.75 y 5.27 : 3-4 miles
+copystring font Times-Bold fontsize 10 vjb rotate  37 x 2.02 y 1.52 : I-95
+copystring rotate -52 x 3.70 y 1.39 : I-295
+copystring rotate  55 x 3.88 y 2.13 : US Rt. 1
+copystring font Times-Roman fontsize 9 rotate  76 x 3.31 y 2.68 
+  : Princeton Pike / Mercer Rd.
+copystring font Times-Italic vjt rotate  76 x 3.38 y 2.63 : 3-4 miles
+copystring font Times-Roman vjb rotate  21 x 4.10 y 6.07 : Rt. 518
+copystring font Times-Italic vjt x 4.12 y 6.0 : 2-4 miles
+copystring font Times-Roman vjb rotate -34 x 4.7 y 4.31 : Alexander Rd.
+copystring hjl rotate 43 x 4.22 y 4.72 : Rt. 27 / Nassau Street
+copystring font Times-Italic hjc vjt rotate  -78 x 4.71 y 7.0
+  : D & R Canal
+copystring font Times-Roman vjb rotate  -80 x 5.13 y 7.0 : Canal Rd.
+copystring font Times-Italic vjt rotate  -80 x 5.04 y 7.0 : 3.5 miles
+copystring font Times-Roman rotate 0 fontsize 12 
+           linesep 7 x 4.17 y 3.80 hjl vjc : Meeting\
+House
+copystring x 5.25 y 7.70 : Griggstown\
+Fire\
+House
+
+copystring fontsize 9 x 4.90 y 3.00 hjl vjc : Quakerbridge Rd.
+newcurve marktype none linetype solid rarrows linethickness .04
+  pts 4.86 3.00   4.50 3.18
+newcurve marktype none linetype solid rarrows linethickness .04
+  pts 4.86 3.00   4.70 2.80
+copystring x 3.40 y 4.10 hjr : Lovers Lane
+newcurve marktype none linetype solid rarrows linethickness .04
+  pts 3.44 4.10   3.82 4.15
+
+copystring font Times-Italic x 3.45 y 6.2 hjc vjb : Wawa
+newcurve marktype none linetype solid rarrows linethickness .04
+  pts 3.45 6.16   3.43 5.85
+
+newstring fontsize 9 x 1.70 y 0.84 hjc vjc linesep 5 : Philadelphia\
+~30 miles
+
+copystring x 3.95 y 0.58 : Trenton\
+~5 miles
+
+copystring hjl vjc x 5.60 y 4.37 linesep : NJ Turnpike\
+Exit 9\
+~20 miles
+
+newstring font Times-Italic fontsize 10 x 4.45 y 4.75 hjl vjc : PRINCETON
+
+newstring font Times-Italic fontsize 10 x 5.50 y 1.80 hjc vjb : N
+newcurve marktype none linetype solid rarrows linethickness .04
+  pts 5.50 1.14   5.50 1.76
+
Index: /trunk/Jgraph/draw.c
===================================================================
--- /trunk/Jgraph/draw.c	(revision 418)
+++ /trunk/Jgraph/draw.c	(revision 419)
@@ -9,4 +9,6 @@
 #include <stdio.h>
 #include <math.h>
+#include <stdlib.h> //by pzn@debian.org
+#include <string.h> //by pzn@debian.org
 
 static char real_eof = EOF;
@@ -315,5 +317,5 @@
               }
               for (i = 0; i < 4; i++) {
-                if (fscanf(f, "%d", &(bb[i])) != 1) {
+                if (fscanf(f, "%d", &(bb[i])) == NULL) {
                   fprintf(stderr, "Error: Eps file '%s': eof in %s\n",
                           c->eps, "bounding box");
@@ -642,6 +644,8 @@
   Graphs gs_p;
   Graph g;
+  int page_counter=0;
 
   for (gs_p = first(gs); gs_p != nil(gs); gs_p = next(gs_p)) {
+    page_counter++;
     draw_header(gs_p, pp, landscape);
     for (g = first(gs_p->g); g != nil(gs_p->g); g = next(g)) {
@@ -649,4 +653,9 @@
     }
     draw_footer(gs_p, pp);
+  }
+  if (pp) {
+      printf("\n%%%%Trailer\n");
+      printf("%%%%Pages: %i\n",page_counter);
+      printf("%%%%EOF\n");
   }
 }
@@ -660,15 +669,94 @@
   char c;
 
-  if (gs->page == 1) printf("%%!PS-Adobe-2.0 EPSF-1.2\n");
-  printf("%%%%Page: %d %d\n", gs->page, gs->page);
-  if (landscape) {
-    printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1], gs->bb[0], 
-            gs->bb[3], gs->bb[2]);
+  if (gs->page == 1) {
+      if (pp) {
+	  printf("%%!PS-Adobe-3.0\n");
+	  printf("%%%%Pages: (atend)\n");
+	  printf("%%%%Creator: jgraph\n");
+	  printf("%%%%EndComments\n\n");
+	  printf("%%%%BeginProlog\n");
+	  printf("%%%%EndProlog\n");
+	  printf("%%%%BeginSetup\n");
+	  printf("%%%%EndSetup\n");
+      } else {
+	  printf("%%!PS-Adobe-2.0 EPSF-1.2\n");
+	  printf("%%%%Creator: jgraph\n");
+      }
+  }
+
+  if (pp) {
+      printf("\n%%%%Page: %d %d\n", gs->page, gs->page);
+      printf("%%%%BeginPageSetup\n");
+      printf("%%%%EndPageSetup\n\n");
+  }
+
+  if ( (gs->page>1) && !pp ) {
+      /* tring EPS with more than one page */
+      fprintf(stderr, "Error: 'newpage' token is not allowed"
+	      " without '-P' command line option.\n");
+      exit(1);
+  }
+
+  /* if (landscape) {
+      printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1], gs->bb[0],
+	     gs->bb[3], gs->bb[2]);
   } else {
-    printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0], gs->bb[1], 
-            gs->bb[2], gs->bb[3]);
-  }
-
-  printf("%%%%EndComments\n");
+      printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0], gs->bb[1],
+	     gs->bb[2], gs->bb[3]);
+  }
+  printf("%%%%EndComments\n"); */
+
+  //BEGIN added by pzn@debian.org
+  { // expands the bounding box to fit characters with tilde, acute,...
+    // if user has set JGRAPH_BORDER enviroment variable
+    int expandborder=0;
+    char *s;                          \
+    s=(char *)getenv("JGRAPH_BORDER");
+    if (s!=NULL) {
+	expandborder=atoi(s);
+    }
+   if (!pp) {
+    if (landscape) {
+      printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1]-expandborder,
+	     gs->bb[0]-expandborder, gs->bb[3]+expandborder,
+	     gs->bb[2]+expandborder);
+    } else {
+      printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0]-expandborder,
+             gs->bb[1]-expandborder, gs->bb[2]+expandborder,
+             gs->bb[3]+expandborder);
+    }
+    printf("%%%%EndComments\n\n");
+   }
+  }
+
+  if (gs->page==1)
+  //reencode fonts to ISOLatin1 or other
+  {   //NOTE: this is a preliminary version. It will only work with
+      //      the default fonts, that are Times-Roman and Times-Bold
+      // "export JGRAPH_ENCODING=ISOLatin1Encoding" will work in sh
+      char *s;                          \
+      s=(char *)getenv("JGRAPH_ENCODING");
+      if ((s!=NULL) && (strlen(s)>0)) {
+	  comment("Setting font encoding by pzn@debian.org");
+	  printf("/Times-Bold findfont\n");
+	  printf("dup length dict begin\n");
+	  printf(" {1 index /FID ne {def} {pop pop} ifelse} forall\n");
+	  printf(" /Encoding %s def\n",s);
+	  printf(" currentdict\n");
+	  printf("end\n");
+	  printf("/Times-Bold exch definefont pop\n");
+	  printf("/Times-Roman findfont\n");
+	  printf("dup length dict begin\n");
+	  printf(" {1 index /FID ne {def} {pop pop} ifelse} forall\n");
+	  printf(" /Encoding %s def\n",s);
+	  printf(" currentdict\n");
+	  printf("end\n");
+	  printf("/Times-Roman exch definefont pop\n");
+	  comment("End of font encoding");
+	  printf("\n");
+      }
+  }
+  //END added by pzn
+
   if (landscape) {
     printf("-90 rotate\n");
@@ -771,4 +859,9 @@
   grestore();
   if (pp) printf("showpage\n"); else printf("\n");
-}
-
+
+  if (pp) {
+      printf("%%%%PageTrailer\n");
+  }
+
+}
+
Index: /trunk/Jgraph/ex2.jgr
===================================================================
--- /trunk/Jgraph/ex2.jgr	(revision 418)
+++ /trunk/Jgraph/ex2.jgr	(revision 419)
@@ -26,5 +26,5 @@
   marktype none linetype solid
   label : N log N / 35000
-   pts shell : nawk \
+   pts shell : awk \
      ' $5 != 0 { \
        print $5,  $5 * log($5) / 35000}' \
@@ -53,5 +53,5 @@
   marktype none linetype solid\
   label : N log N / 35000\
-   pts shell : nawk \\
+   pts shell : awk \\
      ' $5 != 0 { \\
        print $5,  $5 * log($5) / 35000}' \\
Index: /trunk/Jgraph/exit.c
===================================================================
--- /trunk/Jgraph/exit.c	(revision 418)
+++ /trunk/Jgraph/exit.c	(revision 419)
@@ -15,5 +15,5 @@
 **--
 **/
-#include <varargs.h>
+#include <stdarg.h>
 
 exit(va_alist)
Index: /trunk/Jgraph/jgraph.1
===================================================================
--- /trunk/Jgraph/jgraph.1	(revision 418)
+++ /trunk/Jgraph/jgraph.1	(revision 419)
@@ -65,5 +65,5 @@
 function plotting, and pie graphs.  The latter is impossible to do
 with the aid of 
-\fBjgraph, \fR
+\fBjgraph\fR,
 however, the others can be effected with
 \fBjgraph \fR
@@ -245,5 +245,5 @@
 error will be flagged.
 (copygraph does not copy the values of the 
-\fB\fIhash_at\fB, \fImhash_at\fB,\fR
+\fB\fIhash_at\fR, \fImhash_at\fR,\fR
 and 
 \fB\fI\fIhash_label\fB\fR 
@@ -259,7 +259,7 @@
 is the same as appending together the output of separate calls of
 jgraph on the text before the 
-\fB\fInewpage,\fB\fR
+\fB\fInewpage\fR,\fR
 and on the text after the 
-\fB\fInewpage.\fB\fR
+\fB\fInewpage.\fR
 \fB\fINewpage\fB\fR
 will most likely produce bizarre results if the
@@ -293,5 +293,5 @@
 \fB\fIbbox\fB\fR
 command.  If there's more than one page in the jgraph file, 
-\fB\fIY,\fB\fR
+\fB\fIY\fR,\fR
 \fB\fIX\fB\fR
 and
@@ -308,9 +308,9 @@
 jgraph output.  Its units are the 
 final postscript units.  It's probably best to use the 
-\fB\-p\FR 
+\fB\-p\fR 
 option
 to see what the bounding box is that jgraph produces, and then
 alter that accordingly with
-\fB\fIbbox.\fB\fR
+\fB\fIbbox.\fR
 The main use for this is to change the automatic centering that jgraph
 performs:  Usually the center of the bounding box that jgraph computes 
@@ -334,8 +334,8 @@
 files (the token specifies the filename) which will be copied directly 
 into jgraph's output.
-The \fIpreamble\fB is included at the beginning of the output
+The \fIpreamble\fR is included at the beginning of the output
 (after some initial postscript to set things up for jgraph), 
-and the \fIepilogue\fB is included at the end.  A good use for
-the \fIpreamble\fB is to set up a postscript dictionary if you're
+and the \fIepilogue\fR is included at the end.  A good use for
+the \fIpreamble\fR is to set up a postscript dictionary if you're
 using postscript marks.
 .PD
@@ -365,11 +365,11 @@
 If the curve doesn't exist, then this command creates it and starts
 editing it.  
-\fINewcurve\fB
+\fINewcurve\fR
 and 
-\fIcurve\fB
+\fIcurve\fR
 interact as 
-\fInewgraph\fB
-and
-\fIgraph\fB
+\fInewgraph\fR
+and
+\fIgraph\fR
 do.
 .TP
@@ -413,15 +413,15 @@
 .TP
 \fBcopystring \|[\fIinteger\fB\|]\fR
-\fIString\fB
-and
-\fIcopystring\fB
+\fIString\fR
+and
+\fIcopystring\fR
 are to 
-\fInewstring\fB
+\fInewstring\fR
 as
-\fIcurve\fB
-and
-\fIcopycurve\fB
+\fIcurve\fR
+and
+\fIcopycurve\fR
 are to
-\fInewcurve.\fB
+\fInewcurve\fR.
 .TP
 \fBborder\fR
@@ -430,9 +430,9 @@
 .TP
 \fBnoborder\fR
-\fIBorder\fR\fB
+\fIBorder\fR
 draws a square border around the area defined by the axes.
-\fINoborder\fB
+\fINoborder\fR
 specifies no border.
-\fINoborder\fB
+\fINoborder\fR
 is the default.  
 .TP
@@ -442,13 +442,13 @@
 .TP
 \fBnoclip\fR
-\fIClip\fB
+\fIClip\fR
 specifies that all curves in the graph will be clipped -- that is,
 no points outside of the of axes will be plotted.  Clipping can also be
 specified on a per-curve basis.  The default is
-\fInoclip.\fB
+\fInoclip\fR.
 .TP
 \fBinherit_axes\fR   
 This is an old command which is kept for backward compatibility.
-\fICopycurve.\fB
+\fICopycurve\fR.
 is equivalent to:
 .PP
@@ -465,7 +465,7 @@
 By default, the bottom left-hand corner of each graph is at point
 (0,0) (final postscript units).
-\fIX_translate\fB
-and
-\fIY_translate\fB
+\fIX_translate\fR
+and
+\fIY_translate\fR
 translate the bottom left-hand corner of the graph 
 \fB\|[\fIfloat\fB\|] \fR
@@ -475,10 +475,10 @@
 only one graph is drawn, it will always be centered on the page, 
 regardless of its 
-\fIX_translate\fB
-and
-\fIY_translate\fB
+\fIX_translate\fR
+and
+\fIY_translate\fR
 values.  These values are used for relative placement of the graphs.
    To change the centering of the graphs, use
-\fIbbox.\fB
+\fIbbox.\fR
 .TP
 \fBX \|[\fIfloat\fB\|]\fR
@@ -488,7 +488,7 @@
 \fBY \|[\fIfloat\fB\|]\fR   
 These are the same as 
-\fIX\fB
+\fIX\fR
 and 
-\fIY\fB
+\fIY\fR
 in the
 Top-level commands, except that they let the user continue editing
@@ -501,7 +501,7 @@
 These commands act on the current
 axis as chosen by 
-\fIxaxis\fB
+\fIxaxis\fR
 or
-\fIyaxis\fB
+\fIyaxis\fR
 (see GRAPH EDITING COMMANDS). 
 Axis editing terminates when a graph or top-level command is given. 
@@ -519,5 +519,7 @@
 default is linear.  If the axis is set to be logarithmic, then values
 <= 0.0 will be disallowed, as they are at negative infinity on the
-axis.
+axis. If you are using logarithmic axes and the labels shows 0 0 1 10
+instead of 0.01 0.1 1 10, then you should read "hash_format" in this
+section. Hint: xaxis log hash_format g
 .TP
 \fBmin \|[\fIfloat\fB\|]\fR
@@ -532,7 +534,7 @@
 option.  Unless stated, all units (for example point
 plotting, string plotting, etc.) will be in terms of the
-\fImin\fB
-and
-\fImax\fB
+\fImin\fR
+and
+\fImax\fR
 values of the x and y axes.
 .TP
@@ -557,7 +559,7 @@
 for the value).  By default, each hash mark
 will be labeled with its value.  
-\fIHash\fB
+\fIHash\fR
 and 
-\fIshash\fB
+\fIshash\fR
 are ignored if
 the axes are logarithmic.
@@ -572,9 +574,9 @@
 = -1.
 If 
-\fIhash\fB
+\fIhash\fR
 is set by the user, 
-\fIshash\fB
+\fIshash\fR
 is defaulted to the
-\fImin\fB
+\fImin\fR
 value of the axis.
 .TP
@@ -624,12 +626,12 @@
 Draw the axis line at this point on the other axis. 
 The default is usually the other axis's 
-\fImin, \fB
+\fImin\fR,
 however if 
-\fIhash_scale \fB
+\fIhash_scale \fR
 is positive (see 
-\fIhash_scale \fB
+\fIhash_scale \fR
 under ADVANCED AXIS EDITING), it will be
 the other axis's 
-\fImax.\fB
+\fImax\fR.
 .TP
 \fBnodraw\fR   
@@ -637,22 +639,22 @@
 is useful for plotting points with no axes, and for overlaying graphs
 on top of one another with no clashes.  This is equivalent to
-\fIno_draw_axis,\fB
-\fIno_draw_axis_label,\fB
-\fIno_draw_hash_marks,\fB
-and
-\fIno_draw_hash_labels.\fB
+\fIno_draw_axis\fR,
+\fIno_draw_axis_label\fR,
+\fIno_draw_hash_marks\fR,
+and
+\fIno_draw_hash_labels\fR.
 .TP
 \fBdraw\fR   
 Cancels the effect of 
-\fInodraw.  \fB
+\fInodraw\fR.
 Default = 
-\fIdraw.\fB
+\fIdraw\fR
 This is
 equivalent to 
-\fIdraw_axis,\fB
-\fIdraw_axis_label,\fB
-\fIdraw_hash_marks,\fB
+\fIdraw_axis\fR,
+\fIdraw_axis_label\fR,
+\fIdraw_hash_marks\fR,
 and 
-\fIdraw_hash_labels.\fB
+\fIdraw_hash_labels\fR.
 .TP
 \fBgrid_lines\fR
@@ -661,8 +663,8 @@
 .TP
 \fBno_grid_lines\fR
-\fIGrid_lines\fB
+\fIGrid_lines\fR
 specifies to plot a grid line at each major hash
 mark on this axis.  The default is 
-\fIno_grid_lines.\fB
+\fIno_grid_lines.\fR
 .TP
 \fBmgrid_lines\fR
@@ -671,8 +673,8 @@
 .TP
 \fBno_mgrid_lines\fR
-\fIMgrid_lines\fB
+\fIMgrid_lines\fR
 specifies to plot a grid line at each minor hash
 mark on this axis.  The default is 
-\fIno_mgrid_lines.\fB
+\fIno_mgrid_lines\fR.
 .PD
 .RE
@@ -682,7 +684,7 @@
 These commands act on the current curve as
 chosen by 
-\fInewcurve\fB
+\fInewcurve\fR
 or 
-\fIcurve\fB
+\fIcurve\fR
 (see GRAPH EDITING COMMANDS).  Curve
 editing terminates when a graph or top-level command is given.
@@ -692,7 +694,7 @@
 This sets the points to plot in this
 curve.  The first 
-\fIfloat\fB
+\fIfloat\fR
 is the x value, and the second 
-\fIfloat\fB
+\fIfloat\fR
 is the y
 value of the point.  Points are plotted in the order specified.
@@ -708,10 +710,10 @@
 This allows the user to specify points and ``confidence values'' (otherwise
 known as ``error bars'').  The first two 
-\fIfloats\fB
+\fIfloats\fR
 specify the x and y values of
 the point, as above.  If
 \fBx_epts\fR
 is specified,  then the second two
-\fIfloats\fB
+\fIfloats\fR
 specify range or confidence values
 for the x value of the point.  
@@ -719,10 +721,10 @@
 original point's y value)
 from the original point.  Similarly,
-\fIy_epts\fB
+\fIy_epts\fR
 specifies range or confidence values for the y value of the point.
-\fIpts\fB
-\fIx_epts\fB
-and
-\fIy_epts\fB
+\fIpts\fR
+\fIx_epts\fR
+and
+\fIy_epts\fR
 can all be intermixed. 
 .TP
@@ -745,10 +747,10 @@
 curve points (units are units of the x and y axes).
 Default label values are 0 for x and y, and center justification.
-  \fIPostscript:\fR See the \fIpostscript\fB token below.
-  \fIEps:\fR See the \fIeps\fB token below.
+  \fIPostscript\fR: See the \fIpostscript\fR token below.
+  \fIEps\fR: See the \fIeps\fR token below.
   \fINone\fR means that no mark will be
 plotted (this is useful for drawing lines).  
   There are four types of \fIgeneral\fR marks, which work using the 
-\fIgmarks\fB command described below.  The four marktypes are 
+\fIgmarks\fR command described below.  The four marktypes are 
 \fIgeneral\fR, \fIgeneral_nf\fR, \fIgeneral_bez\fR, and 
 \fIgeneral_bez_nf\fR.
@@ -782,9 +784,9 @@
 \fIgray\fR
 should be from 0 (black) to 1 (white).  Values for
-\fIcolor\fR\fB
+\fIcolor\fR
 should also be from 0 to 1.  They are RGB values, and thus define the 
 amount of red, green and blue in the curve respectively.  Specifying
 color nullifies the gray value, and vice versa.  The default is 
-\fIgray 0\fB
+\fIgray 0\fR
 .TP
 \fBfill \|[\fIfloat\fB\|]\fR   
@@ -795,14 +797,14 @@
 This sets the filling of marks which define an area
 to fill (e.g.  \fIbox\fR, \fIcircle\fR, \fIxbar\fR).  
-\fIfill\fB
+\fIfill\fR
 defines a gray value, and 
-\fIcfill\fB
+\fIcfill\fR
 defines a color value (see 
-\fIgray\fB
-and
-\fIcolor\fB
+\fIgray\fR
+and
+\fIcolor\fR
 above for a description of the units).
 The default is 
-\fIfill 0\fB
+\fIfill 0\fR
 (black).
 .TP
@@ -838,15 +840,15 @@
 .TP
 \fBppattern \fItoken\fB \|[\fIfloat\fB\|]\fR   
-\fIPoly\fB allows the user to make jgraph treat the curve as a 
+\fIPoly\fR allows the user to make jgraph treat the curve as a 
 closed polygon (or in the case of a bezier, a closed bezier curve).
-\fIpfill\fB, \fIpcfill\fB and \fIppattern\fB  specify the 
+\fIpfill\fR, \fIpcfill\fR and \fIppattern\fR  specify the 
 filling of the polygon,
-and work like \fIfill\fB, \fIcfill\fB and \fIpattern\fB above.  
-The default is \fInopoly\fB.
+and work like \fIfill\fR, \fIcfill\fR and \fIpattern\fR above.  
+The default is \fInopoly\fR.
 .TP
 \fBgmarks \|[\|{\fIfloat\fB\|} \|{\fIfloat\fB\|}\|]*\fR   
-\fIGmarks\fB
+\fIGmarks\fR
 is a way for the user to define custom marks.  For each mark on 
-\fI(x,y),\fB
+\fI(x,y)\fR,
 Each pair of 
 \fB\|{\fIfloat_x\fB\|}, \|{\fIfloat_y\fB\|}, \fR
@@ -879,6 +881,6 @@
 be set up so that when the string or file is put to the output, (0, 0) of
 the the axes is in the middle of the mark, it is rotated by
-\fImrotate\fB degrees, and scaled by 
-(\fImarksize_x\fB / 2), \fImarksize_y\fB / 2).
+\fImrotate\fR degrees, and scaled by 
+(\fImarksize_x\fR / 2), \fImarksize_y\fR / 2).
 Thus, the \fIbox\fR mark could be defined as:
 .PP
@@ -888,5 +890,5 @@
 .fi
 .PP
-If the \fImarksize_x\fB is defined to be (0, 0), then jgraph does no
+If the \fImarksize_x\fR is defined to be (0, 0), then jgraph does no
 scaling.  This is useful when the postscript has strings, and the 
 user does not want the strings to be scaled.
@@ -895,5 +897,5 @@
 This allows the user to include an encapsulated postscript file
 and treat it as a mark.  It automatically sets the marktype to
-\fIeps\fB.  The file will be scaled so that the bounding
+\fIeps\fR.  The file will be scaled so that the bounding
 box is \fImarksize\fR units.  Among other things, this allows the
 user to include whole jgraph files as marks.  Please see ad.jgr,
@@ -913,15 +915,15 @@
 .TP
 \fBnorarrows\fR
-\fIRarrows\fB
+\fIRarrows\fR
 specifies to draw an arrow at the end of every line
 segment in the curve.  
-\fILarrows\fB
+\fILarrows\fR
 specifies to draw an arrow at the beginning of every line segment.
 The size of the arrows can be changed by using
-\fIasize.\fB
+\fIasize.\fR
 The default is
-\fInolarrows\fB
-and
-\fInorarrows\fB.
+\fInolarrows\fR
+and
+\fInorarrows\fR.
   Arrows always go exactly to the point specified, with the exception 
 of when the marktype is ``circle''.  In this case, the arrow goes to
@@ -941,7 +943,7 @@
 .TP
 \fBnorarrow\fR
-This is analgous to the above, except that with \fIlarrow\fB, the
+This is analgous to the above, except that with \fIlarrow\fR, the
 only arrow drawn is to the beginning of the first segment in the
-curve, and with \fIrarrow\fB, the only arrow drawn is to the end
+curve, and with \fIrarrow\fR, the only arrow drawn is to the end
 of the last segment.
 .TP
@@ -965,15 +967,15 @@
 \fBapattern \fItoken\fB \|[\fIfloat\fB\|]\fR   
 These control the grayness or color of arrowheads.  
-\fIAfill\fB,
-\fIacfill\fB
+\fIAfill\fR,
+\fIacfill\fR
 and 
-\fIapattern\fB
+\fIapattern\fR
 work in the same way as 
-\fIfill\fB,
-\fIcfill\fB
-and
-\fIpattern\fB
+\fIfill\fR,
+\fIcfill\fR
+and
+\fIpattern\fR
 described above.  The default is
-\fIafill 0\fB
+\fIafill 0\fR
 (black).
 .TP
@@ -984,8 +986,8 @@
 \fInone\fR.  The default is \fInone\fR.  \fIGeneral\fR lets the user define
 his own linetype using the
-\fIglines\fB
+\fIglines\fR
 command described below.  Points are connected in the
 order in which they are inserted using the 
-\fIpts\fB
+\fIpts\fR
 command.
 .TP
@@ -994,5 +996,5 @@
 is as in postscript -- the first number is the length of the first
 dash, the second is the length of the space after the first dash,
-etc.  For example, \fIdotdash\fB could be defined as ``\fIglines\fB 5 3
+etc.  For example, \fIdotdash\fR could be defined as ``\fIglines\fR 5 3
 1 3''.  
 .TP
@@ -1008,5 +1010,5 @@
 .br
 .ns
-\fIBezier\fB
+\fIBezier\fR
 specifies to use the curve's points to define successive bezier curves.
 The first point is the starting point.  The next two are control points
@@ -1017,5 +1019,5 @@
 points, where n is at least 1.
   In bezier curves, marks and arrows only apply to every third point.
-\fINobezier\fB is the default.
+\fINobezier\fR is the default.
 
 .TP
@@ -1027,7 +1029,7 @@
 This turns off clipping.  If clipping was specified for the 
 entire graph, then 
-\fInoclip\fB
+\fInoclip\fR
 has no effect.
-\fINoclip\fB
+\fINoclip\fR
 is the default.
 .TP
@@ -1036,5 +1038,5 @@
 drawing a legend.  (see LABEL EDITING COMMANDS and LEGEND EDITING
 COMMANDS).  Unless the legend entry is 
-\fIcustom\fB,
+\fIcustom\fR,
 setting any label attribute except for the text itself
 will have no effect.
@@ -1083,5 +1085,5 @@
 These set the horizontal justification to left,
 center, and right, respectively.  Default = 
-\fIhjc.\fB
+\fIhjc.\fR
 .TP
 \fBvjt\fR
@@ -1096,5 +1098,5 @@
 These set the vertical justification to top
 center, and bottom, respectively.  Default = 
-\fIvjb.\fB
+\fIvjb.\fR
 .TP
 \fBrotate \|[\fIfloat\fB\|]\fR   
@@ -1102,10 +1104,10 @@
 \fB\|[\fIfloat\fB\|] \fR
 degrees.  The point of rotation is defined by the
-\fIvj\fB
+\fIvj\fR
 and 
-\fIhj\fB
+\fIhj\fR
 commands.  For example, to rotate 90 degrees about the center of a string, 
 one would use
-\fIvjc hjc rotate 90.\fB
+\fIvjc hjc rotate 90.\fR
 .TP
 \fBlgray \|[\fIfloat\fB\|]\fR
@@ -1115,7 +1117,7 @@
 \fBlcolor \|[\fIfloat\fB \fIfloat\fB \fIfloat\fB\|]\fR
 These control the color or the grayness of the label.  It works just as
-\fIgray\fB
-and
-\fIcolor\fB
+\fIgray\fR
+and
+\fIcolor\fR
 do for curves and axes.  The default depends on the context.  For example,
 for strings and the title, the default is black.  For axis labels and hash
@@ -1139,11 +1141,11 @@
 fontsize to be 18, you had to set it in each entry's curve.  Now,
 default legend entry characteristics are set using the 
-\fIdefaults\fB
+\fIdefaults\fR
 keyword.  Unless a
-\fIcustom\fB
+\fIcustom\fR
 legend is specified, these default values override any values set in 
 the entry's curve.  Thus, to get all entries to have a fontsize of
 18, it must be set using 
-\fIdefaults fontsize 18.\fB
+\fIdefaults fontsize 18\fR.
 
 If legend editing seems cryptic, try the following example:
@@ -1169,5 +1171,5 @@
 .ns
 .TP
-\fBoff\R
+\fBoff\fR
 These turn printing of the legend on and off.  The default is on
 (but, of course, if there are no curve labels defined, there will
@@ -1224,14 +1226,14 @@
 .ns
 .TP
-\fIright\fB
+\fIright\fR
 These will automatically produce a legend to the left or
 the right of the graph.  
-\fILeft\fB
+\fILeft\fR
 is equivalent to 
-\fIdefaults hjr vjc\fB
-and
-\fIright\fB
+\fIdefaults hjr vjc\fR
+and
+\fIright\fR
 is equivalent to 
-\fIdefaults hjl vjc.\fB
+\fIdefaults hjl vjc\fR.
 .TP
 \fBtop\fR   
@@ -1242,11 +1244,11 @@
 These will automatically produce a legend on the top or
 the bottom of the graph.  
-\fITop\fB
+\fITop\fR
 is equivalent to 
-\fIdefaults hjl vjb\fB
+\fIdefaults hjl vjb\fR
  and
-\fIbottom\fB
+\fIbottom\fR
 is equivalent to
-\fIdefaults hjl vjt.\fB
+\fIdefaults hjl vjt\fR.
 .TP
 \fBx \|[\fIfloat\fB\|]\fR
@@ -1257,11 +1259,11 @@
 These are included mainly for backward compatability to earlier
 versions of jgraph.  Setting 
-\fIx\fB
+\fIx\fR
 and 
-\fIy\fB
+\fIy\fR
 is equivalent to ``defaults x 
-\fIfloat\fB
+\fIfloat\fR
 y
-\fIfloat\fB
+\fIfloat\fR
 hjl vjt''
 .TP
@@ -1269,9 +1271,9 @@
 This lets the user control where each individual legend
 entry goes.  The values of the 
-\fIdefaults\fB
+\fIdefaults\fR
 fields are ignored, and instead, the values of the curve's
 labels are used.  All justifications have defined results, except 
 for 
-\fIhjc\fB.
+\fIhjc\fR.
 Similarly, rotation other than 0 is likely to produce bad effects.
 .PD
@@ -1293,11 +1295,11 @@
 These specify either the grayness of the axis or its color.  Values
 for
-\fIgray\fB
+\fIgray\fR
 should be from 0 (black) to 1 (white).  Values for
-\fIcolor\fB
+\fIcolor\fR
 should also be from 0 to 1.  They are RGB values, and thus define the
 amount of red, green and blue in the axis respectively.  Specifying
 color nullifies the gray value, and vice versa.  The default is
-\fIgray 0\fB.
+\fIgray 0\fR.
 These values affect every part of the axis:  the label,
 the hash marks and labels, the axis line and the grid lines.
@@ -1320,19 +1322,19 @@
 axis lines.
 The default
-\fIgrid_gray\fB
-and
-\fIgrid_color\fB
+\fIgrid_gray\fR
+and
+\fIgrid_color\fR
 is the same as the axis's
-\fIgray\fB
-and
-\fIcolor\fB.
+\fIgray\fR
+and
+\fIcolor\fR.
 The default
-\fImgrid_gray\fB
-and
-\fImgrid_color\fB
+\fImgrid_gray\fR
+and
+\fImgrid_color\fR
 is the same as 
-\fIgrid_gray\fB
-and
-\fIgrid_color\fB.
+\fIgrid_gray\fR
+and
+\fIgrid_color\fR.
 .TP
 \fBhash_at \|[\fIfloat\fB\|]\fR   
@@ -1350,15 +1352,15 @@
 This is so that the user can change the fontsize, justification,
 etc., of the hash labels.  Editing 
-\fIhash_labels \fB
+\fIhash_labels \fR
 is just like editing
 normal labels (see LABEL EDITING COMMANDS), except that the 
-\fI:,\fB
-\fIx,\fB
-and
-\fIy\fB
+\fI:\fR,
+\fIx\fR,
+and
+\fIy\fR
 values are all ignored. Defaults for hash labels are as
 follows: Fontsize=9, Font=``Times-Roman'', Justification is dependent
 on whether it is the x or y axis and whether 
-\fIhash_scale\fB
+\fIhash_scale\fR
 is positive or negative.
 .TP
@@ -1373,5 +1375,5 @@
 either above or below the axis.  This command changes where they are
 drawn.  
-\fIHash_scale\fB
+\fIHash_scale\fR
 still determines whether they are drawn above or
 below this point, and their size.
@@ -1381,8 +1383,8 @@
 drawn either above or below the hash marks (again, this is dependent
 on 
-\fIhash_scale\fB).
+\fIhash_scale\fR).
 This command changes where they are drawn. 
 Justification and fontsize, etc., can be changed with the
-\fIhash_labels\fB
+\fIhash_labels\fR
 command.
 .TP
@@ -1396,15 +1398,15 @@
 \fBjgraph \fR
 will automatically create hash marks according to 
-\fIhash,\fB
-\fImhash\fB
-and
-\fIshash\fB
+\fIhash\fR,
+\fImhash\fR
+and
+\fIshash\fR
 (or 
-\fIlog_base\fB
-and
-\fImhash\fB
+\fIlog_base\fR
+and
+\fImhash\fR
 for logarithmic axes). 
 The default is 
-\fIauto_hash_marks.\fB
+\fIauto_hash_marks\fR.
 .TP
 \fBauto_hash_labels\fR
@@ -1417,7 +1419,7 @@
 \fBjgraph \fR
 will automatically create hash labels for the
-\fIauto_hash_marks\fB.
+\fIauto_hash_marks\fR.
 Default = 
-\fIauto_hash_labels\fB.
+\fIauto_hash_labels\fR.
 .TP
 \fBdraw_axis\fR
@@ -1428,5 +1430,5 @@
 This toggles whether or not the axis
 line is drawn.  Default = 
-\fIdraw_axis.\fB
+\fIdraw_axis\fR.
 .TP
 \fBdraw_axis_label\fR
@@ -1437,8 +1439,8 @@
 This toggles whether or
 not the axis label (as editted by the 
-\fIlabel\fB
+\fIlabel\fR
 command) is drawn.
 Default = 
-\fIdraw_axis_label.\fB
+\fIdraw_axis_label\fR.
 .TP
 \fBdraw_hash_marks\fR
@@ -1449,9 +1451,9 @@
 This toggles whether or
 not the hash marks (both automatic and those created with 
-\fIhash_at\fB
+\fIhash_at\fR
 and 
-\fImhash_at\fB)
+\fImhash_at\fR)
 are drawn.  Default = 
-\fIdraw_hash_marks.\fB
+\fIdraw_hash_marks\fR.
 .TP
 \fBdraw_hash_labels\fR
@@ -1462,5 +1464,5 @@
 This toggles whether or
 not the hash labels are drawn.  Default = 
-\fIdraw_hash_labels.\fB
+\fIdraw_hash_labels\fR.
 .PD
 .RE
@@ -1471,17 +1473,17 @@
 along the appropriate axis.  As a default, they are printed at the
 place denoted by the most recent 
-\fIhash_at\fB
+\fIhash_at\fR
 or 
-\fImhash_at\fB
+\fImhash_at\fR
 for this
 axis, but this can be changed by the 
-\fIat\fB
+\fIat\fR
 command.  If there has been
 no 
-\fIhash_at\fB
+\fIhash_at\fR
 or 
-\fImhash_at,\fB
+\fImhash_at\fR,
 then an
-\fIat\fB
+\fIat\fR
 command must be given, or
 there will be an error.  Hash editing terminates when either one of
@@ -1510,7 +1512,7 @@
 \fBFunction plotting\fR
 With the 
-\fIinclude\fB
+\fIinclude\fR
 and 
-\fIshell\fB
+\fIshell\fR
 statement, it's easy to
 create a file of points of a function with a c or awk program, and
@@ -1530,7 +1532,7 @@
 a user desires.  To embellish the graph with extra text, axes, lines,
 etc., it is helpful to use 
-\fIcopygraph.\fB
+\fIcopygraph.\fR
 The following example graphs show a few examples of different features
-of jgraph.  They should be in the directory JGRAPH_DIR.
+of jgraph.  They should be in the directory /usr/doc/examples/jgraph.
 .sp
 - acc.jgr is a simple bar graph.  Acc.tex is also included to show
@@ -1545,5 +1547,5 @@
 - sin.jgr shows how a sin function can be plotted using a simple c
 program to produce the sin wave.  Moreover, this file shows a use of
-\fIcopygraph\fB
+\fIcopygraph\fR
 to plot an extra x and y axis at the 0 point.
 .sp
@@ -1571,7 +1573,7 @@
 complicated output graph can be quite concisely and simply stated.
 In this graph, the x axis is a time line.  It shows usage of the 
-\fIhash_label\fB
-and
-\fIhash_labels\fB
+\fIhash_label\fR
+and
+\fIhash_labels\fR
 commands, as well as displaying how jgraph lets you extract data from
 output files with awk.
@@ -1598,9 +1600,9 @@
 To view these graphs, use jgraph -P, and view the resulting output
 file with
-\fIgs,\fB
+\fIgs\fR,
 or a similar postscript viewer.
 To make a hard copy of these graphs, pipe the output of jgraph 
 -P directly to 
-\fIlpr.\fB
+\fIlpr\fR.
 
 .SH USING JGRAPH TO DRAW PICTURES
@@ -1608,8 +1610,8 @@
 preprocessor to make drawings.  There are two advantages 
 using jgraph to draw pictures instead of using standard drawing tools like
-\fIxfig\fB,
-\fIfigtool\fB,
+\fIxfig\fR,
+\fIfigtool\fR,
 or
-\fIidraw\fB.
+\fIidraw\fR.
 The first is that with jgraph, you know exactly where strings, lines,
 boxes, etc, will end up, because you plot them explicitly.  The second
@@ -1625,29 +1627,112 @@
 If you'd like to see some more complex pictures drawn with jgraph, as
 well as some hints to make picture-drawing easier, send me email
-(jsp@princeton.edu).
-
-.SH EMBEDDING THE OUTPUT IN LATEX
-I haven't read the manuals, but the way I've been loading these files
-into LaTeX has been as follows:
-.PP
+(plank@cs.utk.edu).
+
+.SH SUPPORT FOR OTHER FONT ENCODINGS
+If you want to use non-english characters to set labels or titles,
+set enviroment variable JGRAPH_ENCODING with the font encoding that
+you need. This value will be passed directly to the postscript.
+
+Ex. to use ISO-8859-1 characters, try:
 .nf
-1.  Toward the beginning of my LaTeX file, I've had ``\\input{psfig}''
-2.  Where I've wanted my file, I've put:
-
-    \\begin{figure}
-    \\centerline{\\psfig{figure=<path-name>/<filename-of-jgraph-output>}}
-    \\end{figure}
-
-    Some versions of dvips or dvi2ps work without the path-name.  Others
-    require that the path-name be present.
-
-3.  After running latex on the file, do
-
-    lpr -d file.dvi
-
-4.  If that doesn't work, try dvips-ing the file and printing the postscript.
+
+   export JGRAPH_ENCODING=ISOLatin1Encoding
 
 .fi
-.PP
+Note: that only works with default fonts. if you use 'font' in stdin
+to specify another font, it won't work.
+
+You also have the possibility to expand the bounding box if jgraph
+cuts some acute, tilde or special chars near the border; try:
+.nf
+
+   export JGRAPH_BORDER=5
+
+.fi
+This support is currently 'testing' code. Send bugs about it
+to pzn@debian.org
+
+.SH INTEGRATION WITH LATEX
+.PP
+.nf
+1. At the top, say
+   \\usepackage{graphics}
+
+2. The floating object is done using:
+
+   \\begin{figure}
+   \\begin{center}
+   \\includegraphics{a.eps}
+   \\end{center}
+   \\end{figure}
+   
+3. Now go through dvips as usual and the .ps file will work.
+.fi
+.PP
+.SH INTEGRATION WITH PDFLATEX
+
+If you are using pdflatex, it requires .pdf files and not .eps
+files. In that case, you have to run epstopdf on the .eps file to get
+a .pdf file. After that,
+.br
+   \\includegraphics{a.pdf}
+.br
+does the trick.
+.SH SCALING THE INCLUDED GRAPHICS OBJECT
+Sometimes you need to change the size of the included object at LaTeX
+time. In that case, you need
+.br
+   \\usepackage{graphicx}
+.br
+instead of graphics, and then say something like
+
+    \\includegraphics[width=7cm]{a.eps}
+ or
+    \\includegraphics[height=7cm]{a.eps}
+
+you can also omit the .eps/.pdf suffix:
+    \\includegraphics[height=7cm]{a}
+
+a.eps and a.pdf can both exist, and includegraphics will automatically
+choose the correct one for postscript or pdf output, depending if you
+are using latex of pdflatex.
+
+.SH AUTOMATION USING MAKE
+You can automate the mapping from .jgr -> .eps or .jgr -> .pdf
+in your Makefile using these rules:
+.nf
+
+--------- cut here ---------
+%.eps : %.jgr
+	jgraph $< > $@
+%.pdf : %.jgr
+	jgraph $< | epstopdf --filter > $@
+--------- cut here ---------
+.fi
+
+jgraph can also return the exit status correctly, so it is also a good
+idea to use it in your scripts to prevent bad .eps files if the .jgr
+source is bad. The following Makefile can handle its exit status.
+.nf
+
+--------- cut here ---------
+%.eps : %.jgr
+	jgraph $< > $@; \\
+	if [ "$$?" != "0" ]; then \\
+	  rm -f $@; \\
+	  exit 1; \\
+	fi
+%.pdf : %.jgr
+	TMP=`tempfile`; jgraph $< > $${TMP}; \\
+	if [ "$$?" == "0" ]; then \\
+	  cat $${TMP} | epstopdf --filter > $@; \\
+	  rm -f $${TMP}; \\
+	else \\
+	  rm -f $${TMP} $@; \\
+	  exit 1; \\
+	fi;
+--------- cut here ---------
+.fi
+
 .SH BUGS
 Logarithmic axes cannot contain points <= 0.  If I have 
@@ -1658,5 +1743,5 @@
 own hash labels.  
 .sp
-There may well be loads of other bugs.  Send to jsp@princeton.edu.
+There may well be loads of other bugs.  Send to plank@cs.utk.edu.
 .sp
 
Index: /trunk/Jgraph/makefile
===================================================================
--- /trunk/Jgraph/makefile	(revision 418)
+++ /trunk/Jgraph/makefile	(revision 419)
@@ -7,9 +7,8 @@
 # jgraph.1 to be the directory containing the example jgraphs.
 
-CC = gcc -LCC
+CC = cc
 
 OBJS = draw.o \
 		edit.o \
-		jgraph.o \
 		list.o \
 		printline.o \
@@ -43,4 +42,5 @@
 	wortman.jps
 
+LOADLIBES = -lm
 
 all: jgraph
@@ -58,10 +58,10 @@
 .tex.dvi:
 	latex $*.tex
-.c.o: 
-	$(CC)  -c -g $*.c
+#.c.o: 
+#	$(CC)  -c -g $*.c
 
 
 jgraph: $(OBJS)
-	$(CC) -g $(OBJS) -lm -o jgraph
+#	$(CC) -g $(OBJS) -lm -o jgraph
 
 sin:	sin.o
@@ -76,8 +76,8 @@
 sin3.jps: sin3.pts
 tree1.jps: tree.awk
-	( echo "4 3" | nawk -f tree.awk ; echo "xaxis size 5.4" ) | \
+	( echo "4 3" | awk -f tree.awk ; echo "xaxis size 5.4" ) | \
            jgraph -P > tree1.jps
 tree2.jps: tree.awk
-	( echo "5 2" | nawk -f tree.awk ; echo "xaxis size 5.4" ) | \
+	( echo "5 2" | awk -f tree.awk ; echo "xaxis size 5.4" ) | \
            jgraph -P > tree2.jps
 
@@ -94,3 +94,3 @@
 token.o: token.c list.h
 clean: 
-	rm -f *.o a.out *.jps
+	rm -f *.o a.out *.jps jgraph
Index: /trunk/Jgraph/printline.c
===================================================================
--- /trunk/Jgraph/printline.c	(revision 418)
+++ /trunk/Jgraph/printline.c	(revision 419)
@@ -8,4 +8,5 @@
 #include "jgraph.h"
 #include <stdio.h>
+#include <assert.h> //by pzn@debian.org
 
 #define LINEWIDTHFACTOR 0.700
@@ -229,4 +230,5 @@
   float fnl;
   char *s;
+  unsigned char *s_7bit; // added by pzn@debian.org
 
   if (l->label == CNULL) return;
@@ -267,6 +269,30 @@
 
   s = l->label;
+  
   for (i = 0; i <= nlines; i++) {
-    printf("(%s) dup stringwidth pop ", s);
+    // BEGIN added by pzn@debian.org
+    // converts 8bit ascii chars to octal value;
+    // 7bit are not converted
+    {
+       int i, j=0, len;
+       len=strlen(s);
+       s_7bit=malloc(len*4+1);
+       assert(s_7bit!=NULL);
+       for (i=0; i<=len; i++) {
+	 if((unsigned char)s[i]<128) {
+	   //char is ascii 7bit
+	   s_7bit[j]=s[i];
+	   j++;
+	 } else {
+	   //char must be converted to octal
+           sprintf(s_7bit+j,"\\%03o",(unsigned char)s[i]);
+	   j+=4;
+	 }
+       }
+       s_7bit[j-1]=0;
+    }
+    //printf("(%s) dup stringwidth pop ", s); //disabled by pzn
+    printf("(%s) dup stringwidth pop ", s_7bit); free(s_7bit);
+    // END added by pzn
     if (l->hj == 'c') {
       printf("2 div neg 0 moveto\n");
