[llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/Makefile alabel.c arc.c circle.c closepl.c color.c cont.c dot.c draw_line.c erase.c extern.h fill.c fontname.c fontsize.c label.c libplot.h line.c linemod.c move.c openpl.c plot.c point.c rotate.c space.c
Chris Lattner
lattner at cs.uiuc.edu
Tue Oct 5 14:07:36 PDT 2004
Changes in directory llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig:
Makefile added (r1.1)
alabel.c added (r1.1)
arc.c added (r1.1)
circle.c added (r1.1)
closepl.c added (r1.1)
color.c added (r1.1)
cont.c added (r1.1)
dot.c added (r1.1)
draw_line.c added (r1.1)
erase.c added (r1.1)
extern.h added (r1.1)
fill.c added (r1.1)
fontname.c added (r1.1)
fontsize.c added (r1.1)
label.c added (r1.1)
libplot.h added (r1.1)
line.c added (r1.1)
linemod.c added (r1.1)
move.c added (r1.1)
openpl.c added (r1.1)
plot.c added (r1.1)
point.c added (r1.1)
rotate.c added (r1.1)
space.c added (r1.1)
---
Log message:
Another benchmark without an input
---
Diffs of the changes: (+1543 -0)
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/Makefile
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/Makefile:1.1
*** /dev/null Tue Oct 5 16:07:35 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/Makefile Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,5 ----
+ LEVEL = ../../../..
+
+ PROG = plot2fig
+ include $(LEVEL)/MultiSource/Makefile.multisrc
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/alabel.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/alabel.c:1.1
*** /dev/null Tue Oct 5 16:07:35 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/alabel.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,92 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+ #include <math.h>
+ #include <stdio.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ #include <ctype.h>
+ #include "libplot.h"
+ #include "extern.h"
+
+ /* ALABEL takes three arguments X_JUSTIFY, Y_JUSTIFY, and S and places
+ the label S according to the x and y axis adjustments specified in
+ X_JUSTIFY and Y_JUSTIFY respectively. X_JUSTIFY is a character
+ containing either l, c, or r for left, center or right justified with
+ respect to the current x coordinate. Y_JUSTIFY is a character
+ containing either b, c, or t for placing the bottom center or top of
+ the label even with the current y coordinate. S is a string containing
+ the label. The current point is moved to follow the end of the text. */
+
+ int alabel (int x_justify, int y_justify, char *s)
+ {
+ /* int i; this variable is never used */
+ char *p;
+ int x_justification = 0;
+ double y_offset = 0.;
+
+ draw_line ();
+ switch( x_justify) {
+ case 'l':
+ x_justification = 0;
+ break;
+ case 'c':
+ x_justification = 1;
+ break;
+ case 'r':
+ x_justification = 2;
+ break;
+ }
+ switch( y_justify) {
+ case 't':
+ y_offset = 1.1;
+ break;
+ case 'c':
+ y_offset = 0.5;
+ break;
+ case 'b':
+ y_offset = 0.0;
+ break;
+ }
+
+ /* ignore leading white space */
+ p = s;
+ while (isspace(*p))
+ p++;
+
+ /* only output the string if it contains non-whitespace characters. */
+ if (strlen(p))
+ printf( "%d %d %d %d %d %d %d %.3f %d %d %d %d %d %s\1\n",
+ 4, /* text object */
+ x_justification, /* horzontal justification */
+ font_id, /* font */
+ font_size, /* point size */
+ 0, /* pen */
+ 0, /* color */
+ 0, /* depth */
+ text_rotation, /* angle of rotation (float) */
+ 0, /* flags */
+ 8, /* height (pixels) */
+ 8, /* length (pixels) */
+ (int) ((last_x - x_input_min)/ x_scale + x_output_min),
+ (int) ((last_y - y_input_min)/ y_scale + y_output_min
+ + font_size * y_offset * 72 / 80),
+ p);
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/arc.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/arc.c:1.1
*** /dev/null Tue Oct 5 16:07:35 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/arc.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,60 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the arc routine, which is a standard part of the plot
+ library. It draws an arc with the center at xc,yc, the beginning at
+ x0,y0 and the ending at x1,y1 */
+
+ #include <math.h>
+ #include <stdio.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ /*
+ extern int printf();
+ extern int fprintf();
+ #ifndef mips
+ extern char *sprintf();
+ #endif
+ extern int fputs(), fputc();
+ */
+
+ #include "libplot.h"
+ #include "extern.h"
+
+ int arc (int xc, int yc, int x0, int y0, int x1, int y1)
+ {
+ draw_line ();
+ printf("%d %d %d %d %d %d %d %d %.3f %d %d %d %.3f %.3f %d %d %d %d %d %d\n",
+ 5 /* arc object */, 1, line_style, 0 /* thickness */,
+ 0 /* black */, 0, 0, fill_level,
+ dash_length, 0 /* clockwise */,
+ 0, 0,
+ (int) ((xc - x_input_min)/ x_scale + x_output_min),
+ (int) ((yc - y_input_min)/ y_scale + y_output_min),
+ (int) ((x0 - x_input_min)/ x_scale + x_output_min),
+ (int) ((y0 - y_input_min)/ y_scale + y_output_min),
+ (int) ((x1 - x_input_min)/ x_scale + x_output_min),
+ (int) ((y1 - y_input_min)/ y_scale + y_output_min),
+ (int) ((x1 - x_input_min)/ x_scale + x_output_min),
+ (int) ((y1 - y_input_min)/ y_scale + y_output_min));
+
+ move_nasko (xc, yc);
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/circle.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/circle.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/circle.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,43 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the circle routine, which is a standard part of the plot
+ library. It draws a circle given the center x,y and the radius */
+
+ #include <math.h>
+ #include <stdio.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ #include "libplot.h"
+ #include "extern.h"
+ /*
+ extern int printf();
+ extern int fprintf();
+ #ifndef mips
+ extern char *sprintf();
+ #endif
+ extern int fputs(), fputc();
+ */
+
+ int circle (int x, int y, int r)
+ {
+ arc (x, y, x+r, y, x+r, y);
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/closepl.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/closepl.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/closepl.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,37 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the closepl routine, which is a standard part of the plot
+ library. Normally it closes the plotting device. */
+
+ #include <stdio.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ #include "libplot.h"
+ #include "extern.h"
+ extern int fputs(), fputc();
+
+ int closepl (void)
+ {
+ draw_line ();
+ return 0;
+ }
+
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/color.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/color.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/color.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,37 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the color routine, which is an extension to the plot
+ library. It changes the color of the following drawing operations. */
+
+ #include "libplot.h"
+ #include "extern.h"
+
+ /* FGCOLOR_RED, FGCOLOR_GREEN and FGCOLOR_BLUE indicate the foreground
+ color of all plot. For each the range of intensity is from 0 to 1 so
+ that a value of (0,0,0) represents black and a value of (1,1,1)
+ indicates white. */
+
+ double fgcolor_red=0., fgcolor_green=0., fgcolor_blue=0.;
+
+ int color ( int red, int green, int blue)
+ {
+ fgcolor_red = red / 0xffff;
+ fgcolor_green = green / 0xffff;
+ fgcolor_blue = blue / 0xffff;
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/cont.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/cont.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/cont.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,64 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the cont routine, which is a standard part of the plot
+ library. It continues a line from the last point drawn to the point
+ specified by x and y.
+ */
+ #include <stdio.h>
+ #include "libplot.h"
+ #include "extern.h"
+
+ int last_x=0, last_y = 0; /* location of the last coordinates used */
+
+ int PointsInLine=0;
+
+ int cont(int x, int y)
+ {
+ if (PointsInLine <= 1)
+ {
+ printf( "%d %d %d %d %d %d %d %d %.3f %d %d %d\n\t",
+ 2, /* polyline object */
+ 1, /* polyline subtype */
+ line_style, /* style */
+ 1, /* thickness */
+ 0, /* color */
+ 0, /* depth */
+ 0, /* pen */
+ fill_level, /* area fill */
+ dash_length, /* style val */
+ 0, /* radius */
+ 0, /* forward arrow */
+ 0 /* backward arrow */
+ );
+ }
+ if (PointsInLine == 1)
+ {
+ printf(" %d %d",
+ (int) ((last_x - x_input_min)/ x_scale + x_output_min),
+ (int) ((last_y - y_input_min)/ y_scale + y_output_min));
+ }
+
+ PointsInLine++;
+ printf(" %d %d",
+ (int) ((x - x_input_min)/ x_scale + x_output_min),
+ (int) ((y - y_input_min)/ y_scale + y_output_min));
+ last_x = x;
+ last_y = y;
+
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/dot.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/dot.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/dot.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,31 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the dot routine, which is an extension to the plot
+ library. this is an extentsion and may be modified. Although I have
+ seen support for this in other plot(1g) programs, I haven't yet found
+ out exactly what `dot' is supposed to do, so it is not yet implemented
+ fully. */
+
+ #include "libplot.h"
+ #include "extern.h"
+
+ int dot (int x, int y, int dx, int n, char pattern)
+ {
+ point (x, y);
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/draw_line.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/draw_line.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/draw_line.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,56 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the draw_line routine, which is used by the other plot
+ library routines. It marks the end of a polyline obect in the output. */
+
+ #include <math.h>
+ #include <stdio.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ /*
+ extern int perror();
+ extern int exit();
+ extern int printf();
+ extern int fprintf();
+ #ifndef mips
+ extern char *sprintf();
+ #endif
+ extern int fputs(), fputc();
+ #ifndef hpux
+ extern void *malloc();
+ extern void *realloc();
+ #endif
+ */
+
+ #include "libplot.h"
+ #include "extern.h"
+
+ /* draw a line using all the accumulated points if there are any. */
+
+ int draw_line (void)
+ {
+ if (PointsInLine > 1)
+ {
+ printf( " 9999 9999\n");
+ PointsInLine = 0;
+ }
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/erase.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/erase.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/erase.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,29 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the erase routine, which is a standard part of the plot
+ library. It erases the page.
+ */
+
+ #include "libplot.h"
+ #include "extern.h"
+
+ int erase (void)
+ {
+ return 0;
+ }
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/extern.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/extern.h:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/extern.h Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,44 ----
+ /* plot, unix plot to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute
+ plot, but only under the conditions described in the GNU General
+ Public License. A copy of this license is supposed to have been given
+ to you along with plot so you can know your rights and
+ responsibilities. It should be in a file named COPYING. Among other
+ things, the copyright notice and this notice must be preserved on all
+ copies. */
+
+ /* this file contains all the exernal references between plot library
+ functions. The are not guaranteed to exist for a particular device
+ and thus are not made available to the user in general. */
+
+ extern int font_id;
+ extern int font_size;
+ extern float text_rotation;
+ extern int line_style;
+ extern int last_x, last_y;
+ extern int PointsInLine;
+ extern float dash_length;
+ extern int fill_level;
+
+ extern double x_input_min; /* minimum input x coordinate */
+ extern double y_input_min; /* minimum input y coordinate */
+ extern double x_output_min; /* minimum output x coordinate */
+ extern double y_output_min; /* minimum output y coordinate */
+ extern double x_output_max; /* maximum output x coordinate */
+ extern double y_output_max; /* maximum output y coordinate */
+ extern double scaleup; /* maximum input to output scaleing of x and y */
+ extern double x_scale; /* input to output scaleing for x */
+ extern double y_scale; /* input to output scaleing for y */
+
+ /* For convenience - some machines do not define M_PI. */
+ #ifndef M_PI
+ #define M_PI 3.14159265358979323846264
+ #endif
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fill.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fill.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fill.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,51 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+ /* This file is the fill routine, which is an extension to the plot
+ library. It changes the grey level of the fill pattern for all closed
+ paths of the following drawing operations. */
+
+ #include "libplot.h"
+ #include "extern.h"
+
+ int fill_level = 0; /* default, no fill */
+
+ /* FILL sets the intensity of the filler for closed paths. LEVEL ranges
+ from 1 to 0xFFFF. A value of 1 represents black and a value of 0xFFFF
+ indicates white. A value of 0 represents no fill - transparent. */
+
+ int fill (int level)
+ {
+ if (level == 0)
+ {
+ fill_level = 0;
+ }
+ else
+ {
+ fill_level = 5 * ((double)level - 1.)/0xFFFE;
+ /* The value of fill level should be between 1 and 5,
+ which is enforced here. */
+ if (fill_level > 5)
+ {
+ fill_level = 5;
+ }
+ else if (fill_level < 1)
+ {
+ fill_level = 1;
+ }
+ }
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontname.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontname.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontname.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,125 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* FONTNAME takes a string argument S containing the name of the
+ desired current font and sets the current font to that name. */
+
+ #include <stdio.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ #include "libplot.h"
+ #include "extern.h"
+ extern int fprintf(FILE *, const char *, ...);
+
+ /* a simple fixed string matcher. match returns
+ 1 if there is a match for s1 in s2, else 0. */
+ int match (char *s1, char *s2)
+ {
+ int len2, i;
+ len2 = strlen (s2);
+
+ for (i=0; i<len2; i++)
+ {
+ if (strcmp (s1, &s2[i]) == 0)
+ {
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ int font_id = 0; /* the default font */
+
+ #ifdef SOLARIS
+ /* XZ: use regcmp() and regex() instead of re_comp() and re_exec() */
+ /* PAS (6/3/96): use regcomp() and regexec() from regex.h instead of
+ re_comp() and re_exec() on the understanding that it only has to
+ compile for our purposes, not run. */
+
+ #include <regex.h>
+
+ int fontname(char *s)
+ {
+ int r;
+ regex_t *res;
+
+ r = regcomp (res,s,1);
+ if (!r)
+ {
+ fprintf (stderr, "error in matching fontname!\n");
+ fprintf (stderr, "Fontname `%s' ignored.\n", s);
+ return 0;
+ }
+
+ #define re_exec(x) regexec(res,x,1,&res,1)
+
+ if (re_exec("typewriter")
+ || re_exec("courier"))
+ font_id = 5;
+ else if (re_exec("modern"))
+ font_id = 4;
+ else if (re_exec("italic")
+ || re_exec("oblique"))
+ font_id = 3;
+ else if (re_exec("bold"))
+ font_id = 2;
+ else if (re_exec("times")
+ || re_exec("roman"))
+ font_id = 2;
+ else
+ fprintf (stderr, "Unrecognized font name `%s' ignored.\n", s);
+
+ return 0;
+ }
+
+ #else
+
+ int fontname(char *s)
+ {
+ char *res;
+
+ res = (char *) re_comp (s);
+ if (res)
+ {
+ fprintf (stderr, "error in matching fontname: %s\n", res);
+ fprintf (stderr, "Fontname `%s' ignored.\n", s);
+ return 0;
+ }
+
+ if (re_exec("typewriter")
+ || re_exec("courier"))
+ font_id = 5;
+ else if (re_exec("modern"))
+ font_id = 4;
+ else if (re_exec("italic")
+ || re_exec("oblique"))
+ font_id = 3;
+ else if (re_exec("bold"))
+ font_id = 2;
+ else if (re_exec("times")
+ || re_exec("roman"))
+ font_id = 2;
+ else
+ fprintf (stderr, "Unrecognized font name `%s' ignored.\n", s);
+
+ return 0;
+ }
+
+ #endif
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontsize.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontsize.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontsize.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,30 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* FONTSIZE takes a single integer argument SIZE and sets the font
+ size accordingly. */
+
+ #include "libplot.h"
+ #include "extern.h"
+
+ int font_size = 12;
+
+ int fontsize(int size)
+ {
+ font_size = size;
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/label.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/label.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/label.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,30 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the label routine, which is a standard part of the plot
+ library. It draws a label at the most recently used coordinate. */
+
+ #include <math.h>
+ #include <stdio.h>
+ #include "libplot.h"
+ #include "extern.h"
+
+ int label(char *s)
+ {
+ (void) alabel ('l', 'b', s);
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/libplot.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/libplot.h:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/libplot.h Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,55 ----
+ /* plot, unix plot to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY. No author or distributor accepts responsibility to anyone for the
+ consequences of using it or for whether it serves any particular purpose or
+ works at all, unless he says so in writing. Refer to the GNU General Public
+ License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot, but
+ only under the conditions described in the GNU General Public License. A copy
+ of this license is supposed to have been given to you along with plot so
+ you can know your rights and responsibilities. It should be in a file named
+ COPYING. Among other things, the copyright notice and this notice must be
+ preserved on all copies. */
+
+ #ifndef _PLOT3_H
+ #define _PLOT3_H
+
+ /* This elides the argument prototypes if the compiler does not
+ supprort them. The name protarg is chosen in hopes that it will not
+ collide with any others. */
+ #ifdef __STDC__
+ #define protarg(a) a
+ #else
+ #define protarg(a) ()
+ #endif
+
+ /* the standard library of plot functions */
+ extern int arc protarg ((int xc, int yc, int x0, int y0, int x1, int y1));
+ extern int circle protarg ((int x, int y, int r));
+ extern int closepl protarg (());
+ extern int cont protarg ((int x, int y));
+ extern int erase protarg (());
+ extern int label protarg ((char *s));
+ extern int line protarg ((int x0, int y0, int x1, int y1));
+ extern int linemod protarg ((char *s));
+ extern int move_nasko protarg ((int x, int y));
+ extern int openpl protarg (());
+ extern int point protarg ((int x, int y));
+ extern int space protarg ((int x0, int y0, int x1, int y1));
+
+ /* Extensions to the library for postscript */
+ extern int alabel protarg ((int x_justify, int y_justify, char *s));
+ extern int color protarg ((int red, int green, int blue));
+ extern int draw_line protarg (());
+ extern int fill protarg ((int level));
+ extern int fontname protarg ((char *s));
+ extern int fontsize protarg ((int size));
+ extern int rotate protarg ((int x, int y, int angle));
+
+ /* internally used routines */
+ extern int draw_line protarg (());
+
+ #endif /* _PLOT3_H */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/line.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/line.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/line.c Tue Oct 5 16:07:24 2004
***************
*** 0 ****
--- 1,27 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+ /* This file is the line routine, which is a standard part of the plot
+ library. It draws a line from coordinate x0,y0 to x1,y1 */
+ #include "libplot.h"
+ #include "extern.h"
+
+ int line (int x0, int y0, int x1, int y1)
+ {
+ move_nasko (x0,y0);
+ cont (x1,y1);
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/linemod.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/linemod.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/linemod.c Tue Oct 5 16:07:25 2004
***************
*** 0 ****
--- 1,88 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the linemod routine, which is a standard part of the plot
+ library. It sets the line type according to the name contained in
+ the string argument s */
+
+ #include <math.h>
+ #include <stdio.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ #include "libplot.h"
+ #include "extern.h"
+ /*
+ extern int printf();
+ extern int fprintf();
+ #ifndef mips
+ extern char *sprintf();
+ #endif
+ extern int fputs(), fputc();
+ */
+
+ int line_style = 0; /* solid */
+
+ float dash_length = 10.0; /* short dashed */
+
+ int linemod(char *s)
+ {
+ if ((strcmp( s, "longdashed") == 0)
+ || (strcmp( s, "long-dashed") == 0))
+ {
+ line_style = 1;
+ dash_length = 20.0;
+ }
+ else if (strcmp( s, "disconnected") == 0)
+ {
+ line_style = 2;
+ dash_length = 999.0;
+ }
+ else if ((strcmp( s, "dotdashed") == 0)
+ || (strcmp( s, "dot-dashed") == 0))
+ {
+ line_style = 1;
+ dash_length = 4.0;
+ }
+ else if (strcmp( s, "dotted") == 0)
+ {
+ line_style = 2;
+ dash_length = 2.0;
+ }
+ else if (strcmp( s, "solid") == 0)
+ {
+ line_style = 0;
+ dash_length = 1.0;
+ }
+ else if ((strcmp( s, "shortdashed") == 0)
+ || (strcmp( s, "short-dashed") == 0))
+ {
+ line_style = 1;
+ dash_length = 10.0;
+ }
+ else
+ {
+ fprintf( stderr, "Unrecognized line mode `%s' ignored. Using solid.\n", s);
+ /* Set the line mode to SOLID if an unsupported mode is requested. */
+ line_style = 0;
+ dash_length = 1.0;
+ }
+
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/move.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/move.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/move.c Tue Oct 5 16:07:25 2004
***************
*** 0 ****
--- 1,33 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the move routine, which is a standard part of the plot
+ library. It switches the device to vector plot mode and plots a
+ point at the given coordinate.
+ */
+ #include <stdio.h>
+ #include "libplot.h"
+ #include "extern.h"
+
+ int move_nasko(int x, int y)
+ {
+ draw_line ();
+ last_x = x;
+ last_y = y;
+ PointsInLine=1;
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/openpl.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/openpl.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/openpl.c Tue Oct 5 16:07:25 2004
***************
*** 0 ****
--- 1,58 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the openpl routine, which is a standard part of the plot
+ library. It normally opens the device. We just print out the
+ postscript prologue */
+
+ #include <math.h>
+ #include <stdio.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ #include "libplot.h"
+ #include "extern.h"
+ /*
+ extern int perror();
+ extern int exit();
+ extern int printf();
+ extern int fprintf();
+ extern int fclose();
+ extern int fread();
+ extern int fwrite();
+ #ifndef mips
+ extern char *sprintf();
+ #endif
+ extern int fputs(), fputc();
+ #ifndef hpux
+ extern void *malloc();
+ extern void *realloc();
+ #endif
+ */
+
+ int openpl(void)
+ {
+ printf( "#FIG 2.0\n");
+ printf( "%d %d\n",
+ 80, /* pixels per inch */
+ 2 /* origin in lower left corner */
+ );
+
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/plot.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/plot.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/plot.c Tue Oct 5 16:07:25 2004
***************
*** 0 ****
--- 1,439 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the main routine for plot.
+
+ It includes code to read the plot file and call plot functions
+ to draw the graphics. */
+
+ #include <stdio.h>
+ #include "/usr/include/stdlib.h"
+ #include <ctype.h>
+ #ifdef sequent
+ #include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+ #include <math.h>
+ #include "libplot.h"
+
+ /*
+ extern int perror();
+ extern int exit();
+ extern int printf();
+ extern int fprintf();
+ extern int fclose();
+ #ifndef mips
+ extern char *sprintf();
+ #endif
+ #ifndef hpux
+ extern void *malloc();
+ extern void *realloc();
+ #endif
+ extern int fputs();
+ */
+ extern void perror(const char *s);
+
+ /* #include "../COPYING" */
+
+ enum plot_instruction
+ {
+ ALABEL = 'T',
+ ARC = 'a',
+ CIRCLE = 'c',
+ COLOR = 'C',
+ CONT = 'n',
+ ERASE = 'e',
+ FILL = 'L',
+ FONT = 'F',
+ FONTSIZE = 'S',
+ LABEL = 't',
+ LINE = 'l',
+ LINEMOD = 'f',
+ MOVE = 'm',
+ POINT = 'p',
+ ROTATE = 'r',
+ SPACE = 's'
+ };
+
+ /* This flag specifies that the input contains unsigned (if zero) or
+ signed (if nonzero) two byte intgers. The default is signed. */
+ int signed_input = 1;
+
+ /* read in two byte intgers with high_byte_first. The default is to read the low
+ byte first. */
+ int high_byte_first = 0;
+
+ /* guess_byte_order is a flag which, if non-zero, indicated that the function
+ find_byte_order should be used to guess the byte order for the input file. */
+ int guess_byte_order = 1;
+
+ /* swap_bytes returns the bottom two bytes of its integer argument with
+ their bytes reversed. */
+
+ int swap_bytes(int x)
+ {
+ unsigned char a, b;
+ a = x & 0xff;
+ b = (x >> 8) & 0xff;
+ return ((a << 8)|b);
+ }
+
+ /* This is a set of known values for the maximum x (abscissa) values
+ specified in the plot size command for known devices. Using this
+ set we can construct a heuristic proceedure for recognizing plot
+ files in which the bytes of two byte integers are reversed. We can
+ recognize these files by looking for size commands containing these
+ known sizes in byte reversed form. The last entry should be 0. */
+
+ int known_size[32] = {
+ 504, /* plot3d output 504x504 */
+ 2048, /* versatek plotter 2048x2048 */
+ 2100, /* plot3d output */
+ 3120, /* Tektronix 4010 terminal 3120x3120 */
+ 4096, /* GSI 300 terminal 4096x4096 */
+ 0 /* the last entry should be 0 */
+ };
+
+ /* find_byte_order takes four integer arguments and matches third one
+ against a set of known values (sizes, see above). If there is a match
+ it merely returns. If there is no match, it check each of the values
+ again with the bottom two bytes reversed. If such a match is found, the
+ bottom two bytes of each argument is reversed, the high_byte_first flag
+ is inverted to indicated how two byte integers should be read and the
+ runction returns. */
+
+ void find_byte_order(int *x0, int *y0, int *x1, int * y1)
+ {
+ int i;
+ for (i=0; known_size[i]!=0; i++)
+ {
+ if (*x1 == known_size[i])
+ return;
+ }
+ /* now check to see if reversing the bytes allows a match... */
+ for (i=0; known_size[i]!=0; i++)
+ {
+ if (*x1 == swap_bytes (known_size[i]))
+ {
+ *x0 = swap_bytes( *x0);
+ *y0 = swap_bytes( *y0);
+ *x1 = swap_bytes( *x1);
+ *y1 = swap_bytes( *y1);
+ high_byte_first = ! high_byte_first;
+ return;
+ }
+ }
+ }
+
+ /* Read a byte */
+
+ #define read_byte(stream) (getc (stream))
+
+ /* Read a coordinate - a two byte integer. */
+
+ int coord(FILE *input)
+ {
+ int x;
+ if ( high_byte_first )
+ {
+ x = ((char) read_byte(input)) << 8; /* get sign from high byte */
+ x |= read_byte(input) & 0xFF; /* not from low byte */
+ }
+ else
+ {
+ x = read_byte (input) & 0xFF; /* ingnore sign in low byte */
+ x |= ((char) read_byte (input)) << 8; /* get sign from high byte */
+ }
+ if ( ! signed_input )
+ {
+ x &= 0xFFFF;
+ }
+
+ return x;
+ }
+
+ /* Read a string, change termination to null.
+ note: string (buffer) reads a newline terminated string. */
+
+ void read_string (FILE *input, char *buffer, int buffer_length)
+ {
+ int length=0;
+ char termination = '\n';
+ char c = '\0';
+
+ while (!feof (input))
+ {
+ if (length > buffer_length)
+ {
+ buffer_length *= 2;
+ buffer = (char *) realloc (buffer, buffer_length);
+ if (buffer <= (char *) 0)
+ {
+ perror ("realloc failed:");
+ exit (-1);
+ }
+ }
+ c = read_byte (input);
+ if (c == termination)
+ break;
+ buffer [length++] = c;
+ }
+
+ buffer [length] = '\0'; /* null terminate label */
+ }
+
+
+ /* read_plot reads a plot file from the standard input and calls
+ a plot function according to each plot instruction found in the
+ file. */
+
+ void read_plot(FILE *in_stream, char *buffer, int buffer_length)
+ {
+ char x_adjust, y_adjust;
+ int x0, y0, x1, y1, x2, y2;
+ int instruction;
+
+ instruction = read_byte (in_stream);
+ while (!feof (in_stream))
+ {
+ switch (instruction)
+ {
+ /* Note: we must get all but the last argument before calling to
+ ensure reading them in the proper order. */
+
+ case ALABEL:
+ x_adjust = read_byte (in_stream);
+ y_adjust = read_byte (in_stream);
+ read_string (in_stream, buffer, buffer_length);
+ alabel (x_adjust, y_adjust, buffer);
+ break;
+ case ARC:
+ x0 = coord (in_stream);
+ y0 = coord (in_stream);
+ x1 = coord (in_stream);
+ y1 = coord (in_stream);
+ x2 = coord (in_stream);
+ y2 = coord (in_stream);
+ arc (x0, y0, x1, y1, x2, y2);
+ break;
+ case CIRCLE:
+ x0 = coord (in_stream);
+ y0 = coord (in_stream);
+ x1 = coord (in_stream);
+ circle (x0, y0, x1);
+ break;
+ case COLOR:
+ x0 = coord (in_stream)&0xFFFF;
+ y0 = coord (in_stream)&0xFFFF;
+ x1 = coord (in_stream)&0xFFFF;
+ color (x0, y0, x1);
+ break;
+ case CONT:
+ x0 = coord (in_stream);
+ y0 = coord (in_stream);
+ cont (x0, y0);
+ break;
+ case ERASE:
+ erase (in_stream);
+ break;
+ case FILL:
+ fill (coord (in_stream)&0xFFFF); break;
+ case FONT:
+ read_string (in_stream, buffer, buffer_length);
+ fontname (buffer);
+ break;
+ case FONTSIZE:
+ fontsize (coord (in_stream));
+ break;
+ case LABEL:
+ read_string (in_stream, buffer, buffer_length);
+ label (buffer);
+ break;
+ case LINE:
+ x0 = coord (in_stream);
+ y0 = coord (in_stream);
+ x1 = coord (in_stream);
+ y1 = coord (in_stream);
+ line (x0, y0, x1, y1);
+ break;
+ case LINEMOD:
+ read_string (in_stream, buffer, buffer_length);
+ linemod (buffer);
+ break;
+ case MOVE:
+ x0 = coord (in_stream);
+ y0 = coord (in_stream);
+ move_nasko (x0, y0);
+ break;
+ case POINT:
+ x0 = coord (in_stream);
+ y0 = coord (in_stream);
+ point (x0, y0);
+ break;
+ case ROTATE:
+ x0 = coord (in_stream);
+ y0 = coord (in_stream);
+ x1 = coord (in_stream);
+ rotate (x0, y0, x1);
+ break;
+ case SPACE:
+ x0 = coord (in_stream);
+ y0 = coord (in_stream);
+ x1 = coord (in_stream);
+ y1 = coord (in_stream);
+ if (guess_byte_order)
+ find_byte_order(&x0, &y0, &x1, &y1);
+ space (x0, y0, x1, y1);
+ break;
+ default:
+ fprintf (stderr, "Unrecognized plot command `%c' ignored.\n", instruction);
+ }
+ instruction = read_byte (in_stream);
+ }
+ return;
+ }
+
+ int main (int argc, char *argv[])
+ {
+ int i;
+ char *buffer;
+ int buffer_length;
+ int named_plot=0; /* count named plot files on command line. */
+ int show_usage=0; /* remember whether to output usage message. */
+ int opened=0; /* remember whether we have opened output. */
+
+ buffer_length = 1024;
+ buffer = (char *) malloc (buffer_length);
+ if (buffer <= (char *) 0)
+ {
+ perror ("malloc failed:");
+ exit (-1);
+ }
+
+ for (i = 1; i < argc; i++)
+ {
+ if ((strcmp (argv [i], "-fontsize") == 0)
+ || (strcmp (argv [i], "-fs") == 0))
+ {
+ /* Sizes supported by X: 8, 10, 12, 14, 18, and 24. */
+ fontsize (atoi (argv[i+1]));
+ i += 1;
+ }
+ else if ((strcmp (argv [i], "-fontname") == 0)
+ || (strcmp (argv [i], "-fn") == 0))
+ {
+ fontname (argv [i+1]);
+ i += 1;
+ }
+ else if ((strcmp (argv [i], "-high-byte-first") == 0)
+ || (strcmp (argv [i], "-h") == 0))
+ {
+ guess_byte_order = 0;
+ high_byte_first = 1;
+ }
+ else if ((strcmp (argv [i], "-low-byte-first") == 0)
+ || (strcmp (argv [i], "-l") == 0))
+ {
+ guess_byte_order = 0;
+ high_byte_first = 0;
+ }
+ else if ((strcmp (argv [i], "-warranty") == 0)
+ || (strcmp (argv [i], "-copying") == 0))
+ {
+ /*
+ for (i=0; copy_notice[i][0]>0; i++)
+ fputs (copy_notice[i], stdout);
+ */
+ named_plot++;
+ }
+ else if ((strcmp (argv [i], "-help") == 0)
+ || (strcmp (argv [i], "-V") == 0))
+ {
+ printf ("%s version %s\n", argv[0], "0.0");
+ show_usage++;
+ named_plot++;
+ }
+ else if ((strcmp (argv [i], "-signed") == 0))
+ {
+ signed_input=1;
+ }
+ else if ((strcmp (argv [i], "-unsigned") == 0))
+ {
+ signed_input=0;
+ }
+ else if ((strcmp (argv [i], "-") == 0))
+ {
+ read_plot (stdin, buffer, buffer_length);
+ named_plot++;
+ }
+ else
+ {
+ FILE *filep;
+ filep = fopen ( argv [i], "r");
+ if (filep == NULL)
+ {
+ fprintf (stderr, "Unrecognized option or file `%s' ignored.\n",
+ argv [i]);
+ show_usage++;
+ }
+ else
+ {
+ named_plot++;
+ if (!opened)
+ {
+ openpl ();
+ opened ++;
+ }
+ read_plot (filep, buffer, buffer_length);
+ fclose (filep);
+ }
+ }
+ }
+
+
+
+ /* if there were no named plot files on the command line, then read
+ the standard input. */
+ if (named_plot == 0)
+ {
+ if (!opened)
+ {
+ openpl ();
+ opened ++;
+ }
+ read_plot (stdin, buffer, buffer_length);
+ }
+ if (opened)
+ closepl();
+
+ if ( show_usage || !opened)
+ {
+ fprintf (stderr, "\n\
+ usage: %s [-fontsize|-fs SIZE] [-high-byte-first|-h]\n\
+ [-low-byte-first|-l] [-fontname|-fn FONTNAME]\n\
+ [-help|-V] [-copying|-warranty] [PLOT_FILE_NAMES ...]\n",
+ *argv);
+ fprintf (stderr, "\n\
+ %s version 0.9, Copyright (C) 1989 Free Software Foundation, Inc.\n\
+ %s comes with ABSOLUTELY NO WARRANTY. This is free software, and\n\
+ you are welcome to redistribute it. Type `%s -warranty' for warranty\n\
+ details and copying conditions.\n\n",
+ *argv, *argv, *argv);
+ }
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/point.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/point.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/point.c Tue Oct 5 16:07:25 2004
***************
*** 0 ****
--- 1,28 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+ /* This file is the point routine, which is a standard part of the plot
+ library. It draws a point at the coordinate x,y. */
+
+ #include "libplot.h"
+ #include "extern.h"
+
+ int point(int x, int y)
+ {
+ move_nasko (x, y);
+ cont (x, y);
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/rotate.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/rotate.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/rotate.c Tue Oct 5 16:07:25 2004
***************
*** 0 ****
--- 1,32 ----
+ /* plot, unix plot file to graphics device translators.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ plot is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY. No author or distributor accepts responsibility to
+ anyone for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the GNU General Public License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute plot,
+ but only under the conditions described in the GNU General Public
+ License. A copy of this license is supposed to have been given to you
+ along with plot so you can know your rights and responsibilities. It
+ should be in a file named COPYING. Among other things, the copyright
+ notice and this notice must be preserved on all copies. */
+
+
+ /* This file is the arc routine, which is an extension to the plot
+ library. It rotates subsequent labels to the given angle in degress
+ from the horizontal */
+
+ #include <math.h>
+ #include "libplot.h"
+ #include "extern.h"
+
+ float text_rotation=0.0;
+
+ int rotate (int w, int h, int angle)
+ {
+ text_rotation = angle * M_PI / 180.0;
+ return 0;
+ }
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/space.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/space.c:1.1
*** /dev/null Tue Oct 5 16:07:36 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/plot2fig/space.c Tue Oct 5 16:07:25 2004
***************
*** 0 ****
--- 1,49 ----
+ /* libtek, a library of functions for tektronics 4010 compatible devices.
+ Copyright (C) 1989 Free Software Foundation, Inc.
+
+ libtek is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY. No author or distributor accepts responsibility to anyone for the
+ consequences of using it or for whether it serves any particular purpose or
+ works at all, unless he says so in writing. Refer to the GNU General Public
+ License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute libtek, but
+ only under the conditions described in the GNU General Public License. A copy
+ of this license is supposed to have been given to you along with libtek so
+ you can know your rights and responsibilities. It should be in a file named
+ COPYING. Among other things, the copyright notice and this notice must be
+ preserved on all copies. */
+
+ /* This file is the space routine, which is a standard part of the plot
+ library. It sets the lower left and upper right corners of the page. The
+ plot will be scaled so that these coners fit the largest renderable area on
+ the page. */
+
+ #include <math.h>
+ #include "libplot.h"
+ #include "extern.h"
+
+ double x_input_min = 0.; /* minimum input x coordinate */
+ double y_input_min = 0.; /* minimum input y coordinate */
+ /* Latex has troubles with plots larger than 6 inches (480). */
+ /* The range (60,660) to (540,180) centers the plot in the fig window. */
+ double x_output_min = 60.; /* minimum output x coordinate */
+ double y_output_min = 660.; /* minimum output y coordinate */
+ double x_output_max = 540.; /* maximum output x coordinate */
+ double y_output_max = 180.; /* maximum output y coordinate */
+ double scaleup = 1.; /* maximum input to output scaleing of x and y */
+ double x_scale = 1.; /* input to output scaleing for x */
+ double y_scale = 1.; /* input to output scaleing for y */
+
+ int space (int x0, int y0, int x1, int y1)
+ {
+ x_input_min = x0;
+ y_input_min = y0;
+ x_scale = (x1 - x0)/(x_output_max - x_output_min);
+ y_scale = (y1 - y0)/(y_output_max - y_output_min);
+ if (fabs(x_scale) > fabs(y_scale))
+ scaleup = fabs (x_scale);
+ else
+ scaleup = fabs (y_scale);
+ return 0;
+ }
More information about the llvm-commits
mailing list