Allow output files to overwrite input files (bug #21280). Thanks to
[pspp-builds.git] / src / language / stats / aggregate.c
index 921c8ed0985ac28fda71f5f96b5754d226a7e618..18d78f238ae1f3038168cad0538d119c8903a0c5 100644 (file)
@@ -36,7 +36,6 @@
 #include <language/lexer/lexer.h>
 #include <language/lexer/variable-parser.h>
 #include <language/stats/sort-criteria.h>
-#include <libpspp/alloc.h>
 #include <libpspp/assertion.h>
 #include <libpspp/message.h>
 #include <libpspp/misc.h>
@@ -46,6 +45,7 @@
 #include <math/sort.h>
 
 #include "minmax.h"
+#include "xalloc.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -330,6 +330,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds)
     }
 
   agr_destroy (&agr);
+  fh_unref (out_file);
   return CMD_SUCCESS;
 
 error:
@@ -337,6 +338,7 @@ error:
     proc_commit (ds);
   casewriter_destroy (output);
   agr_destroy (&agr);
+  fh_unref (out_file);
   return CMD_CASCADING_FAILURE;
 }
 
@@ -485,8 +487,8 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, s
                  }
                 else
                   {
-                   msg (SE, _("Missing argument %d to %s."),
-                         (int) i + 1, function->name);
+                   msg (SE, _("Missing argument %zu to %s."),
+                         i + 1, function->name);
                    goto error;
                  }
 
@@ -516,9 +518,9 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, s
             like `unknown variable t'. */
          if (n_src != n_dest)
            {
-             msg (SE, _("Number of source variables (%u) does not match "
-                        "number of target variables (%u)."),
-                  (unsigned) n_src, (unsigned) n_dest);
+             msg (SE, _("Number of source variables (%zu) does not match "
+                        "number of target variables (%zu)."),
+                   n_src, n_dest);
              goto error;
            }