This helper function encapsulates what most of the callers were doing.
grouper = casegrouper_create_splits (proc_open (ds), dict);
while (casegrouper_get_next_group (grouper, &group))
{
- struct ccase *c = casereader_peek (group, 0);
- if (c != NULL)
- {
- output_split_file_values (ds, c);
- case_unref (c);
- }
-
+ output_split_file_values_peek (ds, group);
group = casereader_project (group, &sc);
group = casereader_select (group, lcmd->first - 1,
(lcmd->last != LONG_MAX ? lcmd->last
cases->hide_all_labels = true;
casenumber case_num = lcmd->first;
+ struct ccase *c;
for (; (c = casereader_read (group)) != NULL; case_unref (c))
{
int case_idx = pivot_category_create_leaf (
#include <stdlib.h>
#include "data/case.h"
+#include "data/casereader.h"
#include "data/data-out.h"
#include "data/dataset.h"
#include "data/dictionary.h"
pivot_table_submit (table);
}
+
+/* Dumps out the values of all the split variables for the first case in
+ READER. */
+void
+output_split_file_values_peek (const struct dataset *ds,
+ const struct casereader *reader)
+{
+ struct ccase *c = casereader_peek (reader, 0);
+ if (c)
+ {
+ output_split_file_values (ds, c);
+ case_unref (c);
+ }
+}
#ifndef SPLIT_FILE_H
#define SPLIT_FILE_H 1
-void output_split_file_values (const struct dataset *ds, const struct ccase *);
+void output_split_file_values (const struct dataset *, const struct ccase *);
+void output_split_file_values_peek (const struct dataset *,
+ const struct casereader *);
#endif /* split-file.h */
struct casereader *group;
while (casegrouper_get_next_group (grouper, &group))
{
- /* Output SPLIT FILE variables. */
- struct ccase *c = casereader_peek (group, 0);
- if (c != NULL)
- {
- output_split_file_values (ds, c);
- case_unref (c);
- }
+ output_split_file_values_peek (ds, group);
/* Initialize hash tables. */
for (struct crosstabulation *xt = &proc.pivots[0];
hmap_init (&xt->data);
/* Tabulate. */
+ struct ccase *c;
for (; (c = casereader_read (group)) != NULL; case_unref (c))
for (struct crosstabulation *xt = &proc.pivots[0];
xt < &proc.pivots[proc.n_pivots]; xt++)
while (casegrouper_get_next_group (grouper, &group))
{
if (splitting)
- {
- struct ccase *c = casereader_peek (group, 0);
- if (c != NULL)
- {
- output_split_file_values (ds, c);
- case_unref (c);
- }
- }
+ output_split_file_values_peek (ds, group);
bool warn_on_invalid = true;
for (struct ccase *c = casereader_read (group); c;
calc_descriptives (struct dsc_proc *dsc, struct casereader *group,
struct dataset *ds)
{
- struct ccase *c = casereader_peek (group, 0);
- if (c == NULL)
- {
- casereader_destroy (group);
- return;
- }
- output_split_file_values (ds, c);
- case_unref (c);
-
+ output_split_file_values_peek (ds, group);
group = casereader_create_filter_weight (group, dataset_dict (ds),
NULL, NULL);
/* First pass to handle most of the work. */
casenumber count = 0;
const struct variable *filter = dict_get_filter (dataset_dict (ds));
+ struct ccase *c;
for (; (c = casereader_read (pass1)) != NULL; case_unref (c))
{
double weight = dict_get_case_weight (dataset_dict (ds), c, NULL);
cov = covariance_2pass_create (cmd->n_dep_vars, cmd->dep_vars,
ws.cats, cmd->wv, cmd->exclude, true);
+ output_split_file_values_peek (ds, input);
- c = casereader_peek (input, 0);
- if (c == NULL)
- {
- casereader_destroy (input);
- return;
- }
- output_split_file_values (ds, c);
- case_unref (c);
taint = taint_clone (casereader_get_taint (input));
struct taint *taint;
struct dictionary *dict = dataset_dict (ds);
struct casereader *reader;
- struct ccase *c;
struct oneway_workspace ws;
ws.vws[v].nl = levene_create (var_get_width (cmd->indep_var), NULL);
}
- c = casereader_peek (input, 0);
- if (c == NULL)
- {
- casereader_destroy (input);
- goto finish;
- }
- output_split_file_values (ds, c);
- case_unref (c);
+ output_split_file_values_peek (ds, input);
taint = taint_clone (casereader_get_taint (input));
input = casereader_create_filter_weight (input, dict, NULL, NULL);
reader = casereader_clone (input);
+ struct ccase *c;
for (; (c = casereader_read (reader)) != NULL; case_unref (c))
{
int i;
taint_destroy (taint);
- finish:
-
for (v = 0; v < cmd->n_vars; ++v)
{
covariance_destroy (ws.vws[v].cov);