REGRESSION: Correctly handle data in temporary file for SAVE subcommand.
[pspp] / src / language / stats / regression.c
index d9409aae59bcc1301e16ed05770606457194915d..a6c6cbacc66183b646aee12e36a63a3649314cc6 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2005, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2009, 2010, 2011, 2012, 2013, 2014, 2016 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
@@ -348,8 +348,7 @@ cmd_regression (struct lexer *lexer, struct dataset *ds)
 
       if (regression.resid)
         {
-          workspace.extras ++;
-          workspace.res_idx = 0;
+          workspace.res_idx = workspace.extras ++;
           workspace.residvars = xcalloc (regression.n_dep_vars, sizeof (*workspace.residvars));
 
           for (i = 0; i < regression.n_dep_vars; ++i)
@@ -361,8 +360,7 @@ cmd_regression (struct lexer *lexer, struct dataset *ds)
 
       if (regression.pred)
         {
-          workspace.extras ++;
-          workspace.pred_idx = 1;
+          workspace.pred_idx = workspace.extras ++;
           workspace.predvars = xcalloc (regression.n_dep_vars, sizeof (*workspace.predvars));
 
           for (i = 0; i < regression.n_dep_vars; ++i)
@@ -376,6 +374,10 @@ cmd_regression (struct lexer *lexer, struct dataset *ds)
         msg (SW, _("REGRESSION with SAVE ignores TEMPORARY.  "
                    "Temporary transformations will be made permanent."));
 
+      if (dict_get_filter (dict))
+        msg (SW, _("REGRESSION with SAVE ignores FILTER.  "
+                   "All cases will be processed."));
+
       workspace.writer = autopaging_writer_create (proto);
       caseproto_unref (proto);
     }
@@ -705,7 +707,7 @@ run_regression (const struct regression *cmd,
       
       for (; (c = casereader_read (r)) != NULL; case_unref (c))
         {
-          struct ccase *outc = case_clone (c);
+          struct ccase *outc = case_create (casewriter_get_proto (ws->writer));
           for (k = 0; k < cmd->n_dep_vars; k++)
             {
               const struct variable **vars = xnmalloc (cmd->n_vars, sizeof (*vars));