treewide: Replace <name>_cnt by n_<name>s and <name>_cap by allocated_<name>.
[pspp] / src / data / casereader-filter.c
index 5244202e4fde4c02f3124a1f08ea2e910db15f3f..08151fadd2a5475115f0a1523252399f425b3f68 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009, 2011 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
 
 #include <config.h>
 
-#include <data/casereader.h>
+#include "data/casereader.h"
 
 #include <stdlib.h>
 
-#include <data/casereader-provider.h>
-#include <data/casewriter.h>
-#include <data/variable.h>
-#include <data/dictionary.h>
-#include <libpspp/taint.h>
-#include <libpspp/message.h>
+#include "data/casereader-provider.h"
+#include "data/casewriter.h"
+#include "data/variable.h"
+#include "data/dictionary.h"
+#include "libpspp/taint.h"
+#include "libpspp/message.h"
 
-#include "xalloc.h"
+#include "gl/xalloc.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -243,7 +243,7 @@ casereader_filter_weight_destroy (void *cfw_)
 struct casereader_filter_missing
   {
     struct variable **vars;     /* Variables whose values to filter. */
-    size_t var_cnt;             /* Number of variables. */
+    size_t n_vars;              /* Number of variables. */
     enum mv_class class;        /* Types of missing values to filter. */
     casenumber *n_missing;
   };
@@ -253,7 +253,7 @@ static bool casereader_filter_missing_destroy (void *);
 
 /* Creates and returns a casereader that filters out cases from
    READER that have a missing value in the given CLASS for any of
-   the VAR_CNT variables in VARS.  Only cases that have
+   the N_VARS variables in VARS.  Only cases that have
    non-missing values for all of these variables are passed
    through.
 
@@ -266,23 +266,23 @@ static bool casereader_filter_missing_destroy (void *);
    is destroyed.
 
    If N_MISSING is non-null, then after reading, it will be filled
-   with the totla number of dropped cases.
+   with the total number of dropped cases.
 
    After this function is called, READER must not ever again
    be referenced directly.  It will be destroyed automatically
    when the filtering casereader is destroyed. */
 struct casereader *
 casereader_create_filter_missing (struct casereader *reader,
-                                  const struct variable **vars, size_t var_cnt,
+                                  const struct variable *const *vars, size_t n_vars,
                                   enum mv_class class,
                                  casenumber *n_missing,
                                   struct casewriter *exclude)
 {
-  if (var_cnt > 0 && class != MV_NEVER)
+  if (n_vars > 0 && class != MV_NEVER)
     {
       struct casereader_filter_missing *cfm = xmalloc (sizeof *cfm);
-      cfm->vars = xmemdup (vars, sizeof *vars * var_cnt);
-      cfm->var_cnt = var_cnt;
+      cfm->vars = xmemdup (vars, sizeof *vars * n_vars);
+      cfm->n_vars = n_vars;
       cfm->class = class;
       cfm->n_missing = n_missing;
       if (n_missing) *n_missing = 0;
@@ -304,13 +304,13 @@ casereader_filter_missing_include (const struct ccase *c, void *cfm_)
   const struct casereader_filter_missing *cfm = cfm_;
   size_t i;
 
-  for (i = 0; i < cfm->var_cnt; i++)
+  for (i = 0; i < cfm->n_vars; i++)
     {
       struct variable *var = cfm->vars[i];
       const union value *value = case_data (c, var);
       if (var_is_value_missing (var, value, cfm->class))
        {
-         if ( cfm->n_missing )
+         if (cfm->n_missing)
            (*cfm->n_missing)++;
          return false;
        }