Moved EXPORT comments to new header file
[pspp] / src / regression.q
index eced95444ad6669e933cda739d92438a18f5449b..660c15d82338647bef0bab3a9a33fadc5357f5e6 100644 (file)
@@ -36,6 +36,7 @@
 #include "lexer.h"
 #include <linreg/pspp_linreg.h>
 #include "missing-values.h"
+#include "reg_export_comments.h"
 #include "tab.h"
 #include "var.h"
 #include "vfm.h"
@@ -484,16 +485,16 @@ subcommand_export (int export, pspp_linreg_cache *c)
       assert (model_file != NULL);
       assert (fp != NULL);
       fp = fopen (handle_get_filename (model_file), "w");
-      fprintf (fp, "/* PSPP-generated linear regression model.\n   Copyright (C) 2005 Free Software Foundation, Inc.\n   Generated by the GNU PSPP regression procedure.\n\n   This program is free software; you can redistribute it and/or\n   modify it under the terms of the GNU General Public License as\n   published by the Free Software Foundation; either version 2 of the\n   License, or (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with GNU PSPP; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n   02110-1301, USA. */\n\n");
       fprintf (fp, "#include <string.h>\n\n");
-      fprintf (fp, "double\npspp_reg_estimate (const double *var_vals, conts char *[] var_names)\n{\n\tchar *model_depvars[%d] = {", c->n_indeps);
+      fprintf (fp, "%s", reg_mean_cmt);
+      fprintf (fp, "double\npspp_reg_estimate (const double *var_vals, const char *var_names[])\n{\n\tchar *model_depvars[%d] = {", c->n_indeps);
       for (i = 1; i < c->n_indeps; i++)
        {
          coeff = c->coeff[i];
-         fprintf (fp, "%s,\n\t\t", coeff.v->name);
+         fprintf (fp, "\"%s\",\n\t\t", coeff.v->name);
        }
       coeff = c->coeff[i];
-      fprintf (fp, "%s};\n\t", coeff.v->name);
+      fprintf (fp, "\"%s\"};\n\t", coeff.v->name);
       fprintf (fp, "double model_coeffs[%d] = {", c->n_indeps);
       for (i = 1; i < c->n_indeps; i++)
        {
@@ -503,11 +504,11 @@ subcommand_export (int export, pspp_linreg_cache *c)
       coeff = c->coeff[i];
       fprintf (fp, "%.15e};\n\t", coeff.estimate);
       coeff = c->coeff[0];
-      fprintf (fp, "double estimate = %.15e\n\t", coeff.estimate);
+      fprintf (fp, "double estimate = %.15e;\n\t", coeff.estimate);
       fprintf (fp, "int i;\n\tint j;\n\n\t");
       fprintf (fp, "for (i = 0; i < %d; i++)\n\t", c->n_indeps);
       fprintf (fp, "{\n\t\tfor (j = 0; j < %d; j++)\n\t\t", c->n_indeps);
-      fprintf (fp, "{\n\t\t\tif (strcmp (var_names[i], model_names[j]) == 0)\n");
+      fprintf (fp, "{\n\t\t\tif (strcmp (var_names[i], model_depvars[j]) == 0)\n");
       fprintf (fp, "\t\t\t{\n\t\t\t\testimate += var_vals[i] * model_coeffs[j];\n");
       fprintf (fp, "\t\t\t}\n\t\t}\n\t}\n\treturn estimate;\n}\n");
       fclose (fp);