Add another expression test and fix the bugs it found.
[pspp-builds.git] / src / cartesian.c
index cac18400a4e9e85c6b1dc78bc795b3323b76dd4c..22201e4e4e4daa3c6caf8f2f805aa243abb5382b 100644 (file)
@@ -53,6 +53,8 @@ write_legend(struct chart *chart, const char *heading, int n);
 void 
 chart_write_xlabel(struct chart *ch, const char *label)
 {
+  if ( ! ch ) 
+    return ;
 
   pl_savestate_r(ch->lp);
 
@@ -69,6 +71,9 @@ chart_write_xlabel(struct chart *ch, const char *label)
 void 
 chart_write_ylabel(struct chart *ch, const char *label)
 {
+  if ( ! ch ) 
+    return ;
+
   pl_savestate_r(ch->lp);
 
   pl_move_r(ch->lp, ch->data_bottom, ch->ordinate_right);
@@ -86,6 +91,10 @@ write_legend(struct chart *chart, const char *heading,
 {
   int ds;
 
+  if ( ! chart ) 
+    return ;
+
+
   pl_savestate_r(chart->lp);
 
   pl_filltype_r(chart->lp,1);
@@ -124,13 +133,18 @@ write_legend(struct chart *chart, const char *heading,
 void
 chart_datum(struct chart *ch, int dataset UNUSED, double x, double y)
 {
+
+  if ( ! ch ) 
+    return ;
+
+
+
   const double x_pos = 
     (x - ch->x_min) * ch->abscissa_scale + ch->data_left ; 
 
   const double y_pos = 
     (y - ch->y_min) * ch->ordinate_scale + ch->data_bottom ;
 
-
   pl_savestate_r(ch->lp);    
   
   pl_fmarker_r(ch->lp, x_pos, y_pos, 6, 15);
@@ -151,6 +165,10 @@ chart_line(struct chart *ch, double slope, double intercept,
   double x1, y1;
   double x2, y2 ;
 
+  if ( ! ch ) 
+    return ;
+
+
   if ( lim_dim == CHART_DIM_Y ) 
     {
       x1 = ( limit1 - intercept ) / slope ;