/* should demonstrate a plotutils bugs 8.10.2003 address@hidden * derived from piechart v0.12 and therefore under GNU GPL v>=2 * * Running this programm on a Debian GNU/Linux woody ia32 using * libplot-2.4.1-7 * brings an X11 warning and a wrongly plotted line * ./low_angle_bugdemo * libplot: truncating a polyline that extends too far for X11 * * other output formats like ps or fig also will have the error * so it must be in the path calculation engine. * * */ #include #include #include int init_plotsession(char *display_type); int end_plotsession(int handle); int main(int argc, char **argv) { int return_value; int handle; handle=init_plotsession("X"); return_value= pl_fspace(-1.2,-1.2,1.2,1.2); if(return_value) { fprintf(stderr,"fspace returned %d!\n",return_value); } pl_filltype(1); /* leaving this line out, it will not give that X warning*/ pl_farc(0,0, 8.000000e-01,3.490659e-07, 8.000000e-01,3.490798e-07); pl_fcont(0,0); return end_plotsession(handle); } /******************************************************************************* * functions */ int init_plotsession(char *display_type) /* Initialise libplot and return handle of wanted plotter. */ { int handle, return_value; handle=pl_newpl(display_type, NULL, stdout, stderr); if(handle<0) { fprintf(stderr,"The plotter could not be created.\n"); exit(1); } return_value=pl_selectpl(handle); if(return_value<0) { fprintf(stderr,"The plotter does not exist or could not be selected.\n"); exit(1); } return_value= pl_openpl(); if(return_value<0) { fprintf(stderr,"The selected plotter could not be opened!\n"); exit(1); } return handle; } /******************************************************************************/ int end_plotsession(int handle) /* Close and delete plotter, return NULL if everything went fine. */ { int err_status=0, return_value; /* end a plot sesssion */ return_value= pl_closepl(); if(return_value<0) { fprintf(stderr,"The plotter could not be closed.\n"); /* no exit, because we try to delete the plotter */ err_status +=1; } /* need to select a different plotter in order to delete our */ return_value=pl_selectpl(0); if(return_value<0) { fprintf(stderr,"Default Plotter could not be selected!\n"); err_status +=1<<1; } return_value=pl_deletepl (handle);/* clean up by deleting used plotter */ if(return_value<0) { fprintf(stderr,"Selected Plotter could not be deleted!\n"); err_status +=1<<2; } return err_status; }