From fc1bc8cb6952953c778f26be64d1931adfdb8cbf Mon Sep 17 00:00:00 2001
From: Friedrich Beckmann <friedrich.beckmann@gmx.de>
Date: Sun, 2 Nov 2014 11:52:08 +0100
Subject: [PATCH] added space between function name and left bracket to comply
 to coding guidelines; adapted to US colouring to
 coloring;removed commented out code; changes according to
 Johns review of the graph patch

---
 src/language/stats/graph.c            |   72 ++++++++++++++++-----------------
 src/output/charts/scatterplot-cairo.c |   37 ++++++++---------
 2 files changed, 52 insertions(+), 57 deletions(-)

diff --git a/src/language/stats/graph.c b/src/language/stats/graph.c
index 0b1c22c..45abe3d 100644
--- a/src/language/stats/graph.c
+++ b/src/language/stats/graph.c
@@ -1,6 +1,6 @@
 /*
   PSPP - a program for statistical analysis.
-  Copyright (C) 2012, 2013  Free Software Foundation, Inc.
+  Copyright (C) 2014 Free Software Foundation, Inc.
   
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -145,22 +145,22 @@ show_scatterplot (const struct graph *cmd, const struct casereader *input)
     }
 		 
 
-  scatterplot = scatterplot_create(input,
-				   cmd->dep_vars[0], 
-				   cmd->dep_vars[1],
-				   cmd->byvar,
-				   &byvar_overflow,
-				   ds_cstr (&title),
-				   cmd->es[0].minimum, cmd->es[0].maximum,
-				   cmd->es[1].minimum, cmd->es[1].maximum);
-  scatterplot_chart_submit(scatterplot);
-  ds_destroy(&title);
+  scatterplot = scatterplot_create (input,
+				    cmd->dep_vars[0], 
+				    cmd->dep_vars[1],
+				    cmd->byvar,
+				    &byvar_overflow,
+				    ds_cstr (&title),
+				    cmd->es[0].minimum, cmd->es[0].maximum,
+				    cmd->es[1].minimum, cmd->es[1].maximum);
+  scatterplot_chart_submit (scatterplot);
+  ds_destroy (&title);
 
   if (byvar_overflow)
     {
       msg (MW, _("Maximum number of scatterplot categories reached." 
 		 "Your BY variable has too many distinct values."
-		 "The colouring of the plot will not be correct"));
+		 "The coloring of the plot will not be correct"));
     }
 
 
@@ -188,11 +188,11 @@ show_histogr (const struct graph *cmd, const struct casereader *input)
     {
       const struct variable *var = cmd->dep_vars[0];
       const double x = case_data (c, var)->f;
-      const double weight = dict_get_case_weight(cmd->dict,c,NULL);
+      const double weight = dict_get_case_weight (cmd->dict,c,NULL);
       moments_pass_two (cmd->es[0].mom, x, weight);
       histogram_add (histogram, x, weight);
     }
-  casereader_destroy(reader);
+  casereader_destroy (reader);
 
 
   {
@@ -210,7 +210,7 @@ show_histogr (const struct graph *cmd, const struct casereader *input)
 				ds_cstr (&label), n, mean,
 				sqrt (var), false));
 
-    statistic_destroy(&histogram->parent);      
+    statistic_destroy (&histogram->parent);      
     ds_destroy (&label);
   }
 }
@@ -234,7 +234,7 @@ run_graph (struct graph *cmd, struct casereader *input)
   struct casereader *reader;
 
 
-  cmd->es = pool_calloc(cmd->pool,cmd->n_dep_vars,sizeof(struct exploratory_stats));
+  cmd->es = pool_calloc (cmd->pool,cmd->n_dep_vars,sizeof(struct exploratory_stats));
   for(int v=0;v<cmd->n_dep_vars;v++)
     {
       cmd->es[v].mom = moments_create (MOMENT_KURTOSIS);
@@ -256,7 +256,7 @@ run_graph (struct graph *cmd, struct casereader *input)
   for (reader = casereader_clone (input);
        (c = casereader_read (reader)) != NULL; case_unref (c))
     {
-      const double weight = dict_get_case_weight(cmd->dict,c,NULL);      
+      const double weight = dict_get_case_weight (cmd->dict,c,NULL);      
       for(int v=0;v<cmd->n_dep_vars;v++)
 	{
 	  const struct variable *var = cmd->dep_vars[v];
@@ -289,21 +289,21 @@ run_graph (struct graph *cmd, struct casereader *input)
   switch (cmd->chart_type)
     {
     case CT_HISTOGRAM:
-      reader = casereader_clone(input);
-      show_histogr(cmd,reader);
-      casereader_destroy(reader);
+      reader = casereader_clone (input);
+      show_histogr (cmd,reader);
+      casereader_destroy (reader);
       break;
     case CT_SCATTERPLOT:
-      reader = casereader_clone(input);
-      show_scatterplot(cmd,reader);
-      casereader_destroy(reader);
+      reader = casereader_clone (input);
+      show_scatterplot (cmd,reader);
+      casereader_destroy (reader);
       break;
     default:
       NOT_REACHED ();
       break;
     };
 
-  casereader_destroy(input);
+  casereader_destroy (input);
 
   cleanup_exploratory_stats (cmd);
 }
@@ -334,11 +334,11 @@ cmd_graph (struct lexer *lexer, struct dataset *ds)
     {
       lex_match (lexer, T_SLASH);
 
-      if (lex_match_id(lexer, "HISTOGRAM"))
+      if (lex_match_id (lexer, "HISTOGRAM"))
 	{
 	  if (graph.chart_type != CT_NONE)
 	    {
-	      lex_error(lexer, _("Only one chart type is allowed."));
+	      lex_error (lexer, _("Only one chart type is allowed."));
 	      goto error;
 	    }
 	  if (!lex_force_match (lexer, T_EQUALS))
@@ -350,7 +350,7 @@ cmd_graph (struct lexer *lexer, struct dataset *ds)
 	    goto error;
 	  if (graph.n_dep_vars > 1)
 	    {
-	      lex_error(lexer, _("Only one variable is allowed"));
+	      lex_error (lexer, _("Only one variable is allowed."));
 	      goto error;
 	    }
 	}
@@ -358,7 +358,7 @@ cmd_graph (struct lexer *lexer, struct dataset *ds)
 	{
 	  if (graph.chart_type != CT_NONE)
 	    {
-	      lex_error(lexer, _("Only one chart type is allowed."));
+	      lex_error (lexer, _("Only one chart type is allowed."));
 	      goto error;
 	    }
 	  graph.chart_type = CT_SCATTERPLOT;
@@ -370,12 +370,12 @@ cmd_graph (struct lexer *lexer, struct dataset *ds)
 		}
 	      else if (lex_match_id (lexer, "OVERLAY"))  
 		{
-		  lex_error(lexer, _("%s is not yet implemented."),"OVERLAY");
+		  lex_error (lexer, _("%s is not yet implemented."),"OVERLAY");
 		  goto error;
 		}
 	      else if (lex_match_id (lexer, "MATRIX"))  
 		{
-		  lex_error(lexer, _("%s is not yet implemented."),"MATRIX");
+		  lex_error (lexer, _("%s is not yet implemented."),"MATRIX");
 		  goto error;
 		}
 	      else if (lex_match_id (lexer, "XYZ"))  
@@ -385,7 +385,7 @@ cmd_graph (struct lexer *lexer, struct dataset *ds)
 		}
 	      else
 		{
-		  lex_error_expecting(lexer, "BIVARIATE", NULL);
+		  lex_error_expecting (lexer, "BIVARIATE", NULL);
 		  goto error;
 		}
 	      if (!lex_force_match (lexer, T_RPAREN))
@@ -401,7 +401,7 @@ cmd_graph (struct lexer *lexer, struct dataset *ds)
 	 
 	  if (graph.scatter_type == ST_BIVARIATE && graph.n_dep_vars != 1)
 	    {
-	      lex_error(lexer, _("Only one variable allowed"));
+	      lex_error(lexer, _("Only one variable is allowed."));
 	      goto error;
 	    }
 
@@ -415,16 +415,16 @@ cmd_graph (struct lexer *lexer, struct dataset *ds)
 
 	  if (graph.scatter_type == ST_BIVARIATE && graph.n_dep_vars != 2)
 	    {
-	      lex_error(lexer, _("Only one variable allowed"));
+	      lex_error (lexer, _("Only one variable is allowed."));
 	      goto error;
 	    }
 	  
-	  if (lex_match(lexer, T_BY))
+	  if (lex_match (lexer, T_BY))
 	    {
 	      const struct variable *v = NULL;
 	      if (!lex_match_variable (lexer,graph.dict,&v))
 		{
-		  lex_error(lexer, _("Variable expected"));
+		  lex_error (lexer, _("Variable expected"));
 		  goto error;
 		}
 	      graph.byvar = v;
@@ -518,7 +518,7 @@ cmd_graph (struct lexer *lexer, struct dataset *ds)
 
   if (graph.chart_type == CT_NONE)
     {
-      lex_error_expecting(lexer,"HISTOGRAM","SCATTERPLOT",NULL);
+      lex_error_expecting (lexer,"HISTOGRAM","SCATTERPLOT",NULL);
       goto error;
     }
 
diff --git a/src/output/charts/scatterplot-cairo.c b/src/output/charts/scatterplot-cairo.c
index b555a12..16c4069 100644
--- a/src/output/charts/scatterplot-cairo.c
+++ b/src/output/charts/scatterplot-cairo.c
@@ -47,11 +47,11 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
   const struct xrchart_colour *colour;
   
   if (spc->byvar)
-    byvar_width = var_get_width(spc->byvar);
+    byvar_width = var_get_width (spc->byvar);
 
   xrchart_write_xscale (cr, geom,
-                      spc->x_min,
-                      spc->x_max, 5);
+                        spc->x_min,
+                        spc->x_max, 5);
   xrchart_write_yscale (cr, geom, spc->y_min, spc->y_max, 5);
   xrchart_write_title (cr, geom, _("Scatterplot %s"), chart_item->title);
   xrchart_write_xlabel (cr, geom, var_to_string(spc->xvar));
@@ -63,25 +63,25 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
     {
       if (spc->byvar)
 	{
-	  const union value *val = case_data(c,spc->byvar);
-	  for(i=0;i<n_catvals && !value_equal(&catvals[i],val,byvar_width);i++);
+	  const union value *val = case_data (c,spc->byvar);
+	  for(i=0;i<n_catvals && !value_equal (&catvals[i],val,byvar_width);i++);
 	  if (i == n_catvals) /* No entry found */
 	    {
 	      if (n_catvals < MAX_PLOT_CATS)
 		{
 		  struct string label;
-		  ds_init_empty(&label);
-		  if (var_is_value_missing(spc->byvar,val,MV_ANY))
-		    ds_put_cstr(&label,"missing");
+		  ds_init_empty (&label);
+		  if (var_is_value_missing (spc->byvar,val,MV_ANY))
+		    ds_put_cstr (&label,"missing");
 		  else
-		    var_append_value_name(spc->byvar,val,&label);
-		  value_clone(&catvals[n_catvals++],val,byvar_width);
+		    var_append_value_name (spc->byvar,val,&label);
+		  value_clone (&catvals[n_catvals++],val,byvar_width);
 		  geom->n_datasets++;
 		  geom->dataset = xrealloc (geom->dataset,
 					    geom->n_datasets * sizeof (*geom->dataset));
 
-		  geom->dataset[geom->n_datasets - 1] = strdup(ds_cstr(&label));
-		  ds_destroy(&label);
+		  geom->dataset[geom->n_datasets - 1] = strdup (ds_cstr(&label));
+		  ds_destroy (&label);
 		}
 	      else /* Use the last plot category */
 		{
@@ -90,7 +90,7 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
 		}
 	    }
 	}
-      colour = &data_colour [ i % XRCHART_N_COLOURS];
+      colour = &data_colour[i % XRCHART_N_COLOURS];
       cairo_set_source_rgb (cr,
                             colour->red / 255.0,
                             colour->green / 255.0,
@@ -101,17 +101,12 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
 		     case_data (c, spc->yvar)->f);
     }
   casereader_destroy (data);
-  cairo_restore(cr);
+  cairo_restore (cr);
 
   for(i=0;i<n_catvals;i++)
-    value_destroy(&catvals[i],byvar_width);
+    value_destroy (&catvals[i],byvar_width);
 
   if (spc->byvar)
-    xrchart_write_legend(cr, geom);
-
-    
-
-  //  xrchart_line (cr, geom, npp->slope, npp->intercept,
-  //            npp->y_first, npp->y_last, XRCHART_DIM_Y);
+    xrchart_write_legend (cr, geom);
 
 }
-- 
1.7.10.4

