I used to think that _cnt was a good suffix for a count representing the
number of items in an array, but I haven't used that convention in a long
time and it looks wrong now. This changes these to an n_ prefix instead.
Similarly, but in far fewer cases, replace <name>_cap for the allocated
capacity of an array by allocated_<name>.
This doesn't change the name of ref_cnt members used as reference counts.
Those are pure counts, not the length of anything.
This doesn't change the Perl library because that's an external API.
128 files changed:
[(@{TAB,'@var{c}'@}, @dots{})]
[@{NOTABLE,TABLE@}]
[FILE='@var{file_name}' [ENCODING='@var{encoding}']]
[(@{TAB,'@var{c}'@}, @dots{})]
[@{NOTABLE,TABLE@}]
[FILE='@var{file_name}' [ENCODING='@var{encoding}']]
- [SKIP=@var{record_cnt}]
/@var{var_spec}@dots{}
where each @var{var_spec} takes one of the forms
/@var{var_spec}@dots{}
where each @var{var_spec} takes one of the forms
(see below).
@end deftypefun
(see below).
@end deftypefun
-@deftypefun size_t dict_get_var_cnt (const struct dictionary *@var{dict})
+@deftypefun size_t dict_get_n_vars (const struct dictionary *@var{dict})
Returns the number of variables in @var{dict}.
@end deftypefun
Returns the number of variables in @var{dict}.
@end deftypefun
caller must not modify or free the returned array.
@end deftypefun
caller must not modify or free the returned array.
@end deftypefun
-@deftypefun size_t dict_get_split_cnt (const struct dictionary *@var{dict})
+@deftypefun size_t dict_get_n_splits (const struct dictionary *@var{dict})
Returns the number of split variables.
@end deftypefun
Returns the number of split variables.
@end deftypefun
-@deftypefun size_t dict_get_document_line_cnt (const struct dictionary *@var{dict})
+@deftypefun size_t dict_get_document_n_lines (const struct dictionary *@var{dict})
Returns the number of line of documents in @var{dict}. If the
dictionary contains no documents, returns 0.
@end deftypefun
Returns the number of line of documents in @var{dict}. If the
dictionary contains no documents, returns 0.
@end deftypefun
int32 rec_type;
int32 label_count;
int32 rec_type;
int32 label_count;
-/* @r{Repeated @code{label_cnt} times}. */
+/* @r{Repeated @code{n_label} times}. */
char value[8];
char label_len;
char label[];
char value[8];
char label_len;
char label[];
get_var_cnt (dict)
struct pspp_dict *dict
CODE:
get_var_cnt (dict)
struct pspp_dict *dict
CODE:
- RETVAL = dict_get_var_cnt (dict->dict);
+ RETVAL = dict_get_n_vars (dict->dict);
INIT:
SV *errstr = get_sv("PSPP::errstr", TRUE);
sv_setpv (errstr, "");
INIT:
SV *errstr = get_sv("PSPP::errstr", TRUE);
sv_setpv (errstr, "");
- if ( SvIV (idx) >= dict_get_var_cnt (dict->dict))
+ if ( SvIV (idx) >= dict_get_n_vars (dict->dict))
{
sv_setpv (errstr, "The dictionary doesn't have that many variables.");
XSRETURN_UNDEF;
{
sv_setpv (errstr, "The dictionary doesn't have that many variables.");
XSRETURN_UNDEF;
size_t nv;
struct ccase *c;
size_t nv;
struct ccase *c;
- if ( av_len (av_case) >= dict_get_var_cnt (swi->dict->dict))
+ if ( av_len (av_case) >= dict_get_n_vars (swi->dict->dict))
XSRETURN_UNDEF;
c = case_create (dict_get_proto (swi->dict->dict));
XSRETURN_UNDEF;
c = case_create (dict_get_proto (swi->dict->dict));
}
/* The remaining variables must be sysmis or blank string */
}
/* The remaining variables must be sysmis or blank string */
- while (i < dict_get_var_cnt (swi->dict->dict))
+ while (i < dict_get_n_vars (swi->dict->dict))
{
const struct variable *v = vv[i++];
union value *val = case_data_rw (c, v);
{
const struct variable *v = vv[i++];
union value *val = case_data_rw (c, v);
- EXTEND (SP, dict_get_var_cnt (sfr->dict->dict));
- for (v = 0; v < dict_get_var_cnt (sfr->dict->dict); ++v )
+ EXTEND (SP, dict_get_n_vars (sfr->dict->dict));
+ for (v = 0; v < dict_get_n_vars (sfr->dict->dict); ++v )
{
const struct variable *var = dict_get_var (sfr->dict->dict, v);
const union value *val = case_data (c, var);
{
const struct variable *var = dict_get_var (sfr->dict->dict, v);
const union value *val = case_data (c, var);
info->integer_format = INTEGER_NATIVE;
info->float_format = FLOAT_NATIVE_DOUBLE;
info->compression = ANY_COMP_NONE;
info->integer_format = INTEGER_NATIVE;
info->float_format = FLOAT_NATIVE_DOUBLE;
info->compression = ANY_COMP_NONE;
- info->case_cnt = casereader_get_case_cnt (reader);
+ info->n_cases = casereader_get_n_cases (reader);
enum integer_format integer_format;
enum float_format float_format;
enum any_compression compression;
enum integer_format integer_format;
enum float_format float_format;
enum any_compression compression;
- casenumber case_cnt; /* -1 if unknown. */
+ casenumber n_cases; /* -1 if unknown. */
char *product; /* Product name. */
char *product_ext; /* Extra product info. */
char *product; /* Product name. */
char *product_ext; /* Extra product info. */
case_map_to_compact_dict (const struct dictionary *d,
unsigned int exclude_classes)
{
case_map_to_compact_dict (const struct dictionary *d,
unsigned int exclude_classes)
{
- size_t n_vars = dict_get_var_cnt (d);
+ size_t n_vars = dict_get_n_vars (d);
struct caseproto *proto;
struct case_map *map;
size_t n_values;
struct caseproto *proto;
struct case_map *map;
size_t n_values;
struct case_map_stage *
case_map_stage_create (const struct dictionary *dict)
{
struct case_map_stage *
case_map_stage_create (const struct dictionary *dict)
{
- size_t n_vars = dict_get_var_cnt (dict);
+ size_t n_vars = dict_get_n_vars (dict);
struct case_map_stage *stage;
size_t i;
struct case_map_stage *stage;
size_t i;
case_map_stage_get_case_map (const struct case_map_stage *stage)
{
struct case_map *map;
case_map_stage_get_case_map (const struct case_map_stage *stage)
{
struct case_map *map;
- size_t n_vars = dict_get_var_cnt (stage->dict);
+ size_t n_vars = dict_get_n_vars (stage->dict);
size_t n_values;
size_t i;
bool identity_map = true;
size_t n_values;
size_t i;
bool identity_map = true;
case_map_by_name (const struct dictionary *old,
const struct dictionary *new)
{
case_map_by_name (const struct dictionary *old,
const struct dictionary *new)
{
- struct case_map *map;
- size_t var_cnt = dict_get_var_cnt (new);
- size_t i;
-
- map = create_case_map (dict_get_proto (new));
- for (i = 0; i < var_cnt; i++)
+ size_t n_vars = dict_get_n_vars (new);
+ struct case_map *map = create_case_map (dict_get_proto (new));
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *nv = dict_get_var (new, i);
struct variable *ov = dict_lookup_var_assert (old, var_get_name (nv));
{
struct variable *nv = dict_get_var (new, i);
struct variable *ov = dict_lookup_var_assert (old, var_get_name (nv));
bool case_tmpfile_get_values (const struct case_tmpfile *,
casenumber, size_t start_value,
bool case_tmpfile_get_values (const struct case_tmpfile *,
casenumber, size_t start_value,
- union value[], size_t value_cnt);
+ union value[], size_t n_values);
struct ccase *case_tmpfile_get_case (const struct case_tmpfile *, casenumber);
bool case_tmpfile_put_values (struct case_tmpfile *,
casenumber, size_t start_value,
struct ccase *case_tmpfile_get_case (const struct case_tmpfile *, casenumber);
bool case_tmpfile_put_values (struct case_tmpfile *,
casenumber, size_t start_value,
- const union value[], size_t value_cnt);
+ const union value[], size_t n_values);
bool case_tmpfile_put_case (struct case_tmpfile *,
casenumber, struct ccase *);
bool case_tmpfile_put_case (struct case_tmpfile *,
casenumber, struct ccase *);
static inline void case_unref (struct ccase *);
static inline bool case_is_shared (const struct ccase *);
static inline void case_unref (struct ccase *);
static inline bool case_is_shared (const struct ccase *);
-static inline size_t case_get_value_cnt (const struct ccase *);
+static inline size_t case_get_n_values (const struct ccase *);
static inline const struct caseproto *case_get_proto (const struct ccase *);
size_t case_get_cost (const struct caseproto *);
static inline const struct caseproto *case_get_proto (const struct ccase *);
size_t case_get_cost (const struct caseproto *);
/* Returns the number of union values in C. */
static inline size_t
/* Returns the number of union values in C. */
static inline size_t
-case_get_value_cnt (const struct ccase *c)
+case_get_n_values (const struct ccase *c)
{
return caseproto_get_n_widths (c->proto);
}
{
return caseproto_get_n_widths (c->proto);
}
/* Creates and returns a casegrouper that reads data from READER
and breaks it into contiguous groups of cases that have equal
/* Creates and returns a casegrouper that reads data from READER
and breaks it into contiguous groups of cases that have equal
- values for the VAR_CNT variables in VARS. If VAR_CNT is 0,
+ values for the N_VARS variables in VARS. If N_VARS is 0,
then all the cases will be put in a single group.
Takes ownerhip of READER. */
struct casegrouper *
casegrouper_create_vars (struct casereader *reader,
const struct variable *const *vars,
then all the cases will be put in a single group.
Takes ownerhip of READER. */
struct casegrouper *
casegrouper_create_vars (struct casereader *reader,
const struct variable *const *vars,
{
struct subcase *sc = xmalloc (sizeof *sc);
{
struct subcase *sc = xmalloc (sizeof *sc);
- subcase_init_vars (sc, vars, var_cnt);
+ subcase_init_vars (sc, vars, n_vars);
return casegrouper_create_func (reader, casegrouper_vars_same_group,
casegrouper_vars_destroy, sc);
}
return casegrouper_create_func (reader, casegrouper_vars_same_group,
casegrouper_vars_destroy, sc);
}
{
return casegrouper_create_vars (reader,
dict_get_split_vars (dict),
{
return casegrouper_create_vars (reader,
dict_get_split_vars (dict),
- dict_get_split_cnt (dict));
+ dict_get_n_splits (dict));
}
/* Creates and returns a casegrouper that reads data from READER
}
/* Creates and returns a casegrouper that reads data from READER
void *aux);
struct casegrouper *casegrouper_create_vars (struct casereader *,
const struct variable *const *vars,
void *aux);
struct casegrouper *casegrouper_create_vars (struct casereader *,
const struct variable *const *vars,
struct casegrouper *casegrouper_create_splits (struct casereader *,
const struct dictionary *);
struct casegrouper *casegrouper_create_subcase (struct casereader *,
struct casegrouper *casegrouper_create_splits (struct casereader *,
const struct dictionary *);
struct casegrouper *casegrouper_create_subcase (struct casereader *,
init_list_mark (struct init_list *list, const struct init_list *exclude,
enum leave_class include, const struct dictionary *d)
{
init_list_mark (struct init_list *list, const struct init_list *exclude,
enum leave_class include, const struct dictionary *d)
{
- size_t var_cnt = dict_get_var_cnt (d);
- size_t i;
+ size_t n_vars = dict_get_n_vars (d);
assert (list != exclude);
assert (list != exclude);
- list->values = xnrealloc (list->values, list->cnt + dict_get_var_cnt (d),
+ list->values = xnrealloc (list->values, list->cnt + dict_get_n_vars (d),
- for (i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *v = dict_get_var (d, i);
size_t case_index = var_get_case_index (v);
{
struct variable *v = dict_get_var (d, i);
size_t case_index = var_get_case_index (v);
struct casereader_filter_missing
{
struct variable **vars; /* Variables whose values to filter. */
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;
};
enum mv_class class; /* Types of missing values to filter. */
casenumber *n_missing;
};
/* Creates and returns a casereader that filters out cases from
READER that have a missing value in the given CLASS for any of
/* 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.
non-missing values for all of these variables are passed
through.
when the filtering casereader is destroyed. */
struct casereader *
casereader_create_filter_missing (struct casereader *reader,
when the filtering casereader is destroyed. */
struct casereader *
casereader_create_filter_missing (struct casereader *reader,
- const struct variable *const*vars, size_t var_cnt,
+ const struct variable *const *vars, size_t n_vars,
enum mv_class class,
casenumber *n_missing,
struct casewriter *exclude)
{
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);
{
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;
cfm->class = class;
cfm->n_missing = n_missing;
if (n_missing) *n_missing = 0;
const struct casereader_filter_missing *cfm = cfm_;
size_t i;
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);
{
struct variable *var = cfm->vars[i];
const union value *value = case_data (c, var);
struct casereader *
casereader_create_sequential (const struct taint *,
struct casereader *
casereader_create_sequential (const struct taint *,
- const struct caseproto *, casenumber case_cnt,
+ const struct caseproto *, casenumber n_cases,
const struct casereader_class *, void *);
void *casereader_dynamic_cast (struct casereader *, const struct casereader_class *);
const struct casereader_class *, void *);
void *casereader_dynamic_cast (struct casereader *, const struct casereader_class *);
-casereader_create_random (const struct caseproto *, casenumber case_cnt,
+casereader_create_random (const struct caseproto *, casenumber n_cases,
const struct casereader_random_class *, void *aux);
#endif /* data/casereader-provider.h */
const struct casereader_random_class *, void *aux);
#endif /* data/casereader-provider.h */
casereader_shim_insert (struct casereader *reader)
{
const struct caseproto *proto = casereader_get_proto (reader);
casereader_shim_insert (struct casereader *reader)
{
const struct caseproto *proto = casereader_get_proto (reader);
- casenumber case_cnt = casereader_get_case_cnt (reader);
+ casenumber n_cases = casereader_get_n_cases (reader);
struct casereader_shim *s = xmalloc (sizeof *s);
s->window = casewindow_create (proto, settings_get_workspace_cases (proto));
struct casereader_shim *s = xmalloc (sizeof *s);
s->window = casewindow_create (proto, settings_get_workspace_cases (proto));
- s->subreader = casereader_create_random (proto, case_cnt, &shim_class, s);
+ s->subreader = casereader_create_random (proto, n_cases, &shim_class, s);
casereader_swap (reader, s->subreader);
taint_propagate (casewindow_get_taint (s->window),
casereader_get_taint (reader));
casereader_swap (reader, s->subreader);
taint_propagate (casewindow_get_taint (s->window),
casereader_get_taint (reader));
{
struct casereader_shim *s = s_;
{
struct casereader_shim *s = s_;
- while (casewindow_get_case_cnt (s->window) <= offset)
+ while (casewindow_get_n_cases (s->window) <= offset)
if (!buffer_case (s))
return false;
if (!buffer_case (s))
return false;
/* Discards CNT cases from the front of S's window. */
static void
casereader_shim_advance (struct casereader *reader UNUSED, void *s_,
/* Discards CNT cases from the front of S's window. */
static void
casereader_shim_advance (struct casereader *reader UNUSED, void *s_,
{
struct casereader_shim *s = s_;
{
struct casereader_shim *s = s_;
- casewindow_pop_tail (s->window, case_cnt);
+ casewindow_pop_tail (s->window, n_cases);
}
/* Class for the buffered reader. */
}
/* Class for the buffered reader. */
ct->destroy = destroy;
ct->aux = aux;
reader = casereader_create_sequential (
ct->destroy = destroy;
ct->aux = aux;
reader = casereader_create_sequential (
- NULL, output_proto, casereader_get_case_cnt (ct->subreader),
+ NULL, output_proto, casereader_get_n_cases (ct->subreader),
&casereader_translator_class, ct);
taint_propagate (casereader_get_taint (ct->subreader),
casereader_get_taint (reader));
&casereader_translator_class, ct);
taint_propagate (casereader_get_taint (ct->subreader),
casereader_get_taint (reader));
cst->destroy = destroy;
cst->aux = aux;
reader = casereader_create_random (
cst->destroy = destroy;
cst->aux = aux;
reader = casereader_create_random (
- output_proto, casereader_get_case_cnt (cst->subreader),
+ output_proto, casereader_get_n_cases (cst->subreader),
&casereader_stateless_translator_class, cst);
taint_propagate (casereader_get_taint (cst->subreader),
casereader_get_taint (reader));
&casereader_stateless_translator_class, cst);
taint_propagate (casereader_get_taint (cst->subreader),
casereader_get_taint (reader));
{
struct taint *taint; /* Corrupted? */
struct caseproto *proto; /* Format of contained cases. */
{
struct taint *taint; /* Corrupted? */
struct caseproto *proto; /* Format of contained cases. */
- casenumber case_cnt; /* Number of cases,
+ casenumber n_cases; /* Number of cases,
CASENUMBER_MAX if unknown. */
const struct casereader_class *class; /* Class. */
void *aux; /* Auxiliary data for class. */
CASENUMBER_MAX if unknown. */
const struct casereader_class *class; /* Class. */
void *aux; /* Auxiliary data for class. */
struct ccase *
casereader_read (struct casereader *reader)
{
struct ccase *
casereader_read (struct casereader *reader)
{
- if (reader->case_cnt != 0)
+ if (reader->n_cases != 0)
{
/* ->read may use casereader_swap to replace itself by
another reader and then delegate to that reader by
{
/* ->read may use casereader_swap to replace itself by
another reader and then delegate to that reader by
ever will.
To allow this to work, however, we must decrement
ever will.
To allow this to work, however, we must decrement
- case_cnt before calling ->read. If we decremented
- case_cnt after calling ->read, then this would actually
- drop two cases from case_cnt instead of one, and we'd
+ n_cases before calling ->read. If we decremented
+ n_cases after calling ->read, then this would actually
+ drop two cases from n_cases instead of one, and we'd
lose the last case in the casereader. */
struct ccase *c;
lose the last case in the casereader. */
struct ccase *c;
- if (reader->case_cnt != CASENUMBER_MAX)
- reader->case_cnt--;
+ if (reader->n_cases != CASENUMBER_MAX)
+ reader->n_cases--;
c = reader->class->read (reader, reader->aux);
if (c != NULL)
{
size_t n_widths UNUSED = caseproto_get_n_widths (reader->proto);
c = reader->class->read (reader, reader->aux);
if (c != NULL)
{
size_t n_widths UNUSED = caseproto_get_n_widths (reader->proto);
- assert (case_get_value_cnt (c) >= n_widths);
+ assert (case_get_n_values (c) >= n_widths);
expensive_assert (caseproto_equal (case_get_proto (c), 0,
reader->proto, 0, n_widths));
return c;
}
}
expensive_assert (caseproto_equal (case_get_proto (c), 0,
reader->proto, 0, n_widths));
return c;
}
}
struct ccase *
casereader_peek (struct casereader *reader, casenumber idx)
{
struct ccase *
casereader_peek (struct casereader *reader, casenumber idx)
{
- if (idx < reader->case_cnt)
+ if (idx < reader->n_cases)
{
struct ccase *c;
if (reader->class->peek == NULL)
{
struct ccase *c;
if (reader->class->peek == NULL)
if (c != NULL)
return c;
else if (casereader_error (reader))
if (c != NULL)
return c;
else if (casereader_error (reader))
- if (reader->case_cnt > idx)
- reader->case_cnt = idx;
+ if (reader->n_cases > idx)
+ reader->n_cases = idx;
bool
casereader_is_empty (struct casereader *reader)
{
bool
casereader_is_empty (struct casereader *reader)
{
- if (reader->case_cnt == 0)
+ if (reader->n_cases == 0)
actual number of cases in such a casereader, use
casereader_count_cases. */
casenumber
actual number of cases in such a casereader, use
casereader_count_cases. */
casenumber
-casereader_get_case_cnt (struct casereader *reader)
+casereader_get_n_cases (struct casereader *reader)
- return reader->case_cnt;
+ return reader->n_cases;
casenumber
casereader_count_cases (const struct casereader *reader)
{
casenumber
casereader_count_cases (const struct casereader *reader)
{
- if (reader->case_cnt == CASENUMBER_MAX)
+ if (reader->n_cases == CASENUMBER_MAX)
{
struct casereader *reader_rw = CONST_CAST (struct casereader *, reader);
{
struct casereader *reader_rw = CONST_CAST (struct casereader *, reader);
- reader_rw->case_cnt = casereader_count_cases__ (reader, CASENUMBER_MAX);
+ reader_rw->n_cases = casereader_count_cases__ (reader, CASENUMBER_MAX);
- return reader->case_cnt;
+ return reader->n_cases;
}
/* Truncates READER to at most N cases. */
}
/* Truncates READER to at most N cases. */
"max_cases" member to struct casereader. We could also add a "truncate"
function to the casereader implementation, to allow the casereader to
throw away data that cannot ever be read. */
"max_cases" member to struct casereader. We could also add a "truncate"
function to the casereader implementation, to allow the casereader to
throw away data that cannot ever be read. */
- if (reader->case_cnt == CASENUMBER_MAX)
- reader->case_cnt = casereader_count_cases__ (reader, n);
- if (reader->case_cnt > n)
- reader->case_cnt = n;
+ if (reader->n_cases == CASENUMBER_MAX)
+ reader->n_cases = casereader_count_cases__ (reader, n);
+ if (reader->n_cases > n)
+ reader->n_cases = n;
}
/* Returns the prototype for the cases in READER. The caller
}
/* Returns the prototype for the cases in READER. The caller
struct casereader *
casereader_create_sequential (const struct taint *taint,
const struct caseproto *proto,
struct casereader *
casereader_create_sequential (const struct taint *taint,
const struct caseproto *proto,
const struct casereader_class *class, void *aux)
{
struct casereader *reader = xmalloc (sizeof *reader);
reader->taint = taint != NULL ? taint_clone (taint) : taint_create ();
reader->proto = caseproto_ref (proto);
const struct casereader_class *class, void *aux)
{
struct casereader *reader = xmalloc (sizeof *reader);
reader->taint = taint != NULL ? taint_clone (taint) : taint_create ();
reader->proto = caseproto_ref (proto);
- reader->case_cnt = case_cnt;
+ reader->n_cases = n_cases;
reader->class = class;
reader->aux = aux;
return reader;
reader->class = class;
reader->aux = aux;
return reader;
member functions and auxiliary data to pass to those member
functions, respectively. */
struct casereader *
member functions and auxiliary data to pass to those member
functions, respectively. */
struct casereader *
-casereader_create_random (const struct caseproto *proto, casenumber case_cnt,
+casereader_create_random (const struct caseproto *proto, casenumber n_cases,
const struct casereader_random_class *class,
void *aux)
{
const struct casereader_random_class *class,
void *aux)
{
shared->class = class;
shared->aux = aux;
shared->min_offset = 0;
shared->class = class;
shared->aux = aux;
shared->min_offset = 0;
- return casereader_create_sequential (NULL, proto, case_cnt,
+ return casereader_create_sequential (NULL, proto, n_cases,
&random_reader_casereader_class,
make_random_reader (shared, 0));
}
&random_reader_casereader_class,
make_random_reader (shared, 0));
}
struct random_reader_shared *shared = br->shared;
return casereader_create_sequential (casereader_get_taint (reader),
reader->proto,
struct random_reader_shared *shared = br->shared;
return casereader_create_sequential (casereader_get_taint (reader),
reader->proto,
- casereader_get_case_cnt (reader),
+ casereader_get_n_cases (reader),
&random_reader_casereader_class,
make_random_reader (shared,
br->offset));
&random_reader_casereader_class,
make_random_reader (shared,
br->offset));
void casereader_force_error (struct casereader *);
const struct taint *casereader_get_taint (const struct casereader *);
void casereader_force_error (struct casereader *);
const struct taint *casereader_get_taint (const struct casereader *);
-casenumber casereader_get_case_cnt (struct casereader *);
+casenumber casereader_get_n_cases (struct casereader *);
casenumber casereader_count_cases (const struct casereader *);
void casereader_truncate (struct casereader *, casenumber);
const struct caseproto *casereader_get_proto (const struct casereader *);
casenumber casereader_count_cases (const struct casereader *);
void casereader_truncate (struct casereader *, casenumber);
const struct caseproto *casereader_get_proto (const struct casereader *);
struct casewriter *exclude);
struct casereader *
casereader_create_filter_missing (struct casereader *,
struct casewriter *exclude);
struct casereader *
casereader_create_filter_missing (struct casereader *,
- const struct variable *const*vars, size_t var_cnt,
+ const struct variable *const *vars, size_t n_vars,
enum mv_class,
casenumber *n_missing,
struct casewriter *exclude);
enum mv_class,
casenumber *n_missing,
struct casewriter *exclude);
void (*push_head) (void *aux, struct ccase *);
void (*pop_tail) (void *aux, casenumber cnt);
struct ccase *(*get_case) (void *aux, casenumber ofs);
void (*push_head) (void *aux, struct ccase *);
void (*pop_tail) (void *aux, casenumber cnt);
struct ccase *(*get_case) (void *aux, casenumber ofs);
- casenumber (*get_case_cnt) (const void *aux);
+ casenumber (*get_n_cases) (const void *aux);
{
struct casewindow *new;
new = do_casewindow_create (taint_clone (old->taint), old->proto, 0);
{
struct casewindow *new;
new = do_casewindow_create (taint_clone (old->taint), old->proto, 0);
- while (casewindow_get_case_cnt (old) > 0 && !casewindow_error (new))
+ while (casewindow_get_n_cases (old) > 0 && !casewindow_error (new))
{
struct ccase *c = casewindow_get_case (old, 0);
if (c == NULL)
{
struct ccase *c = casewindow_get_case (old, 0);
if (c == NULL)
cw->class->push_head (cw->aux, c);
if (!casewindow_error (cw))
{
cw->class->push_head (cw->aux, c);
if (!casewindow_error (cw))
{
- casenumber case_cnt = cw->class->get_case_cnt (cw->aux);
- if (case_cnt > cw->max_in_core_cases
+ casenumber n_cases = cw->class->get_n_cases (cw->aux);
+ if (n_cases > cw->max_in_core_cases
&& cw->class == &casewindow_memory_class)
casewindow_to_disk (cw);
}
&& cw->class == &casewindow_memory_class)
casewindow_to_disk (cw);
}
/* Deletes CASE_CNT cases at the tail of casewindow CW. */
void
/* Deletes CASE_CNT cases at the tail of casewindow CW. */
void
-casewindow_pop_tail (struct casewindow *cw, casenumber case_cnt)
+casewindow_pop_tail (struct casewindow *cw, casenumber n_cases)
{
if (!casewindow_error (cw))
{
if (!casewindow_error (cw))
- cw->class->pop_tail (cw->aux, case_cnt);
+ cw->class->pop_tail (cw->aux, n_cases);
}
/* Returns the case that is CASE_IDX cases away from CW's tail
}
/* Returns the case that is CASE_IDX cases away from CW's tail
{
struct casewindow *cw = CONST_CAST (struct casewindow *, cw_);
{
struct casewindow *cw = CONST_CAST (struct casewindow *, cw_);
- assert (case_idx >= 0 && case_idx < casewindow_get_case_cnt (cw));
+ assert (case_idx >= 0 && case_idx < casewindow_get_n_cases (cw));
if (casewindow_error (cw))
return NULL;
return cw->class->get_case (cw->aux, case_idx);
if (casewindow_error (cw))
return NULL;
return cw->class->get_case (cw->aux, case_idx);
/* Returns the number of cases in casewindow CW. */
casenumber
/* Returns the number of cases in casewindow CW. */
casenumber
-casewindow_get_case_cnt (const struct casewindow *cw)
+casewindow_get_n_cases (const struct casewindow *cw)
- return cw->class->get_case_cnt (cw->aux);
+ return cw->class->get_n_cases (cw->aux);
}
/* Returns the case prototype for the cases in casewindow CW.
}
/* Returns the case prototype for the cases in casewindow CW.
-casewindow_memory_pop_tail (void *cwm_, casenumber case_cnt)
+casewindow_memory_pop_tail (void *cwm_, casenumber n_cases)
{
struct casewindow_memory *cwm = cwm_;
{
struct casewindow_memory *cwm = cwm_;
- assert (deque_count (&cwm->deque) >= case_cnt);
- while (case_cnt-- > 0)
+ assert (deque_count (&cwm->deque) >= n_cases);
+ while (n_cases-- > 0)
case_unref (cwm->cases[deque_pop_front (&cwm->deque)]);
}
case_unref (cwm->cases[deque_pop_front (&cwm->deque)]);
}
-casewindow_memory_get_case_cnt (const void *cwm_)
+casewindow_memory_get_n_cases (const void *cwm_)
{
const struct casewindow_memory *cwm = cwm_;
return deque_count (&cwm->deque);
{
const struct casewindow_memory *cwm = cwm_;
return deque_count (&cwm->deque);
casewindow_memory_push_head,
casewindow_memory_pop_tail,
casewindow_memory_get_case,
casewindow_memory_push_head,
casewindow_memory_pop_tail,
casewindow_memory_get_case,
- casewindow_memory_get_case_cnt,
+ casewindow_memory_get_n_cases,
};
\f
/* On-disk casewindow data. */
};
\f
/* On-disk casewindow data. */
-casewindow_file_get_case_cnt (const void *cwf_)
+casewindow_file_get_n_cases (const void *cwf_)
{
const struct casewindow_file *cwf = cwf_;
return cwf->head - cwf->tail;
{
const struct casewindow_file *cwf = cwf_;
return cwf->head - cwf->tail;
casewindow_file_push_head,
casewindow_file_pop_tail,
casewindow_file_get_case,
casewindow_file_push_head,
casewindow_file_pop_tail,
casewindow_file_get_case,
- casewindow_file_get_case_cnt,
+ casewindow_file_get_n_cases,
struct ccase *casewindow_get_case (const struct casewindow *,
casenumber case_idx);
const struct caseproto *casewindow_get_proto (const struct casewindow *);
struct ccase *casewindow_get_case (const struct casewindow *,
casenumber case_idx);
const struct caseproto *casewindow_get_proto (const struct casewindow *);
-casenumber casewindow_get_case_cnt (const struct casewindow *);
+casenumber casewindow_get_n_cases (const struct casewindow *);
bool casewindow_error (const struct casewindow *);
void casewindow_force_error (struct casewindow *);
bool casewindow_error (const struct casewindow *);
void casewindow_force_error (struct casewindow *);
{
struct taint *taint;
struct caseproto *proto;
{
struct taint *taint;
struct caseproto *proto;
const struct casewriter_class *class;
void *aux;
};
const struct casewriter_class *class;
void *aux;
};
casewriter_write (struct casewriter *writer, struct ccase *c)
{
size_t n_widths UNUSED = caseproto_get_n_widths (writer->proto);
casewriter_write (struct casewriter *writer, struct ccase *c)
{
size_t n_widths UNUSED = caseproto_get_n_widths (writer->proto);
- assert (case_get_value_cnt (c) >= n_widths);
+ assert (case_get_n_values (c) >= n_widths);
expensive_assert (caseproto_equal (case_get_proto (c), 0,
writer->proto, 0, n_widths));
writer->class->write (writer, writer->aux, c);
expensive_assert (caseproto_equal (case_get_proto (c), 0,
writer->proto, 0, n_widths));
writer->class->write (writer, writer->aux, c);
struct casewriter *writer = xmalloc (sizeof *writer);
writer->taint = taint_create ();
writer->proto = caseproto_ref (proto);
struct casewriter *writer = xmalloc (sizeof *writer);
writer->taint = taint_create ();
writer->proto = caseproto_ref (proto);
writer->class = class;
writer->aux = aux;
return writer;
writer->class = class;
writer->aux = aux;
return writer;
struct casewindow *window = window_;
struct casereader *reader =
casereader_create_random (casewindow_get_proto (window),
struct casewindow *window = window_;
struct casereader *reader =
casereader_create_random (casewindow_get_proto (window),
- casewindow_get_case_cnt (window),
+ casewindow_get_n_cases (window),
&casereader_window_class, window);
taint_propagate (casewindow_get_taint (window),
&casereader_window_class, window);
taint_propagate (casewindow_get_taint (window),
casenumber offset)
{
struct casewindow *window = window_;
casenumber offset)
{
struct casewindow *window = window_;
- if (offset >= casewindow_get_case_cnt (window))
+ if (offset >= casewindow_get_n_cases (window))
return NULL;
return casewindow_get_case (window, offset);
}
return NULL;
return casewindow_get_case (window, offset);
}
/* Discards CASE_CNT cases from the front of WINDOW. */
static void
casereader_window_advance (struct casereader *reader UNUSED, void *window_,
/* Discards CASE_CNT cases from the front of WINDOW. */
static void
casereader_window_advance (struct casereader *reader UNUSED, void *window_,
{
struct casewindow *window = window_;
{
struct casewindow *window = window_;
- casewindow_pop_tail (window, case_cnt);
+ casewindow_pop_tail (window, n_cases);
}
/* Class for casewindow writer. */
}
/* Class for casewindow writer. */
w->encoding = xstrdup (dict_get_encoding (dict));
w->encoding = xstrdup (dict_get_encoding (dict));
- w->n_csv_vars = dict_get_var_cnt (dict);
+ w->n_csv_vars = dict_get_n_vars (dict);
w->csv_vars = xnmalloc (w->n_csv_vars, sizeof *w->csv_vars);
for (i = 0; i < w->n_csv_vars; i++)
{
w->csv_vars = xnmalloc (w->n_csv_vars, sizeof *w->csv_vars);
for (i = 0; i < w->n_csv_vars; i++)
{
if (!ds->discard_output)
{
struct dictionary *pd = ds->permanent_dict;
if (!ds->discard_output)
{
struct dictionary *pd = ds->permanent_dict;
- size_t compacted_value_cnt = dict_count_values (pd, 1u << DC_SCRATCH);
- if (compacted_value_cnt < dict_get_next_value_idx (pd))
+ size_t compacted_n_values = dict_count_values (pd, 1u << DC_SCRATCH);
+ if (compacted_n_values < dict_get_next_value_idx (pd))
{
struct caseproto *compacted_proto;
compacted_proto = dict_get_compacted_proto (pd, 1u << DC_SCRATCH);
{
struct caseproto *compacted_proto;
compacted_proto = dict_get_compacted_proto (pd, 1u << DC_SCRATCH);
while (cnt > 0)
{
unsigned long first_phy;
while (cnt > 0)
{
unsigned long first_phy;
unsigned long i;
/* Allocate physical rows from the pool of available
rows. */
unsigned long i;
/* Allocate physical rows from the pool of available
rows. */
- if (!axis_allocate (ds->rows, cnt, &first_phy, &phy_cnt))
+ if (!axis_allocate (ds->rows, cnt, &first_phy, &n_phys))
{
/* No rows were available. Extend the row axis to make
some new ones available. */
{
/* No rows were available. Extend the row axis to make
some new ones available. */
first_phy = axis_extend (ds->rows, cnt);
}
/* Insert the new rows into the row mapping. */
first_phy = axis_extend (ds->rows, cnt);
}
/* Insert the new rows into the row mapping. */
- axis_insert (ds->rows, before, first_phy, phy_cnt);
+ axis_insert (ds->rows, before, first_phy, n_phys);
/* Initialize the new rows. */
/* Initialize the new rows. */
- for (i = 0; i < phy_cnt; i++)
+ for (i = 0; i < n_phys; i++)
if (!datasheet_put_row (ds, before + i, c[i]))
{
while (++i < cnt)
case_unref (c[i]);
if (!datasheet_put_row (ds, before + i, c[i]))
{
while (++i < cnt)
case_unref (c[i]);
- datasheet_delete_rows (ds, before - added, phy_cnt + added);
+ datasheet_delete_rows (ds, before - added, n_phys + added);
return false;
}
/* Advance. */
return false;
}
/* Advance. */
- c += phy_cnt;
- cnt -= phy_cnt;
- before += phy_cnt;
- added += phy_cnt;
+ c += n_phys;
+ cnt -= n_phys;
+ before += n_phys;
+ added += n_phys;
/* "advance" function for the datasheet random casereader. */
static void
datasheet_reader_advance (struct casereader *reader UNUSED, void *ds_,
/* "advance" function for the datasheet random casereader. */
static void
datasheet_reader_advance (struct casereader *reader UNUSED, void *ds_,
{
struct datasheet *ds = ds_;
{
struct datasheet *ds = ds_;
- datasheet_delete_rows (ds, 0, case_cnt);
+ datasheet_delete_rows (ds, 0, n_cases);
}
/* Random casereader class for a datasheet. */
}
/* Random casereader class for a datasheet. */
struct dictionary
{
int ref_cnt;
struct dictionary
{
int ref_cnt;
- struct vardict_info *var; /* Variables. */
- size_t var_cnt, var_cap; /* Number of variables, capacity. */
+ struct vardict_info *vars; /* Variables. */
+ size_t n_vars; /* Number of variables. */
+ size_t allocated_vars; /* Allocated space in 'vars'. */
struct caseproto *proto; /* Prototype for dictionary cases
(updated lazily). */
struct hmap name_map; /* Variable index by name. */
int next_value_idx; /* Index of next `union value' to allocate. */
const struct variable **split; /* SPLIT FILE vars. */
struct caseproto *proto; /* Prototype for dictionary cases
(updated lazily). */
struct hmap name_map; /* Variable index by name. */
int next_value_idx; /* Index of next `union value' to allocate. */
const struct variable **split; /* SPLIT FILE vars. */
- size_t split_cnt; /* SPLIT FILE count. */
+ size_t n_splits; /* SPLIT FILE count. */
struct variable *weight; /* WEIGHT variable. */
struct variable *filter; /* FILTER variable. */
casenumber case_limit; /* Current case limit (N command). */
char *label; /* File label. */
struct string_array documents; /* Documents. */
struct vector **vector; /* Vectors of variables. */
struct variable *weight; /* WEIGHT variable. */
struct variable *filter; /* FILTER variable. */
casenumber case_limit; /* Current case limit (N command). */
char *label; /* File label. */
struct string_array documents; /* Documents. */
struct vector **vector; /* Vectors of variables. */
- size_t vector_cnt; /* Number of vectors. */
+ size_t n_vectors; /* Number of vectors. */
struct attrset attributes; /* Custom attributes. */
struct mrset **mrsets; /* Multiple response sets. */
size_t n_mrsets; /* Number of multiple response sets. */
struct attrset attributes; /* Custom attributes. */
struct mrset **mrsets; /* Multiple response sets. */
size_t n_mrsets; /* Number of multiple response sets. */
size_t i;
for (i = from; i < to; i++)
size_t i;
for (i = from; i < to; i++)
- unindex_var (d, &d->var[i]);
+ unindex_var (d, &d->vars[i]);
}
/* Re-sets the dict_index in the dictionary variables with
}
/* Re-sets the dict_index in the dictionary variables with
size_t i;
for (i = from; i < to; i++)
size_t i;
for (i = from; i < to; i++)
- reindex_var (d, &d->var[i], skip_callbacks);
+ reindex_var (d, &d->vars[i], skip_callbacks);
dict_dump (const struct dictionary *d)
{
int i;
dict_dump (const struct dictionary *d)
{
int i;
- for (i = 0 ; i < d->var_cnt ; ++i)
+ for (i = 0 ; i < d->n_vars ; ++i)
- const struct variable *v = d->var[i].var;
+ const struct variable *v = d->vars[i].var;
printf ("Name: %s;\tdict_idx: %zu; case_idx: %zu\n",
var_get_name (v),
var_get_dict_index (v),
printf ("Name: %s;\tdict_idx: %zu; case_idx: %zu\n",
var_get_name (v),
var_get_dict_index (v),
d = dict_create (s->encoding);
dict_set_names_must_be_ids (d, dict_get_names_must_be_ids (s));
d = dict_create (s->encoding);
dict_set_names_must_be_ids (d, dict_get_names_must_be_ids (s));
- for (i = 0; i < s->var_cnt; i++)
+ for (i = 0; i < s->n_vars; i++)
- struct variable *sv = s->var[i].var;
+ struct variable *sv = s->vars[i].var;
struct variable *dv = dict_clone_var_assert (d, sv);
size_t i;
struct variable *dv = dict_clone_var_assert (d, sv);
size_t i;
- for (i = 0; i < var_get_short_name_cnt (sv); i++)
+ for (i = 0; i < var_get_n_short_names (sv); i++)
var_set_short_name (dv, i, var_get_short_name (sv, i));
var_get_vardict (dv)->case_index = var_get_vardict (sv)->case_index;
var_set_short_name (dv, i, var_get_short_name (sv, i));
var_get_vardict (dv)->case_index = var_get_vardict (sv)->case_index;
d->next_value_idx = s->next_value_idx;
d->next_value_idx = s->next_value_idx;
- d->split_cnt = s->split_cnt;
- if (d->split_cnt > 0)
+ d->n_splits = s->n_splits;
+ if (d->n_splits > 0)
- d->split = xnmalloc (d->split_cnt, sizeof *d->split);
- for (i = 0; i < d->split_cnt; i++)
+ d->split = xnmalloc (d->n_splits, sizeof *d->split);
+ for (i = 0; i < d->n_splits; i++)
d->split[i] = dict_lookup_var_assert (d, var_get_name (s->split[i]));
}
d->split[i] = dict_lookup_var_assert (d, var_get_name (s->split[i]));
}
dict_set_label (d, dict_get_label (s));
dict_set_documents (d, dict_get_documents (s));
dict_set_label (d, dict_get_label (s));
dict_set_documents (d, dict_get_documents (s));
- d->vector_cnt = s->vector_cnt;
- d->vector = xnmalloc (d->vector_cnt, sizeof *d->vector);
- for (i = 0; i < s->vector_cnt; i++)
+ d->n_vectors = s->n_vectors;
+ d->vector = xnmalloc (d->n_vectors, sizeof *d->vector);
+ for (i = 0; i < s->n_vectors; i++)
d->vector[i] = vector_clone (s->vector[i], s, d);
dict_set_attributes (d, dict_get_attributes (s));
d->vector[i] = vector_clone (s->vector[i], s, d);
dict_set_attributes (d, dict_get_attributes (s));
\f
/* Returns the SPLIT FILE vars (see cmd_split_file()). Call
\f
/* Returns the SPLIT FILE vars (see cmd_split_file()). Call
- dict_get_split_cnt() to determine how many SPLIT FILE vars
+ dict_get_n_splits() to determine how many SPLIT FILE vars
there are. Returns a null pointer if and only if there are no
SPLIT FILE vars. */
const struct variable *const *
there are. Returns a null pointer if and only if there are no
SPLIT FILE vars. */
const struct variable *const *
/* Returns the number of SPLIT FILE vars. */
size_t
/* Returns the number of SPLIT FILE vars. */
size_t
-dict_get_split_cnt (const struct dictionary *d)
+dict_get_n_splits (const struct dictionary *d)
}
/* Removes variable V, which must be in D, from D's set of split
}
/* Removes variable V, which must be in D, from D's set of split
assert (dict_contains_var (d, v));
assert (dict_contains_var (d, v));
- orig_count = d->split_cnt;
- d->split_cnt = remove_equal (d->split, d->split_cnt, sizeof *d->split,
+ orig_count = d->n_splits;
+ d->n_splits = remove_equal (d->split, d->n_splits, sizeof *d->split,
&v, compare_var_ptrs, NULL);
&v, compare_var_ptrs, NULL);
- if (orig_count != d->split_cnt && !skip_callbacks)
+ if (orig_count != d->n_splits && !skip_callbacks)
{
if (d->changed) d->changed (d, d->changed_data);
/* We changed the set of split variables so invoke the
{
if (d->changed) d->changed (d, d->changed_data);
/* We changed the set of split variables so invoke the
-/* Sets CNT split vars SPLIT in dictionary D. */
+/* Sets N split vars SPLIT in dictionary D. */
static void
dict_set_split_vars__ (struct dictionary *d,
static void
dict_set_split_vars__ (struct dictionary *d,
- struct variable *const *split, size_t cnt, bool skip_callbacks)
+ struct variable *const *split, size_t n,
+ bool skip_callbacks)
- assert (cnt == 0 || split != NULL);
+ assert (n == 0 || split != NULL);
- d->split_cnt = cnt;
- if (cnt > 0)
+ d->n_splits = n;
+ if (n > 0)
- d->split = xnrealloc (d->split, cnt, sizeof *d->split) ;
- memcpy (d->split, split, cnt * sizeof *d->split);
+ d->split = xnrealloc (d->split, n, sizeof *d->split) ;
+ memcpy (d->split, split, n * sizeof *d->split);
-/* Sets CNT split vars SPLIT in dictionary D. */
+/* Sets N split vars SPLIT in dictionary D. */
void
dict_set_split_vars (struct dictionary *d,
void
dict_set_split_vars (struct dictionary *d,
- struct variable *const *split, size_t cnt)
+ struct variable *const *split, size_t n)
- dict_set_split_vars__ (d, split, cnt, false);
+ dict_set_split_vars__ (d, split, n, false);
dict_clear_vectors (d);
/* Remove V from var array. */
dict_clear_vectors (d);
/* Remove V from var array. */
- unindex_vars (d, dict_index, d->var_cnt);
- remove_element (d->var, d->var_cnt, sizeof *d->var, dict_index);
- d->var_cnt--;
+ unindex_vars (d, dict_index, d->n_vars);
+ remove_element (d->vars, d->n_vars, sizeof *d->vars, dict_index);
+ d->n_vars--;
/* Update dict_index for each affected variable. */
/* Update dict_index for each affected variable. */
- reindex_vars (d, dict_index, d->var_cnt, skip_callbacks);
+ reindex_vars (d, dict_index, d->n_vars, skip_callbacks);
/* Free memory. */
var_clear_vardict (v);
/* Free memory. */
var_clear_vardict (v);
details. Deleting consecutive vars will result in less callbacks
compared to iterating over dict_delete_var.
A simple while loop over dict_delete_var will
details. Deleting consecutive vars will result in less callbacks
compared to iterating over dict_delete_var.
A simple while loop over dict_delete_var will
- produce (d->var_cnt - IDX) * COUNT variable changed callbacks
+ produce (d->n_vars - IDX) * COUNT variable changed callbacks
plus COUNT variable delete callbacks.
plus COUNT variable delete callbacks.
- This here produces d->var_cnt - IDX variable changed callbacks
+ This here produces d->n_vars - IDX variable changed callbacks
plus COUNT variable delete callbacks. */
void
dict_delete_consecutive_vars (struct dictionary *d, size_t idx, size_t count)
{
plus COUNT variable delete callbacks. */
void
dict_delete_consecutive_vars (struct dictionary *d, size_t idx, size_t count)
{
- assert (idx + count <= d->var_cnt);
+ assert (idx + count <= d->n_vars);
/* We need to store the variable and the corresponding case_index
for the delete callbacks later. We store them in a linked list.*/
/* We need to store the variable and the corresponding case_index
for the delete callbacks later. We store them in a linked list.*/
{
struct delvar *dv = xmalloc (sizeof (struct delvar));
assert (dv);
{
struct delvar *dv = xmalloc (sizeof (struct delvar));
assert (dv);
- struct variable *v = d->var[i].var;
+ struct variable *v = d->vars[i].var;
dict_unset_split_var (d, v, false);
dict_unset_mrset_var (d, v);
dict_unset_split_var (d, v, false);
dict_unset_mrset_var (d, v);
dict_clear_vectors (d);
/* Remove variables from var array. */
dict_clear_vectors (d);
/* Remove variables from var array. */
- unindex_vars (d, idx, d->var_cnt);
- remove_range (d->var, d->var_cnt, sizeof *d->var, idx, count);
- d->var_cnt -= count;
+ unindex_vars (d, idx, d->n_vars);
+ remove_range (d->vars, d->n_vars, sizeof *d->vars, idx, count);
+ d->n_vars -= count;
/* Reindexing will result variable-changed callback */
/* Reindexing will result variable-changed callback */
- reindex_vars (d, idx, d->var_cnt, false);
+ reindex_vars (d, idx, d->n_vars, false);
invalidate_proto (d);
if (d->changed) d->changed (d, d->changed_data);
invalidate_proto (d);
if (d->changed) d->changed (d, d->changed_data);
/* FIXME: this can be done in O(count) time, but this algorithm
is O(count**2). */
/* FIXME: this can be done in O(count) time, but this algorithm
is O(count**2). */
- for (i = 0; i < d->var_cnt;)
- if (var_get_dict_class (d->var[i].var) == DC_SCRATCH)
- dict_delete_var (d, d->var[i].var);
+ for (i = 0; i < d->n_vars;)
+ if (var_get_dict_class (d->vars[i].var) == DC_SCRATCH)
+ dict_delete_var (d, d->vars[i].var);
{
/* FIXME? Should we really clear case_limit, label, documents?
Others are necessarily cleared by deleting all the variables.*/
{
/* FIXME? Should we really clear case_limit, label, documents?
Others are necessarily cleared by deleting all the variables.*/
- dict_delete_var__ (d, d->var[d->var_cnt - 1].var, skip_callbacks);
+ dict_delete_var__ (d, d->vars[d->n_vars - 1].var, skip_callbacks);
- free (d->var);
- d->var = NULL;
- d->var_cnt = d->var_cap = 0;
+ free (d->vars);
+ d->vars = NULL;
+ d->n_vars = d->allocated_vars = 0;
invalidate_proto (d);
hmap_clear (&d->name_map);
d->next_value_idx = 0;
invalidate_proto (d);
hmap_clear (&d->name_map);
d->next_value_idx = 0;
/* Returns the number of variables in D. */
size_t
/* Returns the number of variables in D. */
size_t
-dict_get_var_cnt (const struct dictionary *d)
+dict_get_n_vars (const struct dictionary *d)
}
/* Returns the variable in D with dictionary index IDX, which
must be between 0 and the count returned by
}
/* Returns the variable in D with dictionary index IDX, which
must be between 0 and the count returned by
- dict_get_var_cnt(), exclusive. */
+ dict_get_n_vars(), exclusive. */
struct variable *
dict_get_var (const struct dictionary *d, size_t idx)
{
struct variable *
dict_get_var (const struct dictionary *d, size_t idx)
{
- assert (idx < d->var_cnt);
+ assert (idx < d->n_vars);
- return d->var[idx].var;
+ return d->vars[idx].var;
-/* Sets *VARS to an array of pointers to variables in D and *CNT
+/* Sets *VARS to an array of pointers to variables in D and *N
to the number of variables in *D. All variables are returned
except for those, if any, in the classes indicated by EXCLUDE.
(There is no point in putting DC_SYSTEM in EXCLUDE as
dictionaries never include system variables.) */
void
dict_get_vars (const struct dictionary *d, const struct variable ***vars,
to the number of variables in *D. All variables are returned
except for those, if any, in the classes indicated by EXCLUDE.
(There is no point in putting DC_SYSTEM in EXCLUDE as
dictionaries never include system variables.) */
void
dict_get_vars (const struct dictionary *d, const struct variable ***vars,
- size_t *cnt, enum dict_class exclude)
+ size_t *n, enum dict_class exclude)
- dict_get_vars_mutable (d, (struct variable ***) vars, cnt, exclude);
+ dict_get_vars_mutable (d, (struct variable ***) vars, n, exclude);
-/* Sets *VARS to an array of pointers to variables in D and *CNT
+/* Sets *VARS to an array of pointers to variables in D and *N
to the number of variables in *D. All variables are returned
except for those, if any, in the classes indicated by EXCLUDE.
(There is no point in putting DC_SYSTEM in EXCLUDE as
dictionaries never include system variables.) */
void
dict_get_vars_mutable (const struct dictionary *d, struct variable ***vars,
to the number of variables in *D. All variables are returned
except for those, if any, in the classes indicated by EXCLUDE.
(There is no point in putting DC_SYSTEM in EXCLUDE as
dictionaries never include system variables.) */
void
dict_get_vars_mutable (const struct dictionary *d, struct variable ***vars,
- size_t *cnt, enum dict_class exclude)
+ size_t *n, enum dict_class exclude)
{
size_t count;
size_t i;
{
size_t count;
size_t i;
assert (exclude == (exclude & DC_ALL));
count = 0;
assert (exclude == (exclude & DC_ALL));
count = 0;
- for (i = 0; i < d->var_cnt; i++)
+ for (i = 0; i < d->n_vars; i++)
- enum dict_class class = var_get_dict_class (d->var[i].var);
+ enum dict_class class = var_get_dict_class (d->vars[i].var);
if (!(class & exclude))
count++;
}
*vars = xnmalloc (count, sizeof **vars);
if (!(class & exclude))
count++;
}
*vars = xnmalloc (count, sizeof **vars);
- *cnt = 0;
- for (i = 0; i < d->var_cnt; i++)
+ *n = 0;
+ for (i = 0; i < d->n_vars; i++)
- enum dict_class class = var_get_dict_class (d->var[i].var);
+ enum dict_class class = var_get_dict_class (d->vars[i].var);
- (*vars)[(*cnt)++] = d->var[i].var;
+ (*vars)[(*n)++] = d->vars[i].var;
- assert (*cnt == count);
}
static struct variable *
}
static struct variable *
assert (case_index >= d->next_value_idx);
/* Update dictionary. */
assert (case_index >= d->next_value_idx);
/* Update dictionary. */
- if (d->var_cnt >= d->var_cap)
+ if (d->n_vars >= d->allocated_vars)
- d->var = x2nrealloc (d->var, &d->var_cap, sizeof *d->var);
+ d->vars = x2nrealloc (d->vars, &d->allocated_vars, sizeof *d->vars);
hmap_clear (&d->name_map);
hmap_clear (&d->name_map);
- for (i = 0; i < d->var_cnt; i++)
+ for (i = 0; i < d->n_vars; i++)
- var_set_vardict (d->var[i].var, &d->var[i]);
- hmap_insert_fast (&d->name_map, &d->var[i].name_node,
- d->var[i].name_node.hash);
+ var_set_vardict (d->vars[i].var, &d->vars[i]);
+ hmap_insert_fast (&d->name_map, &d->vars[i].name_node,
+ d->vars[i].name_node.hash);
- vardict = &d->var[d->var_cnt++];
+ vardict = &d->vars[d->n_vars++];
vardict->dict = d;
vardict->var = v;
hmap_insert (&d->name_map, &vardict->name_node,
vardict->dict = d;
vardict->var = v;
hmap_insert (&d->name_map, &vardict->name_node,
{
size_t old_index = var_get_dict_index (v);
{
size_t old_index = var_get_dict_index (v);
- assert (new_index < d->var_cnt);
+ assert (new_index < d->n_vars);
unindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1);
unindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1);
- move_element (d->var, d->var_cnt, sizeof *d->var, old_index, new_index);
+ move_element (d->vars, d->n_vars, sizeof *d->vars, old_index, new_index);
reindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1, false);
}
reindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1, false);
}
size_t i;
assert (count == 0 || order != NULL);
size_t i;
assert (count == 0 || order != NULL);
- assert (count <= d->var_cnt);
+ assert (count <= d->n_vars);
- new_var = xnmalloc (d->var_cap, sizeof *new_var);
+ new_var = xnmalloc (d->allocated_vars, sizeof *new_var);
/* Add variables in ORDER to new_var. */
for (i = 0; i < count; i++)
/* Add variables in ORDER to new_var. */
for (i = 0; i < count; i++)
}
/* Add remaining variables to new_var. */
}
/* Add remaining variables to new_var. */
- for (i = 0; i < d->var_cnt; i++)
- if (d->var[i].dict != NULL)
- new_var[count++] = d->var[i];
- assert (count == d->var_cnt);
+ for (i = 0; i < d->n_vars; i++)
+ if (d->vars[i].dict != NULL)
+ new_var[count++] = d->vars[i];
+ assert (count == d->n_vars);
/* Replace old vardicts by new ones. */
/* Replace old vardicts by new ones. */
- free (d->var);
- d->var = new_var;
+ free (d->vars);
+ d->vars = new_var;
hmap_clear (&d->name_map);
hmap_clear (&d->name_map);
- reindex_vars (d, 0, d->var_cnt, false);
+ reindex_vars (d, 0, d->n_vars, false);
}
/* Changes the name of variable V that is currently in a dictionary to
}
/* Changes the name of variable V that is currently in a dictionary to
size_t i;
d->proto = caseproto_create ();
size_t i;
d->proto = caseproto_create ();
- d->proto = caseproto_reserve (d->proto, d->var_cnt);
- for (i = 0; i < d->var_cnt; i++)
+ d->proto = caseproto_reserve (d->proto, d->n_vars);
+ for (i = 0; i < d->n_vars; i++)
d->proto = caseproto_set_width (d->proto,
d->proto = caseproto_set_width (d->proto,
- var_get_case_index (d->var[i].var),
- var_get_width (d->var[i].var));
+ var_get_case_index (d->vars[i].var),
+ var_get_width (d->vars[i].var));
size_t i;
d->next_value_idx = 0;
size_t i;
d->next_value_idx = 0;
- for (i = 0; i < d->var_cnt; i++)
+ for (i = 0; i < d->n_vars; i++)
- struct variable *v = d->var[i].var;
+ struct variable *v = d->vars[i].var;
set_var_case_index (v, d->next_value_idx++);
}
invalidate_proto (d);
set_var_case_index (v, d->next_value_idx++);
}
invalidate_proto (d);
size_t
dict_count_values (const struct dictionary *d, unsigned int exclude_classes)
{
size_t
dict_count_values (const struct dictionary *d, unsigned int exclude_classes)
{
- size_t i;
- size_t cnt;
-
assert ((exclude_classes & ~((1u << DC_ORDINARY)
| (1u << DC_SYSTEM)
| (1u << DC_SCRATCH))) == 0);
assert ((exclude_classes & ~((1u << DC_ORDINARY)
| (1u << DC_SYSTEM)
| (1u << DC_SCRATCH))) == 0);
- cnt = 0;
- for (i = 0; i < d->var_cnt; i++)
+ size_t n = 0;
+ for (size_t i = 0; i < d->n_vars; i++)
- enum dict_class class = var_get_dict_class (d->var[i].var);
+ enum dict_class class = var_get_dict_class (d->vars[i].var);
if (!(exclude_classes & (1u << class)))
if (!(exclude_classes & (1u << class)))
}
/* Returns the case prototype that would result after deleting
}
/* Returns the case prototype that would result after deleting
| (1u << DC_SCRATCH))) == 0);
proto = caseproto_create ();
| (1u << DC_SCRATCH))) == 0);
proto = caseproto_create ();
- for (i = 0; i < d->var_cnt; i++)
+ for (i = 0; i < d->n_vars; i++)
- struct variable *v = d->var[i].var;
+ struct variable *v = d->vars[i].var;
if (!(exclude_classes & (1u << var_get_dict_class (v))))
proto = caseproto_add_width (proto, var_get_width (v));
}
if (!(exclude_classes & (1u << var_get_dict_class (v))))
proto = caseproto_add_width (proto, var_get_width (v));
}
/* Returns the number of document lines in dictionary D. */
size_t
/* Returns the number of document lines in dictionary D. */
size_t
-dict_get_document_line_cnt (const struct dictionary *d)
+dict_get_document_n_lines (const struct dictionary *d)
{
return d->documents.n;
}
{
return d->documents.n;
}
return d->documents.strings[idx];
}
return d->documents.strings[idx];
}
-/* Creates in D a vector named NAME that contains the CNT
+/* Creates in D a vector named NAME that contains the N
variables in VAR. Returns true if successful, or false if a
vector named NAME already exists in D. */
bool
dict_create_vector (struct dictionary *d,
const char *name,
variables in VAR. Returns true if successful, or false if a
vector named NAME already exists in D. */
bool
dict_create_vector (struct dictionary *d,
const char *name,
- struct variable **var, size_t cnt)
+ struct variable **var, size_t n)
- size_t i;
-
- assert (cnt > 0);
- for (i = 0; i < cnt; i++)
+ assert (n > 0);
+ for (size_t i = 0; i < n; i++)
assert (dict_contains_var (d, var[i]));
if (dict_lookup_vector (d, name) == NULL)
{
assert (dict_contains_var (d, var[i]));
if (dict_lookup_vector (d, name) == NULL)
{
- d->vector = xnrealloc (d->vector, d->vector_cnt + 1, sizeof *d->vector);
- d->vector[d->vector_cnt++] = vector_create (name, var, cnt);
+ d->vector = xnrealloc (d->vector, d->n_vectors + 1, sizeof *d->vector);
+ d->vector[d->n_vectors++] = vector_create (name, var, n);
return true;
}
else
return false;
}
return true;
}
else
return false;
}
-/* Creates in D a vector named NAME that contains the CNT
+/* Creates in D a vector named NAME that contains the N
variables in VAR. A vector named NAME must not already exist
in D. */
void
dict_create_vector_assert (struct dictionary *d,
const char *name,
variables in VAR. A vector named NAME must not already exist
in D. */
void
dict_create_vector_assert (struct dictionary *d,
const char *name,
- struct variable **var, size_t cnt)
+ struct variable **var, size_t n)
{
assert (dict_lookup_vector (d, name) == NULL);
{
assert (dict_lookup_vector (d, name) == NULL);
- dict_create_vector (d, name, var, cnt);
+ dict_create_vector (d, name, var, n);
}
/* Returns the vector in D with index IDX, which must be less
}
/* Returns the vector in D with index IDX, which must be less
- than dict_get_vector_cnt (D). */
+ than dict_get_n_vectors (D). */
const struct vector *
dict_get_vector (const struct dictionary *d, size_t idx)
{
const struct vector *
dict_get_vector (const struct dictionary *d, size_t idx)
{
- assert (idx < d->vector_cnt);
+ assert (idx < d->n_vectors);
return d->vector[idx];
}
/* Returns the number of vectors in D. */
size_t
return d->vector[idx];
}
/* Returns the number of vectors in D. */
size_t
-dict_get_vector_cnt (const struct dictionary *d)
+dict_get_n_vectors (const struct dictionary *d)
}
/* Looks up and returns the vector within D with the given
}
/* Looks up and returns the vector within D with the given
dict_lookup_vector (const struct dictionary *d, const char *name)
{
size_t i;
dict_lookup_vector (const struct dictionary *d, const char *name)
{
size_t i;
- for (i = 0; i < d->vector_cnt; i++)
+ for (i = 0; i < d->n_vectors; i++)
if (!utf8_strcasecmp (vector_get_name (d->vector[i]), name))
return d->vector[i];
return NULL;
if (!utf8_strcasecmp (vector_get_name (d->vector[i]), name))
return d->vector[i];
return NULL;
- for (i = 0; i < d->vector_cnt; i++)
+ for (i = 0; i < d->n_vectors; i++)
vector_destroy (d->vector[i]);
free (d->vector);
d->vector = NULL;
vector_destroy (d->vector[i]);
free (d->vector);
d->vector = NULL;
}
\f
/* Multiple response sets. */
}
\f
/* Multiple response sets. */
/* Destroy internal_dict if it has no variables left, just so that
valgrind --leak-check --show-reachable won't show internal_dict. */
/* Destroy internal_dict if it has no variables left, just so that
valgrind --leak-check --show-reachable won't show internal_dict. */
- if (dict_get_var_cnt (internal_dict) == 0)
+ if (dict_get_n_vars (internal_dict) == 0)
{
dict_unref (internal_dict);
internal_dict = NULL;
{
dict_unref (internal_dict);
internal_dict = NULL;
int
vardict_get_dict_index (const struct vardict_info *vardict)
{
int
vardict_get_dict_index (const struct vardict_info *vardict)
{
- return vardict - vardict->dict->var;
+ return vardict - vardict->dict->vars;
struct variable *dict_lookup_var_assert (const struct dictionary *,
const char *);
struct variable *dict_get_var (const struct dictionary *, size_t position);
struct variable *dict_lookup_var_assert (const struct dictionary *,
const char *);
struct variable *dict_get_var (const struct dictionary *, size_t position);
-size_t dict_get_var_cnt (const struct dictionary *);
+size_t dict_get_n_vars (const struct dictionary *);
/* Other access to variables. */
bool dict_contains_var (const struct dictionary *, const struct variable *);
void dict_get_vars (const struct dictionary *,
/* Other access to variables. */
bool dict_contains_var (const struct dictionary *, const struct variable *);
void dict_get_vars (const struct dictionary *,
- const struct variable ***vars, size_t *cnt,
+ const struct variable ***vars, size_t *n_vars,
enum dict_class exclude);
void dict_get_vars_mutable (const struct dictionary *,
enum dict_class exclude);
void dict_get_vars_mutable (const struct dictionary *,
- struct variable ***vars, size_t *cnt,
+ struct variable ***vars, size_t *n_vars,
enum dict_class exclude);
/* Creating variables. */
enum dict_class exclude);
/* Creating variables. */
/* SPLIT FILE variables. */
const struct variable *const *dict_get_split_vars (const struct dictionary *);
/* SPLIT FILE variables. */
const struct variable *const *dict_get_split_vars (const struct dictionary *);
-size_t dict_get_split_cnt (const struct dictionary *);
+size_t dict_get_n_splits (const struct dictionary *);
void dict_set_split_vars (struct dictionary *,
void dict_set_split_vars (struct dictionary *,
- struct variable *const *, size_t cnt);
+ struct variable *const *, size_t n);
/* File label. */
const char *dict_get_label (const struct dictionary *);
/* File label. */
const char *dict_get_label (const struct dictionary *);
bool dict_add_document_line (struct dictionary *, const char *,
bool issue_warning);
bool dict_add_document_line (struct dictionary *, const char *,
bool issue_warning);
-size_t dict_get_document_line_cnt (const struct dictionary *);
+size_t dict_get_document_n_lines (const struct dictionary *);
const char *dict_get_document_line (const struct dictionary *, size_t);
/* Vectors. */
bool dict_create_vector (struct dictionary *, const char *name,
const char *dict_get_document_line (const struct dictionary *, size_t);
/* Vectors. */
bool dict_create_vector (struct dictionary *, const char *name,
- struct variable **, size_t cnt);
+ struct variable **, size_t n);
void dict_create_vector_assert (struct dictionary *, const char *name,
void dict_create_vector_assert (struct dictionary *, const char *name,
- struct variable **, size_t cnt);
+ struct variable **, size_t n);
const struct vector *dict_get_vector (const struct dictionary *, size_t idx);
const struct vector *dict_get_vector (const struct dictionary *, size_t idx);
-size_t dict_get_vector_cnt (const struct dictionary *);
+size_t dict_get_n_vectors (const struct dictionary *);
const struct vector *dict_lookup_vector (const struct dictionary *,
const char *name);
void dict_clear_vectors (struct dictionary *);
const struct vector *dict_lookup_vector (const struct dictionary *,
const char *name);
void dict_clear_vectors (struct dictionary *);
{
enum fmt_type format; /* Format type. */
#define MAX_TOKENS 11
{
enum fmt_type format; /* Format type. */
#define MAX_TOKENS 11
- size_t token_cnt; /* Number of tokens. */
+ size_t n_tokens; /* Number of tokens. */
enum date_token tokens[MAX_TOKENS]; /* Tokens. */
};
enum date_token tokens[MAX_TOKENS]; /* Tokens. */
};
enum date_token token;
enum date_token tokens[MAX_TOKENS];
enum date_token tokens_seen;
enum date_token token;
enum date_token tokens[MAX_TOKENS];
enum date_token tokens_seen;
int decimals;
bool is_date;
int i;
/* Break S into tokens. */
int decimals;
bool is_date;
int i;
/* Break S into tokens. */
tokens_seen = 0;
decimals = 0;
while (!ss_is_empty (s))
{
tokens_seen = 0;
decimals = 0;
while (!ss_is_empty (s))
{
- if (token_cnt >= MAX_TOKENS)
+ if (n_tokens >= MAX_TOKENS)
return;
token = parse_date_token (&s, tokens_seen, &decimals);
if (token == 0)
return;
return;
token = parse_date_token (&s, tokens_seen, &decimals);
if (token == 0)
return;
- tokens[token_cnt++] = token;
+ tokens[n_tokens++] = token;
return;
/* Find matching date formats, if any, and increment the
return;
/* Find matching date formats, if any, and increment the
for (i = 0; i < DATE_SYNTAX_CNT; i++)
{
struct date_syntax *s = &syntax[i];
for (i = 0; i < DATE_SYNTAX_CNT; i++)
{
struct date_syntax *s = &syntax[i];
- if (match_date_syntax (tokens, token_cnt, s->tokens, s->token_cnt))
+ if (match_date_syntax (tokens, n_tokens, s->tokens, s->n_tokens))
{
is_date = true;
g->date[i]++;
{
is_date = true;
g->date[i]++;
{
for (i = 0; i < DATE_SYNTAX_CNT; i++)
if (g->date[i]
{
for (i = 0; i < DATE_SYNTAX_CNT; i++)
if (g->date[i]
- && syntax[i].tokens[syntax[i].token_cnt - 1] == DT_SECOND)
+ && syntax[i].tokens[syntax[i].n_tokens - 1] == DT_SECOND)
{
f->d = g->decimals / g->count;
f->w = MAX (f->w, fmt_min_input_width (f->type) + 3);
{
f->d = g->decimals / g->count;
f->w = MAX (f->w, fmt_min_input_width (f->type) + 3);
int *decimals)
{
long int value;
int *decimals)
{
long int value;
- size_t digit_cnt = ss_get_long (s, &value);
+ size_t n_digits = ss_get_long (s, &value);
enum date_token token = 0;
if (ss_match_byte (s, settings_get_fmt_settings ()->decimal)
enum date_token token = 0;
if (ss_match_byte (s, settings_get_fmt_settings ()->decimal)
else
token = DT_DAY_COUNT;
else
token = DT_DAY_COUNT;
{
token |= DT_YEAR;
if (value <= 59)
token |= DT_MINUTE | DT_SECOND;
}
{
token |= DT_YEAR;
if (value <= 59)
token |= DT_MINUTE | DT_SECOND;
}
- else if (digit_cnt == 4)
+ else if (n_digits == 4)
{ T_TO, SS_LITERAL_INITIALIZER ("TO") },
{ T_WITH, SS_LITERAL_INITIALIZER ("WITH") },
};
{ T_TO, SS_LITERAL_INITIALIZER ("TO") },
{ T_WITH, SS_LITERAL_INITIALIZER ("WITH") },
};
-static const size_t keyword_cnt = sizeof keywords / sizeof *keywords;
+static const size_t n_keywords = sizeof keywords / sizeof *keywords;
/* Returns true if TOKEN is representable as a keyword. */
bool
lex_is_keyword (enum token_type token)
{
const struct keyword *kw;
/* Returns true if TOKEN is representable as a keyword. */
bool
lex_is_keyword (enum token_type token)
{
const struct keyword *kw;
- for (kw = keywords; kw < &keywords[keyword_cnt]; kw++)
+ for (kw = keywords; kw < &keywords[n_keywords]; kw++)
if (kw->token == token)
return true;
return false;
if (kw->token == token)
return true;
return false;
if (ss_length (id) >= 2 && ss_length (id) <= 4)
{
const struct keyword *kw;
if (ss_length (id) >= 2 && ss_length (id) <= 4)
{
const struct keyword *kw;
- for (kw = keywords; kw < &keywords[keyword_cnt]; kw++)
+ for (kw = keywords; kw < &keywords[n_keywords]; kw++)
if (ss_equals_case (kw->identifier, id))
return kw->token;
}
if (ss_equals_case (kw->identifier, id))
return kw->token;
}
data source or CASENUMBER_MAX if the number of cases cannot be
predicted in advance. */
struct casereader *
data source or CASENUMBER_MAX if the number of cases cannot be
predicted in advance. */
struct casereader *
-lazy_casereader_create (const struct caseproto *proto, casenumber case_cnt,
+lazy_casereader_create (const struct caseproto *proto, casenumber n_cases,
struct casereader *(*callback) (void *aux), void *aux,
unsigned long int *serial)
{
struct casereader *(*callback) (void *aux), void *aux,
unsigned long int *serial)
{
*serial = lc->serial = next_serial++;
lc->callback = callback;
lc->aux = aux;
*serial = lc->serial = next_serial++;
lc->callback = callback;
lc->aux = aux;
- return casereader_create_sequential (NULL, proto, case_cnt,
+ return casereader_create_sequential (NULL, proto, n_cases,
&lazy_casereader_class, lc);
}
&lazy_casereader_class, lc);
}
#include "data/case.h"
struct casereader *lazy_casereader_create (const struct caseproto *,
#include "data/case.h"
struct casereader *lazy_casereader_create (const struct caseproto *,
struct casereader *(*) (void *aux),
void *aux,
unsigned long int *serial);
struct casereader *(*) (void *aux),
void *aux,
unsigned long int *serial);
struct all_dict_variables
all_variables (struct dictionary *dict)
{
struct all_dict_variables
all_variables (struct dictionary *dict)
{
- size_t n_vars = dict_get_var_cnt (dict);
+ size_t n_vars = dict_get_n_vars (dict);
/* Start with a set of all variable names. */
struct string_set var_names = STRING_SET_INITIALIZER (var_names);
/* Start with a set of all variable names. */
struct string_set var_names = STRING_SET_INITIALIZER (var_names);
const char *sav_name)
{
struct mdd_writer *w = XZALLOC (struct mdd_writer);
const char *sav_name)
{
struct mdd_writer *w = XZALLOC (struct mdd_writer);
- size_t n_vars = dict_get_var_cnt (dict);
+ size_t n_vars = dict_get_n_vars (dict);
/* Open file handle as an exclusive writer. */
/* TRANSLATORS: this fragment will be interpolated into
/* Open file handle as an exclusive writer. */
/* TRANSLATORS: this fragment will be interpolated into
/* We reserve ids 1...N_VARS for variables and then start other ids after
that. */
/* We reserve ids 1...N_VARS for variables and then start other ids after
that. */
- int id = dict_get_var_cnt (dict) + 1;
+ int id = dict_get_n_vars (dict) + 1;
/* <definition/> */
xmlTextWriterStartElement (w->writer, _xml ("definition"));
/* <definition/> */
xmlTextWriterStartElement (w->writer, _xml ("definition"));
continue;
if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col)
break;
continue;
if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col)
break;
- if (idx >= dict_get_var_cnt (r->spreadsheet.dict))
+ if (idx >= dict_get_n_vars (r->spreadsheet.dict))
break;
var = dict_get_var (r->spreadsheet.dict, idx);
break;
var = dict_get_var (r->spreadsheet.dict, idx);
info->integer_format = INTEGER_LSB_FIRST;
info->float_format = FLOAT_IEEE_DOUBLE_LE;
info->compression = r->compressed ? ANY_COMP_SIMPLE : ANY_COMP_NONE;
info->integer_format = INTEGER_LSB_FIRST;
info->float_format = FLOAT_IEEE_DOUBLE_LE;
info->compression = r->compressed ? ANY_COMP_SIMPLE : ANY_COMP_NONE;
- info->case_cnt = r->n_cases;
+ info->n_cases = r->n_cases;
/* Convert file label to UTF-8 and put it into DICT. */
label = recode_and_trim_string (r->pool, dict_encoding, header->file_label);
/* Convert file label to UTF-8 and put it into DICT. */
label = recode_and_trim_string (r->pool, dict_encoding, header->file_label);
an error. */
static inline int
read_bytes_internal (struct pcp_reader *r, bool eof_is_ok,
an error. */
static inline int
read_bytes_internal (struct pcp_reader *r, bool eof_is_ok,
- void *buf, size_t byte_cnt)
+ void *buf, size_t n_bytes)
- size_t bytes_read = fread (buf, 1, byte_cnt, r->file);
+ size_t bytes_read = fread (buf, 1, n_bytes, r->file);
- if (bytes_read == byte_cnt)
+ if (bytes_read == n_bytes)
return 1;
else if (ferror (r->file))
{
return 1;
else if (ferror (r->file))
{
Returns true if successful.
Returns false upon I/O error or if end-of-file is encountered. */
static bool
Returns true if successful.
Returns false upon I/O error or if end-of-file is encountered. */
static bool
-read_bytes (struct pcp_reader *r, void *buf, size_t byte_cnt)
+read_bytes (struct pcp_reader *r, void *buf, size_t n_bytes)
- return read_bytes_internal (r, false, buf, byte_cnt) == 1;
+ return read_bytes_internal (r, false, buf, n_bytes) == 1;
}
/* Reads BYTE_CNT bytes into BUF.
}
/* Reads BYTE_CNT bytes into BUF.
Returns 0 if an immediate end-of-file is encountered.
Returns -1 if an I/O error or a partial read occurs. */
static int
Returns 0 if an immediate end-of-file is encountered.
Returns -1 if an I/O error or a partial read occurs. */
static int
-try_read_bytes (struct pcp_reader *r, void *buf, size_t byte_cnt)
+try_read_bytes (struct pcp_reader *r, void *buf, size_t n_bytes)
- return read_bytes_internal (r, true, buf, byte_cnt);
+ return read_bytes_internal (r, true, buf, n_bytes);
}
/* Reads a 16-bit signed integer from R and stores its value in host format in
}
/* Reads a 16-bit signed integer from R and stores its value in host format in
int line_length; /* Number of characters so far on this line. */
char cc; /* Current character. */
char *trans; /* 256-byte character set translation table. */
int line_length; /* Number of characters so far on this line. */
char cc; /* Current character. */
char *trans; /* 256-byte character set translation table. */
- int var_cnt; /* Number of variables. */
+ int n_vars; /* Number of variables. */
int weight_index; /* 0-based index of weight variable, or -1. */
struct caseproto *proto; /* Format of output cases. */
bool ok; /* Set false on I/O error. */
int weight_index; /* 0-based index of weight variable, or -1. */
struct caseproto *proto; /* Format of output cases. */
bool ok; /* Set false on I/O error. */
r->line_length = 0;
r->weight_index = -1;
r->trans = NULL;
r->line_length = 0;
r->weight_index = -1;
r->trans = NULL;
r->proto = NULL;
r->ok = true;
if (setjmp (r->bail_out))
r->proto = NULL;
r->ok = true;
if (setjmp (r->bail_out))
info->float_format = FLOAT_NATIVE_DOUBLE;
info->integer_format = INTEGER_NATIVE;
info->compression = ANY_COMP_NONE;
info->float_format = FLOAT_NATIVE_DOUBLE;
info->integer_format = INTEGER_NATIVE;
info->compression = ANY_COMP_NONE;
/* Date. */
info->creation_date = xmalloc (11);
/* Date. */
info->creation_date = xmalloc (11);
if (!match (r, '4'))
error (r, _("Expected variable count record."));
if (!match (r, '4'))
error (r, _("Expected variable count record."));
- r->var_cnt = read_int (r);
- if (r->var_cnt <= 0)
- error (r, _("Invalid number of variables %d."), r->var_cnt);
+ r->n_vars = read_int (r);
+ if (r->n_vars <= 0)
+ error (r, _("Invalid number of variables %d."), r->n_vars);
if (match (r, '5'))
read_int (r);
if (match (r, '5'))
read_int (r);
error (r, _("Weight variable name (%s) truncated."), weight_name);
}
error (r, _("Weight variable name (%s) truncated."), weight_name);
}
- for (i = 0; i < r->var_cnt; i++)
+ for (i = 0; i < r->n_vars; i++)
{
int width;
char name[256];
{
int width;
char name[256];
static void
read_documents (struct pfm_reader *r, struct dictionary *dict)
{
static void
read_documents (struct pfm_reader *r, struct dictionary *dict)
{
- int line_cnt;
- int i;
-
- line_cnt = read_int (r);
- for (i = 0; i < line_cnt; i++)
+ int n_lines = read_int (r);
+ for (int i = 0; i < n_lines; i++)
{
char line[256];
read_string (r, line);
{
char line[256];
read_string (r, line);
- for (i = 0; i < r->var_cnt; i++)
+ for (i = 0; i < r->n_vars; i++)
{
int width = caseproto_get_width (r->proto, i);
{
int width = caseproto_get_width (r->proto, i);
{
unsigned char header[464];
char trans[256];
{
unsigned char header[464];
char trans[256];
- int cooked_cnt, raw_cnt, line_len;
+ int n_cooked, n_raws, line_len;
- cooked_cnt = raw_cnt = 0;
- while (cooked_cnt < sizeof header)
+ while (n_cooked < sizeof header)
- if (c == EOF || raw_cnt++ > 512)
+ if (c == EOF || n_raws++ > 512)
return ferror (file) ? -errno : 0;
else if (c == '\n')
{
return ferror (file) ? -errno : 0;
else if (c == '\n')
{
- while (line_len < 80 && cooked_cnt < sizeof header)
+ while (line_len < 80 && n_cooked < sizeof header)
- header[cooked_cnt++] = ' ';
+ header[n_cooked++] = ' ';
line_len++;
}
line_len = 0;
}
else if (c != '\r')
{
line_len++;
}
line_len = 0;
}
else if (c != '\r')
{
- header[cooked_cnt++] = c;
+ header[n_cooked++] = c;
int lc; /* Number of characters on this line so far. */
int lc; /* Number of characters on this line so far. */
- size_t var_cnt; /* Number of variables. */
+ size_t n_vars; /* Number of variables. */
struct pfm_var *vars; /* Variables. */
int digits; /* Digits of precision. */
struct pfm_var *vars; /* Variables. */
int digits; /* Digits of precision. */
w->file = NULL;
w->rf = NULL;
w->lc = 0;
w->file = NULL;
w->rf = NULL;
w->lc = 0;
- w->var_cnt = dict_get_var_cnt (dict);
- w->vars = xnmalloc (w->var_cnt, sizeof *w->vars);
- for (i = 0; i < w->var_cnt; i++)
+ w->n_vars = dict_get_n_vars (dict);
+ w->vars = xnmalloc (w->n_vars, sizeof *w->vars);
+ for (i = 0; i < w->n_vars; i++)
{
const struct variable *dv = dict_get_var (dict, i);
struct pfm_var *pv = &w->vars[i];
{
const struct variable *dv = dict_get_var (dict, i);
struct pfm_var *pv = &w->vars[i];
write_version_data (w);
write_variables (w, dict);
write_value_labels (w, dict);
write_version_data (w);
write_variables (w, dict);
write_value_labels (w, dict);
- if (dict_get_document_line_cnt (dict) > 0)
+ if (dict_get_document_n_lines (dict) > 0)
write_documents (w, dict);
buf_write (w, "F", 1);
if (ferror (w->file))
write_documents (w, dict);
buf_write (w, "F", 1);
if (ferror (w->file))
- write_int (w, dict_get_var_cnt (dict));
+ write_int (w, dict_get_n_vars (dict));
buf_write (w, "5", 1);
write_int (w, ceil (w->digits * (log (10) / log (30))));
buf_write (w, "5", 1);
write_int (w, ceil (w->digits * (log (10) / log (30))));
- for (i = 0; i < dict_get_var_cnt (dict); i++)
+ for (i = 0; i < dict_get_n_vars (dict); i++)
{
struct variable *v = dict_get_var (dict, i);
struct missing_values mv;
{
struct variable *v = dict_get_var (dict, i);
struct missing_values mv;
- for (i = 0; i < dict_get_var_cnt (dict); i++)
+ for (i = 0; i < dict_get_n_vars (dict); i++)
{
struct variable *v = dict_get_var (dict, i);
const struct val_labs *val_labs = var_get_value_labels (v);
{
struct variable *v = dict_get_var (dict, i);
const struct val_labs *val_labs = var_get_value_labels (v);
static void
write_documents (struct pfm_writer *w, const struct dictionary *dict)
{
static void
write_documents (struct pfm_writer *w, const struct dictionary *dict)
{
- size_t line_cnt = dict_get_document_line_cnt (dict);
+ size_t n_lines = dict_get_document_n_lines (dict);
struct string line = DS_EMPTY_INITIALIZER;
int i;
buf_write (w, "E", 1);
struct string line = DS_EMPTY_INITIALIZER;
int i;
buf_write (w, "E", 1);
- write_int (w, line_cnt);
- for (i = 0; i < line_cnt; i++)
+ write_int (w, n_lines);
+ for (i = 0; i < n_lines; i++)
write_string (w, dict_get_document_line (dict, i));
ds_destroy (&line);
}
write_string (w, dict_get_document_line (dict, i));
ds_destroy (&line);
}
- for (i = 0; i < w->var_cnt; i++)
+ for (i = 0; i < w->n_vars; i++)
{
struct pfm_var *v = &w->vars[i];
{
struct pfm_var *v = &w->vars[i];
character after the formatted number. */
static char *
format_trig_digits (char *string,
character after the formatted number. */
static char *
format_trig_digits (char *string,
- const char trigs[], int trig_cnt, int trig_places)
+ const char trigs[], int n_trigs, int trig_places)
*string++ = '0';
trig_places = -1;
}
*string++ = '0';
trig_places = -1;
}
{
if (trig_places-- == 0)
*string++ = '.';
{
if (trig_places-- == 0)
*string++ = '.';
is exactly half, examines TRIGS[-1] and returns true if odd,
false if even ("round to even"). */
static bool
is exactly half, examines TRIGS[-1] and returns true if odd,
false if even ("round to even"). */
static bool
-should_round_up (const char trigs[], int trig_cnt)
+should_round_up (const char trigs[], int n_trigs)
{
/* Approximately half: look more closely. */
int i;
{
/* Approximately half: look more closely. */
int i;
- for (i = 1; i < trig_cnt; i++)
+ for (i = 1; i < n_trigs; i++)
if (trigs[i] > 0)
{
/* Slightly greater than half: round up. */
if (trigs[i] > 0)
{
/* Slightly greater than half: round up. */
successful, false on failure (due to a carry out of the
leftmost position). */
static bool
successful, false on failure (due to a carry out of the
leftmost position). */
static bool
-try_round_up (char *trigs, int trig_cnt)
+try_round_up (char *trigs, int n_trigs)
- char *round_trig = trigs + --trig_cnt;
+ char *round_trig = trigs + --n_trigs;
if (*round_trig != BASE - 1)
{
/* Round this trig up to the next value. */
if (*round_trig != BASE - 1)
{
/* Round this trig up to the next value. */
/* VALUE as a set of trigesimals. */
char buffer[DBL_DIG + 16];
char *trigs;
/* VALUE as a set of trigesimals. */
char buffer[DBL_DIG + 16];
char *trigs;
/* Number of trigesimal places for trigs.
trigs[0] has coefficient 30**(trig_places - 1),
/* Number of trigesimal places for trigs.
trigs[0] has coefficient 30**(trig_places - 1),
/* Dump all the trigs to buffer[], CHUNK_SIZE at a time. */
trigs = buffer;
/* Dump all the trigs to buffer[], CHUNK_SIZE at a time. */
trigs = buffer;
for (trigs_to_output = DIV_RND_UP (DBL_DIG * 2, 3) + 1 + (CHUNK_SIZE / 2);
trigs_to_output > 0;
trigs_to_output -= CHUNK_SIZE)
for (trigs_to_output = DIV_RND_UP (DBL_DIG * 2, 3) + 1 + (CHUNK_SIZE / 2);
trigs_to_output > 0;
trigs_to_output -= CHUNK_SIZE)
/* Append the chunk, in base 30, to trigs[]. */
for (trigs_left = CHUNK_SIZE; chunk > 0 && trigs_left > 0;)
{
/* Append the chunk, in base 30, to trigs[]. */
for (trigs_left = CHUNK_SIZE; chunk > 0 && trigs_left > 0;)
{
- trigs[trig_cnt + --trigs_left] = chunk % 30;
+ trigs[n_trigs + --trigs_left] = chunk % 30;
chunk /= 30;
}
while (trigs_left > 0)
chunk /= 30;
}
while (trigs_left > 0)
- trigs[trig_cnt + --trigs_left] = 0;
- trig_cnt += CHUNK_SIZE;
+ trigs[n_trigs + --trigs_left] = 0;
+ n_trigs += CHUNK_SIZE;
/* Proceed to the next chunk. */
if (value == 0.)
/* Proceed to the next chunk. */
if (value == 0.)
}
/* Strip leading zeros. */
}
/* Strip leading zeros. */
- while (trig_cnt > 1 && *trigs == 0)
+ while (n_trigs > 1 && *trigs == 0)
if (base_10_precision > LDBL_DIG)
base_10_precision = LDBL_DIG;
base_30_precision = DIV_RND_UP (base_10_precision * 2, 3);
if (base_10_precision > LDBL_DIG)
base_10_precision = LDBL_DIG;
base_30_precision = DIV_RND_UP (base_10_precision * 2, 3);
- if (trig_cnt > base_30_precision)
+ if (n_trigs > base_30_precision)
{
if (should_round_up (trigs + base_30_precision,
{
if (should_round_up (trigs + base_30_precision,
- trig_cnt - base_30_precision))
+ n_trigs - base_30_precision))
{
/* Try to round up. */
if (try_round_up (trigs, base_30_precision))
{
/* Rounding up worked. */
{
/* Try to round up. */
if (try_round_up (trigs, base_30_precision))
{
/* Rounding up worked. */
- trig_cnt = base_30_precision;
+ n_trigs = base_30_precision;
}
else
{
/* Couldn't round up because we ran out of trigs to
carry into. Do the carry here instead. */
*trigs = 1;
}
else
{
/* Couldn't round up because we ran out of trigs to
carry into. Do the carry here instead. */
*trigs = 1;
trig_places++;
}
}
else
{
/* Round down. */
trig_places++;
}
}
else
{
/* Round down. */
- trig_cnt = base_30_precision;
+ n_trigs = base_30_precision;
}
/* Strip trailing zeros. */
}
/* Strip trailing zeros. */
- while (trig_cnt > 1 && trigs[trig_cnt - 1] == 0)
- trig_cnt--;
+ while (n_trigs > 1 && trigs[n_trigs - 1] == 0)
+ n_trigs--;
/* Write output. */
if (negative)
*output++ = '-';
/* Write output. */
if (negative)
*output++ = '-';
- if (trig_places >= -1 && trig_places < trig_cnt + 3)
+ if (trig_places >= -1 && trig_places < n_trigs + 3)
{
/* Use conventional notation. */
{
/* Use conventional notation. */
- format_trig_digits (output, trigs, trig_cnt, trig_places);
+ format_trig_digits (output, trigs, n_trigs, trig_places);
}
else
{
/* Use scientific notation. */
char *op;
}
else
{
/* Use scientific notation. */
char *op;
- op = format_trig_digits (output, trigs, trig_cnt, trig_cnt);
- op = format_trig_int (trig_places - trig_cnt, true, op);
+ op = format_trig_digits (output, trigs, n_trigs, n_trigs);
+ op = format_trig_int (trig_places - n_trigs, true, op);
case INTERVALOID:
case TIMESTAMPTZOID:
case TIMETZOID:
case INTERVALOID:
case TIMESTAMPTZOID:
case TIMETZOID:
- if (i < r->vmapsize && var_get_dict_index(v) + 1 < dict_get_var_cnt (r->dict))
+ if (i < r->vmapsize && var_get_dict_index(v) + 1 < dict_get_n_vars (r->dict))
{
const struct variable *v1 = NULL;
v1 = dict_get_var (r->dict, var_get_dict_index (v) + 1);
{
const struct variable *v1 = NULL;
v1 = dict_get_var (r->dict, var_get_dict_index (v) + 1);
void
short_names_assign (struct dictionary *d)
{
void
short_names_assign (struct dictionary *d)
{
- size_t var_cnt = dict_get_var_cnt (d);
+ size_t n_vars = dict_get_n_vars (d);
struct stringi_set short_names;
struct stringi_set short_names;
stringi_set_init (&short_names);
/* Clear short names that conflict with a variable name. */
stringi_set_init (&short_names);
/* Clear short names that conflict with a variable name. */
- for (i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *v = dict_get_var (d, i);
{
struct variable *v = dict_get_var (d, i);
- int segment_cnt = sfm_width_to_segments (var_get_width (v));
- for (j = 0; j < segment_cnt; j++)
+ int n_segments = sfm_width_to_segments (var_get_width (v));
+ for (size_t j = 0; j < n_segments; j++)
{
const char *name = var_get_short_name (v, j);
if (name != NULL)
{
const char *name = var_get_short_name (v, j);
if (name != NULL)
/* Give variables whose names are short the corresponding short
name. */
/* Give variables whose names are short the corresponding short
name. */
- for (i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *v = dict_get_var (d, i);
const char *name = var_get_name (v);
{
struct variable *v = dict_get_var (d, i);
const char *name = var_get_name (v);
conflict, the claimant earlier in dictionary order wins.
Then similarly for additional segments of very long
strings. */
conflict, the claimant earlier in dictionary order wins.
Then similarly for additional segments of very long
strings. */
- for (i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *v = dict_get_var (d, i);
claim_short_name (v, 0, &short_names);
}
{
struct variable *v = dict_get_var (d, i);
claim_short_name (v, 0, &short_names);
}
- for (i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *v = dict_get_var (d, i);
{
struct variable *v = dict_get_var (d, i);
- int segment_cnt = sfm_width_to_segments (var_get_width (v));
- for (j = 1; j < segment_cnt; j++)
+ int n_segments = sfm_width_to_segments (var_get_width (v));
+ for (size_t j = 1; j < n_segments; j++)
claim_short_name (v, j, &short_names);
}
/* Assign short names to first segment of remaining variables,
then similarly for additional segments. */
claim_short_name (v, j, &short_names);
}
/* Assign short names to first segment of remaining variables,
then similarly for additional segments. */
- for (i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *v = dict_get_var (d, i);
assign_short_name (v, 0, &short_names);
}
{
struct variable *v = dict_get_var (d, i);
assign_short_name (v, 0, &short_names);
}
- for (i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *v = dict_get_var (d, i);
{
struct variable *v = dict_get_var (d, i);
- int segment_cnt = sfm_width_to_segments (var_get_width (v));
- for (j = 1; j < segment_cnt; j++)
+ int n_segments = sfm_width_to_segments (var_get_width (v));
+ for (size_t j = 1; j < n_segments; j++)
assign_short_name (v, j, &short_names);
}
assign_short_name (v, j, &short_names);
}
user.
The array is allocated with malloc and stored in *SFM_VARS,
user.
The array is allocated with malloc and stored in *SFM_VARS,
- and its number of elements is stored in *SFM_VAR_CNT. The
+ and its number of elements is stored in *SFM_N_VARS. The
caller is responsible for freeing it when it is no longer
needed. */
int
sfm_dictionary_to_sfm_vars (const struct dictionary *dict,
caller is responsible for freeing it when it is no longer
needed. */
int
sfm_dictionary_to_sfm_vars (const struct dictionary *dict,
- struct sfm_var **sfm_vars, size_t *sfm_var_cnt)
+ struct sfm_var **sfm_vars, size_t *sfm_n_vars)
- size_t var_cnt = dict_get_var_cnt (dict);
- size_t segment_cnt;
+ size_t n_vars = dict_get_n_vars (dict);
+ size_t n_segments;
size_t i;
/* Estimate the number of sfm_vars that will be needed.
We might not need all of these, because very long string
variables can have segments that are all padding, which do
not need sfm_vars of their own. */
size_t i;
/* Estimate the number of sfm_vars that will be needed.
We might not need all of these, because very long string
variables can have segments that are all padding, which do
not need sfm_vars of their own. */
- segment_cnt = 0;
- for (i = 0; i < var_cnt; i++)
+ n_segments = 0;
+ for (i = 0; i < n_vars; i++)
{
const struct variable *v = dict_get_var (dict, i);
{
const struct variable *v = dict_get_var (dict, i);
- segment_cnt += sfm_width_to_segments (var_get_width (v));
+ n_segments += sfm_width_to_segments (var_get_width (v));
}
/* Compose the sfm_vars. */
}
/* Compose the sfm_vars. */
- *sfm_vars = xnmalloc (segment_cnt, sizeof **sfm_vars);
- *sfm_var_cnt = 0;
- for (i = 0; i < var_cnt; i++)
+ *sfm_vars = xnmalloc (n_segments, sizeof **sfm_vars);
+ *sfm_n_vars = 0;
+ for (i = 0; i < n_vars; i++)
{
const struct variable *dv = dict_get_var (dict, i);
int width = var_get_width (dv);
{
const struct variable *dv = dict_get_var (dict, i);
int width = var_get_width (dv);
struct sfm_var *sv;
if (used_bytes != 0)
{
struct sfm_var *sv;
if (used_bytes != 0)
{
- sv = &(*sfm_vars)[(*sfm_var_cnt)++];
+ sv = &(*sfm_vars)[(*sfm_n_vars)++];
sv->var_width = width;
sv->segment_width = width == 0 ? 0 : used_bytes;
sv->case_index = var_get_case_index (dv);
sv->var_width = width;
sv->segment_width = width == 0 ? 0 : used_bytes;
sv->case_index = var_get_case_index (dv);
{
/* Segment is all padding. Just add it to the
previous segment. */
{
/* Segment is all padding. Just add it to the
previous segment. */
- sv = &(*sfm_vars)[*sfm_var_cnt - 1];
+ sv = &(*sfm_vars)[*sfm_n_vars - 1];
sv->padding += padding;
}
assert ((sv->segment_width + sv->padding) % 8 == 0);
}
}
sv->padding += padding;
}
assert ((sv->segment_width + sv->padding) % 8 == 0);
}
}
}
\f
/* Given the name of an encoding, returns the codepage number to use in the
}
\f
/* Given the name of an encoding, returns the codepage number to use in the
enum integer_format integer_format; /* On-disk integer format. */
enum float_format float_format; /* On-disk floating point format. */
struct sfm_var *sfm_vars; /* Variables. */
enum integer_format integer_format; /* On-disk integer format. */
enum float_format float_format; /* On-disk floating point format. */
struct sfm_var *sfm_vars; /* Variables. */
- size_t sfm_var_cnt; /* Number of variables. */
- int case_cnt; /* Number of cases */
+ size_t sfm_n_vars; /* Number of variables. */
+ int n_cases; /* Number of cases */
const char *encoding; /* String encoding. */
bool written_by_readstat; /* From https://github.com/WizardMac/ReadStat? */
const char *encoding; /* String encoding. */
bool written_by_readstat; /* From https://github.com/WizardMac/ReadStat? */
struct sfm_var_record *, size_t n);
static void parse_format_spec (struct sfm_reader *, off_t pos,
unsigned int format, enum which_format,
struct sfm_var_record *, size_t n);
static void parse_format_spec (struct sfm_reader *, off_t pos,
unsigned int format, enum which_format,
- struct variable *, int *format_warning_cnt);
+ struct variable *, int *format_n_warnings);
static void parse_document (struct dictionary *, struct sfm_document_record *);
static void parse_display_parameters (struct sfm_reader *,
const struct sfm_extension_record *,
static void parse_document (struct dictionary *, struct sfm_document_record *);
static void parse_display_parameters (struct sfm_reader *,
const struct sfm_extension_record *,
sfm_read_case to use. We cannot use the `struct variable's
from the dictionary we created, because the caller owns the
dictionary and may destroy or modify its variables. */
sfm_read_case to use. We cannot use the `struct variable's
from the dictionary we created, because the caller owns the
dictionary and may destroy or modify its variables. */
- sfm_dictionary_to_sfm_vars (dict, &r->sfm_vars, &r->sfm_var_cnt);
+ sfm_dictionary_to_sfm_vars (dict, &r->sfm_vars, &r->sfm_n_vars);
pool_register (r->pool, free, r->sfm_vars);
r->proto = caseproto_ref_pool (dict_get_proto (dict), r->pool);
pool_register (r->pool, free, r->sfm_vars);
r->proto = caseproto_ref_pool (dict_get_proto (dict), r->pool);
}
return casereader_create_sequential
}
return casereader_create_sequential
- (NULL, r->proto,
- r->case_cnt == -1 ? CASENUMBER_MAX: r->case_cnt,
- &sys_file_casereader_class, r);
+ (NULL, r->proto, r->n_cases == -1 ? CASENUMBER_MAX : r->n_cases,
+ &sys_file_casereader_class, r);
if (!read_int (r, &header->weight_idx))
return false;
if (!read_int (r, &header->weight_idx))
return false;
- if (!read_int (r, &r->case_cnt))
+ if (!read_int (r, &r->n_cases))
- if (r->case_cnt > INT_MAX / 2)
- r->case_cnt = -1;
+ if (r->n_cases > INT_MAX / 2)
+ r->n_cases = -1;
/* Identify floating-point format and obtain compression bias. */
if (!read_bytes (r, raw_bias, sizeof raw_bias))
/* Identify floating-point format and obtain compression bias. */
if (!read_bytes (r, raw_bias, sizeof raw_bias))
info->integer_format = r->integer_format;
info->float_format = r->float_format;
info->compression = r->compression;
info->integer_format = r->integer_format;
info->float_format = r->float_format;
info->compression = r->compression;
- info->case_cnt = r->case_cnt;
+ info->n_cases = r->n_cases;
- n_vars = dict_get_var_cnt (dict);
+ n_vars = dict_get_n_vars (dict);
if (record->count == 3 * n_vars)
includes_width = true;
else if (record->count == 2 * n_vars)
if (record->count == 3 * n_vars)
includes_width = true;
else if (record->count == 2 * n_vars)
/* Renaming a variable may clear its short names, but we
want to retain them, so we save them and re-set them
afterward. */
/* Renaming a variable may clear its short names, but we
want to retain them, so we save them and re-set them
afterward. */
- n_short_names = var_get_short_name_cnt (var);
+ n_short_names = var_get_n_short_names (var);
short_names = xnmalloc (n_short_names, sizeof *short_names);
for (i = 0; i < n_short_names; i++)
{
short_names = xnmalloc (n_short_names, sizeof *short_names);
for (i = 0; i < n_short_names; i++)
{
converted to lowercase, as the long variable names. */
size_t i;
converted to lowercase, as the long variable names. */
size_t i;
- for (i = 0; i < dict_get_var_cnt (dict); i++)
+ for (i = 0; i < dict_get_n_vars (dict); i++)
{
struct variable *var = dict_get_var (dict, i);
char *new_name;
{
struct variable *var = dict_get_var (dict, i);
char *new_name;
{
size_t idx = var_get_dict_index (var);
long int length;
{
size_t idx = var_get_dict_index (var);
long int length;
- segment_cnt = sfm_width_to_segments (length);
- if (segment_cnt == 1)
+ int n_segments = sfm_width_to_segments (length);
+ if (n_segments == 1)
{
sys_warn (r, record->pos,
_("%s listed in very long string record with width %s, "
{
sys_warn (r, record->pos,
_("%s listed in very long string record with width %s, "
var_get_name (var), length_s);
continue;
}
var_get_name (var), length_s);
continue;
}
- if (idx + segment_cnt > dict_get_var_cnt (dict))
+ if (idx + n_segments > dict_get_n_vars (dict))
{
sys_error (r, record->pos,
_("Very long string %s overflows dictionary."),
{
sys_error (r, record->pos,
_("Very long string %s overflows dictionary."),
/* Get the short names from the segments and check their
lengths. */
/* Get the short names from the segments and check their
lengths. */
- for (i = 0; i < segment_cnt; i++)
+ for (i = 0; i < n_segments; i++)
{
struct variable *seg = dict_get_var (dict, idx + i);
int alloc_width = sfm_segment_alloc_width (length, i);
{
struct variable *seg = dict_get_var (dict, idx + i);
int alloc_width = sfm_segment_alloc_width (length, i);
- dict_delete_consecutive_vars (dict, idx + 1, segment_cnt - 1);
+ dict_delete_consecutive_vars (dict, idx + 1, n_segments - 1);
var_set_width (var, length);
}
close_text_record (r, text);
var_set_width (var, length);
}
close_text_record (r, text);
size_t n_warnings = 0;
size_t i;
size_t n_warnings = 0;
size_t i;
- for (i = 0; i < dict_get_var_cnt (dict); i++)
+ for (i = 0; i < dict_get_n_vars (dict); i++)
{
struct variable *var = dict_get_var (dict, i);
struct attrset *attrs = var_get_attributes (var);
{
struct variable *var = dict_get_var (dict, i);
struct attrset *attrs = var_get_attributes (var);
- if (r->error || !r->sfm_var_cnt)
+ if (r->error || !r->sfm_n_vars)
return NULL;
c = case_create (r->proto);
return NULL;
c = case_create (r->proto);
- for (i = 0; i < r->sfm_var_cnt; i++)
+ for (i = 0; i < r->sfm_n_vars; i++)
{
struct sfm_var *sv = &r->sfm_vars[i];
union value *v = case_data_rw_idx (c, sv->case_index);
{
struct sfm_var *sv = &r->sfm_vars[i];
union value *v = case_data_rw_idx (c, sv->case_index);
eof:
if (i != 0)
partial_record (r);
eof:
if (i != 0)
partial_record (r);
read_error (reader, r);
case_unref (c);
return NULL;
read_error (reader, r);
case_unref (c);
return NULL;
an error. */
static inline int
read_bytes_internal (struct sfm_reader *r, bool eof_is_ok,
an error. */
static inline int
read_bytes_internal (struct sfm_reader *r, bool eof_is_ok,
- void *buf, size_t byte_cnt)
+ void *buf, size_t n_bytes)
- size_t bytes_read = fread (buf, 1, byte_cnt, r->file);
+ size_t bytes_read = fread (buf, 1, n_bytes, r->file);
- if (bytes_read == byte_cnt)
+ if (bytes_read == n_bytes)
return 1;
else if (ferror (r->file))
{
return 1;
else if (ferror (r->file))
{
Returns true if successful.
Returns false upon I/O error or if end-of-file is encountered. */
static bool
Returns true if successful.
Returns false upon I/O error or if end-of-file is encountered. */
static bool
-read_bytes (struct sfm_reader *r, void *buf, size_t byte_cnt)
+read_bytes (struct sfm_reader *r, void *buf, size_t n_bytes)
- return read_bytes_internal (r, false, buf, byte_cnt) == 1;
+ return read_bytes_internal (r, false, buf, n_bytes) == 1;
}
/* Reads BYTE_CNT bytes into BUF.
}
/* Reads BYTE_CNT bytes into BUF.
Returns 0 if an immediate end-of-file is encountered.
Returns -1 if an I/O error or a partial read occurs. */
static int
Returns 0 if an immediate end-of-file is encountered.
Returns -1 if an I/O error or a partial read occurs. */
static int
-try_read_bytes (struct sfm_reader *r, void *buf, size_t byte_cnt)
+try_read_bytes (struct sfm_reader *r, void *buf, size_t n_bytes)
- return read_bytes_internal (r, true, buf, byte_cnt);
+ return read_bytes_internal (r, true, buf, n_bytes);
}
/* Reads a 32-bit signed integer from R and stores its value in host format in
}
/* Reads a 32-bit signed integer from R and stores its value in host format in
-read_bytes_zlib (struct sfm_reader *r, void *buf_, size_t byte_cnt)
+read_bytes_zlib (struct sfm_reader *r, void *buf_, size_t n_bytes)
/* Use already inflated data if there is any. */
if (r->zout_pos < r->zout_end)
{
/* Use already inflated data if there is any. */
if (r->zout_pos < r->zout_end)
{
- unsigned int n = MIN (byte_cnt, r->zout_end - r->zout_pos);
+ unsigned int n = MIN (n_bytes, r->zout_end - r->zout_pos);
memcpy (buf, &r->zout_buf[r->zout_pos], n);
r->zout_pos += n;
memcpy (buf, &r->zout_buf[r->zout_pos], n);
r->zout_pos += n;
-read_compressed_bytes (struct sfm_reader *r, void *buf, size_t byte_cnt)
+read_compressed_bytes (struct sfm_reader *r, void *buf, size_t n_bytes)
{
if (r->compression == ANY_COMP_SIMPLE)
{
if (r->compression == ANY_COMP_SIMPLE)
- return read_bytes (r, buf, byte_cnt);
+ return read_bytes (r, buf, n_bytes);
- int retval = read_bytes_zlib (r, buf, byte_cnt);
+ int retval = read_bytes_zlib (r, buf, n_bytes);
if (retval == 0)
sys_error (r, r->pos, _("Unexpected end of ZLIB compressed data."));
return retval;
if (retval == 0)
sys_error (r, r->pos, _("Unexpected end of ZLIB compressed data."));
return retval;
-try_read_compressed_bytes (struct sfm_reader *r, void *buf, size_t byte_cnt)
+try_read_compressed_bytes (struct sfm_reader *r, void *buf, size_t n_bytes)
{
if (r->compression == ANY_COMP_SIMPLE)
{
if (r->compression == ANY_COMP_SIMPLE)
- return try_read_bytes (r, buf, byte_cnt);
+ return try_read_bytes (r, buf, n_bytes);
- return read_bytes_zlib (r, buf, byte_cnt);
+ return read_bytes_zlib (r, buf, n_bytes);
}
/* Reads a 64-bit floating-point number from R and returns its
}
/* Reads a 64-bit floating-point number from R and returns its
struct replace_file *rf; /* Ticket for replacing output file. */
enum any_compression compression;
struct replace_file *rf; /* Ticket for replacing output file. */
enum any_compression compression;
- casenumber case_cnt; /* Number of cases written so far. */
+ casenumber n_cases; /* Number of cases written so far. */
uint8_t space; /* ' ' in the file's character encoding. */
/* Simple compression buffering.
uint8_t space; /* ' ' in the file's character encoding. */
/* Simple compression buffering.
/* Variables. */
struct sfm_var *sfm_vars; /* Variables. */
/* Variables. */
struct sfm_var *sfm_vars; /* Variables. */
- size_t sfm_var_cnt; /* Number of variables. */
- size_t segment_cnt; /* Number of variables including extra segments
+ size_t sfm_n_vars; /* Number of variables. */
+ size_t n_segments; /* Number of variables including extra segments
for long string variables. */
};
for long string variables. */
};
&& is_encoding_ebcdic_compatible (dict_get_encoding (d)))
w->compression = ANY_COMP_SIMPLE;
&& is_encoding_ebcdic_compatible (dict_get_encoding (d)))
w->compression = ANY_COMP_SIMPLE;
w->n_opcodes = w->n_elements = 0;
memset (w->cbuf[0], 0, 8);
w->n_opcodes = w->n_elements = 0;
memset (w->cbuf[0], 0, 8);
data. Also count the number of segments. Very long strings
occupy multiple segments, otherwise each variable only takes
one segment. */
data. Also count the number of segments. Very long strings
occupy multiple segments, otherwise each variable only takes
one segment. */
- w->segment_cnt = sfm_dictionary_to_sfm_vars (d, &w->sfm_vars,
- &w->sfm_var_cnt);
+ w->n_segments = sfm_dictionary_to_sfm_vars (d, &w->sfm_vars, &w->sfm_n_vars);
/* Open file handle as an exclusive writer. */
/* TRANSLATORS: this fragment will be interpolated into
/* Open file handle as an exclusive writer. */
/* TRANSLATORS: this fragment will be interpolated into
/* Write basic variable info. */
short_names_assign (d);
/* Write basic variable info. */
short_names_assign (d);
- for (i = 0; i < dict_get_var_cnt (d); i++)
+ for (i = 0; i < dict_get_n_vars (d); i++)
write_variable (w, dict_get_var (d, i));
write_value_labels (w, d);
write_variable (w, dict_get_var (d, i));
write_value_labels (w, d);
- if (dict_get_document_line_cnt (d) > 0)
+ if (dict_get_document_n_lines (d) > 0)
write_documents (w, d);
write_integer_info_record (w, d);
write_documents (w, d);
write_integer_info_record (w, d);
- for (i = 0; i < dict_get_var_cnt (d); i++)
+ for (i = 0; i < dict_get_n_vars (d); i++)
{
struct variable *var = dict_get_var (d, i);
if (var == target_var)
{
struct variable *var = dict_get_var (d, i);
if (var == target_var)
write_variable (struct sfm_writer *w, const struct variable *v)
{
int width = var_get_width (v);
write_variable (struct sfm_writer *w, const struct variable *v)
{
int width = var_get_width (v);
- int segment_cnt = sfm_width_to_segments (width);
+ int n_segments = sfm_width_to_segments (width);
int seg0_width = sfm_segment_alloc_width (width, 0);
const char *encoding = var_get_encoding (v);
int i;
int seg0_width = sfm_segment_alloc_width (width, 0);
const char *encoding = var_get_encoding (v);
int i;
write_variable_continuation_records (w, seg0_width);
/* Write additional segments for very long string variables. */
write_variable_continuation_records (w, seg0_width);
/* Write additional segments for very long string variables. */
- for (i = 1; i < segment_cnt; i++)
+ for (i = 1; i < n_segments; i++)
{
int seg_width = sfm_segment_alloc_width (width, i);
struct fmt_spec fmt = fmt_for_output (FMT_A, MAX (seg_width, 1), 0);
{
int seg_width = sfm_segment_alloc_width (width, i);
struct fmt_spec fmt = fmt_for_output (FMT_A, MAX (seg_width, 1), 0);
hmap_init (&same_sets);
idx = 0;
hmap_init (&same_sets);
idx = 0;
- for (i = 0; i < dict_get_var_cnt (d); i++)
+ for (i = 0; i < dict_get_n_vars (d); i++)
{
struct variable *v = dict_get_var (d, i);
{
struct variable *v = dict_get_var (d, i);
write_variable_attributes (struct sfm_writer *w, const struct dictionary *d)
{
struct string s = DS_EMPTY_INITIALIZER;
write_variable_attributes (struct sfm_writer *w, const struct dictionary *d)
{
struct string s = DS_EMPTY_INITIALIZER;
- size_t n_vars = dict_get_var_cnt (d);
+ size_t n_vars = dict_get_n_vars (d);
size_t n_attrsets = 0;
size_t i;
size_t n_attrsets = 0;
size_t i;
write_int (w, 7); /* Record type. */
write_int (w, 11); /* Record subtype. */
write_int (w, 4); /* Data item (int32) size. */
write_int (w, 7); /* Record type. */
write_int (w, 11); /* Record subtype. */
write_int (w, 4); /* Data item (int32) size. */
- write_int (w, w->segment_cnt * 3); /* Number of data items. */
+ write_int (w, w->n_segments * 3); /* Number of data items. */
- for (i = 0; i < dict_get_var_cnt (dict); ++i)
+ for (i = 0; i < dict_get_n_vars (dict); ++i)
{
struct variable *v = dict_get_var (dict, i);
int width = var_get_width (v);
{
struct variable *v = dict_get_var (dict, i);
int width = var_get_width (v);
- int segment_cnt = sfm_width_to_segments (width);
+ int n_segments = sfm_width_to_segments (width);
int measure = (var_get_measure (v) == MEASURE_NOMINAL ? 1
: var_get_measure (v) == MEASURE_ORDINAL ? 2
: 3);
int measure = (var_get_measure (v) == MEASURE_NOMINAL ? 1
: var_get_measure (v) == MEASURE_ORDINAL ? 2
: 3);
- for (i = 0; i < segment_cnt; i++)
+ for (i = 0; i < n_segments; i++)
{
int width_left = width - sfm_segment_effective_offset (width, i);
write_int (w, measure);
{
int width_left = width - sfm_segment_effective_offset (width, i);
write_int (w, measure);
int i;
ds_init_empty (&map);
int i;
ds_init_empty (&map);
- for (i = 0; i < dict_get_var_cnt (dict); ++i)
+ for (i = 0; i < dict_get_n_vars (dict); ++i)
{
const struct variable *v = dict_get_var (dict, i);
if (sfm_width_to_segments (var_get_width (v)) > 1)
{
const struct variable *v = dict_get_var (dict, i);
if (sfm_width_to_segments (var_get_width (v)) > 1)
const struct dictionary *dict)
{
const char *encoding = dict_get_encoding (dict);
const struct dictionary *dict)
{
const char *encoding = dict_get_encoding (dict);
- size_t n_vars = dict_get_var_cnt (dict);
+ size_t n_vars = dict_get_n_vars (dict);
size_t size, i;
/* Figure out the size in advance. */
size_t size, i;
/* Figure out the size in advance. */
const struct dictionary *dict)
{
const char *encoding = dict_get_encoding (dict);
const struct dictionary *dict)
{
const char *encoding = dict_get_encoding (dict);
- size_t n_vars = dict_get_var_cnt (dict);
+ size_t n_vars = dict_get_n_vars (dict);
size_t size, i;
/* Figure out the size in advance. */
size_t size, i;
/* Figure out the size in advance. */
size_t i;
ds_init_empty (&map);
size_t i;
ds_init_empty (&map);
- for (i = 0; i < dict_get_var_cnt (dict); i++)
+ for (i = 0; i < dict_get_n_vars (dict); i++)
{
struct variable *v = dict_get_var (dict, i);
if (i)
{
struct variable *v = dict_get_var (dict, i);
if (i)
if (w->compression == ANY_COMP_NONE)
write_case_uncompressed (w, c);
if (w->compression == ANY_COMP_NONE)
write_case_uncompressed (w, c);
/* Seek back to the beginning and update the number of cases.
This is just a courtesy to later readers, so there's no need
to check return values or report errors. */
/* Seek back to the beginning and update the number of cases.
This is just a courtesy to later readers, so there's no need
to check return values or report errors. */
- if (ok && w->case_cnt <= INT32_MAX && !fseeko (w->file, 80, SEEK_SET))
+ if (ok && w->n_cases <= INT32_MAX && !fseeko (w->file, 80, SEEK_SET))
- write_int (w, w->case_cnt);
+ write_int (w, w->n_cases);
- for (i = 0; i < w->sfm_var_cnt; i++)
+ for (i = 0; i < w->sfm_n_vars; i++)
{
struct sfm_var *v = &w->sfm_vars[i];
{
struct sfm_var *v = &w->sfm_vars[i];
- for (i = 0; i < w->sfm_var_cnt; i++)
+ for (i = 0; i < w->sfm_n_vars; i++)
{
struct sfm_var *v = &w->sfm_vars[i];
{
struct sfm_var *v = &w->sfm_vars[i];
struct trns_chain
{
struct transformation *trns; /* Array of transformations. */
struct trns_chain
{
struct transformation *trns; /* Array of transformations. */
- size_t trns_cnt; /* Number of transformations. */
- size_t trns_cap; /* Allocated capacity. */
+ size_t n_trns; /* Number of transformations. */
+ size_t allocated_trns; /* Allocated capacity. */
bool finalized; /* Finalize functions called? */
};
bool finalized; /* Finalize functions called? */
};
{
struct trns_chain *chain = xmalloc (sizeof *chain);
chain->trns = NULL;
{
struct trns_chain *chain = xmalloc (sizeof *chain);
chain->trns = NULL;
- chain->trns_cnt = 0;
- chain->trns_cap = 0;
+ chain->n_trns = 0;
+ chain->allocated_trns = 0;
chain->finalized = false;
return chain;
}
chain->finalized = false;
return chain;
}
size_t i;
chain->finalized = true;
size_t i;
chain->finalized = true;
- for (i = 0; i < chain->trns_cnt; i++)
+ for (i = 0; i < chain->n_trns; i++)
{
struct transformation *trns = &chain->trns[i];
trns_finalize_func *finalize = trns->finalize;
{
struct transformation *trns = &chain->trns[i];
trns_finalize_func *finalize = trns->finalize;
/* Needed to ensure that the control stack gets cleared. */
trns_chain_finalize (chain);
/* Needed to ensure that the control stack gets cleared. */
trns_chain_finalize (chain);
- for (i = 0; i < chain->trns_cnt; i++)
+ for (i = 0; i < chain->n_trns; i++)
{
struct transformation *trns = &chain->trns[i];
if (trns->free != NULL)
{
struct transformation *trns = &chain->trns[i];
if (trns->free != NULL)
bool
trns_chain_is_empty (const struct trns_chain *chain)
{
bool
trns_chain_is_empty (const struct trns_chain *chain)
{
- return chain->trns_cnt == 0;
+ return chain->n_trns == 0;
}
/* Adds a transformation to CHAIN with finalize function
}
/* Adds a transformation to CHAIN with finalize function
chain->finalized = false;
chain->finalized = false;
- if (chain->trns_cnt == chain->trns_cap)
- chain->trns = x2nrealloc (chain->trns, &chain->trns_cap,
+ if (chain->n_trns == chain->allocated_trns)
+ chain->trns = x2nrealloc (chain->trns, &chain->allocated_trns,
- trns = &chain->trns[chain->trns_cnt++];
+ trns = &chain->trns[chain->n_trns++];
trns->idx_ofs = 0;
trns->finalize = finalize;
trns->execute = execute;
trns->idx_ofs = 0;
trns->finalize = finalize;
trns->execute = execute;
assert (dst->finalized);
assert (src->finalized);
assert (dst->finalized);
assert (src->finalized);
- if (dst->trns_cnt + src->trns_cnt > dst->trns_cap)
+ if (dst->n_trns + src->n_trns > dst->allocated_trns)
- dst->trns_cap = dst->trns_cnt + src->trns_cnt;
- dst->trns = xnrealloc (dst->trns, dst->trns_cap, sizeof *dst->trns);
+ dst->allocated_trns = dst->n_trns + src->n_trns;
+ dst->trns = xnrealloc (dst->trns, dst->allocated_trns, sizeof *dst->trns);
- for (i = 0; i < src->trns_cnt; i++)
+ for (i = 0; i < src->n_trns; i++)
- struct transformation *d = &dst->trns[i + dst->trns_cnt];
+ struct transformation *d = &dst->trns[i + dst->n_trns];
const struct transformation *s = &src->trns[i];
*d = *s;
const struct transformation *s = &src->trns[i];
*d = *s;
- d->idx_ofs += src->trns_cnt;
+ d->idx_ofs += src->n_trns;
- dst->trns_cnt += src->trns_cnt;
+ dst->n_trns += src->n_trns;
trns_chain_destroy (src);
}
trns_chain_destroy (src);
}
size_t
trns_chain_next (struct trns_chain *chain)
{
size_t
trns_chain_next (struct trns_chain *chain)
{
- return chain->trns_cnt;
}
/* Executes the given CHAIN of transformations on *C,
}
/* Executes the given CHAIN of transformations on *C,
size_t i;
assert (chain->finalized);
size_t i;
assert (chain->finalized);
- for (i = start < 0 ? 0 : start; i < chain->trns_cnt;)
+ for (i = start < 0 ? 0 : start; i < chain->n_trns;)
{
struct transformation *trns = &chain->trns[i];
int retval = trns->execute (trns->aux, c, case_nr);
{
struct transformation *trns = &chain->trns[i];
int retval = trns->execute (trns->aux, c, case_nr);
/* Used only for system and portable file input and output.
See short-names.h. */
char **short_names;
/* Used only for system and portable file input and output.
See short-names.h. */
char **short_names;
/* Custom attributes. */
struct attrset attributes;
/* Custom attributes. */
struct attrset attributes;
all if it hasn't been saved to or read from a system or
portable file. */
size_t
all if it hasn't been saved to or read from a system or
portable file. */
size_t
-var_get_short_name_cnt (const struct variable *var)
+var_get_n_short_names (const struct variable *var)
- return var->short_name_cnt;
+ return var->n_short_names;
}
/* Returns VAR's short name with the given IDX, if it has one
}
/* Returns VAR's short name with the given IDX, if it has one
const char *
var_get_short_name (const struct variable *var, size_t idx)
{
const char *
var_get_short_name (const struct variable *var, size_t idx)
{
- return idx < var->short_name_cnt ? var->short_names[idx] : NULL;
+ return idx < var->n_short_names ? var->short_names[idx] : NULL;
}
/* Sets VAR's short name with the given IDX to the UTF-8 string SHORT_NAME.
}
/* Sets VAR's short name with the given IDX to the UTF-8 string SHORT_NAME.
struct variable *ov = var_clone (var);
/* Clear old short name numbered IDX, if any. */
struct variable *ov = var_clone (var);
/* Clear old short name numbered IDX, if any. */
- if (idx < var->short_name_cnt)
+ if (idx < var->n_short_names)
{
free (var->short_names[idx]);
var->short_names[idx] = NULL;
{
free (var->short_names[idx]);
var->short_names[idx] = NULL;
/* Install new short name for IDX. */
if (short_name != NULL)
{
/* Install new short name for IDX. */
if (short_name != NULL)
{
- if (idx >= var->short_name_cnt)
+ if (idx >= var->n_short_names)
- size_t old_cnt = var->short_name_cnt;
+ size_t n_old = var->n_short_names;
- var->short_name_cnt = MAX (idx * 2, 1);
- var->short_names = xnrealloc (var->short_names, var->short_name_cnt,
+ var->n_short_names = MAX (idx * 2, 1);
+ var->short_names = xnrealloc (var->short_names, var->n_short_names,
sizeof *var->short_names);
sizeof *var->short_names);
- for (i = old_cnt; i < var->short_name_cnt; i++)
+ for (i = n_old; i < var->n_short_names; i++)
var->short_names[i] = NULL;
}
var->short_names[idx] = utf8_to_upper (short_name);
var->short_names[i] = NULL;
}
var->short_names[idx] = utf8_to_upper (short_name);
- for (i = 0; i < v->short_name_cnt; i++)
+ for (i = 0; i < v->n_short_names; i++)
free (v->short_names[i]);
free (v->short_names);
v->short_names = NULL;
free (v->short_names[i]);
free (v->short_names);
v->short_names = NULL;
}
\f
/* Relationship with dictionary. */
}
\f
/* Relationship with dictionary. */
bool var_must_leave (const struct variable *);
/* Short names. */
bool var_must_leave (const struct variable *);
/* Short names. */
-size_t var_get_short_name_cnt (const struct variable *);
+size_t var_get_n_short_names (const struct variable *);
const char *var_get_short_name (const struct variable *, size_t idx);
void var_set_short_name (struct variable *, size_t, const char *);
void var_clear_short_names (struct variable *);
const char *var_get_short_name (const struct variable *, size_t idx);
void var_set_short_name (struct variable *, size_t, const char *);
void var_clear_short_names (struct variable *);
{
char *name; /* Name. */
struct variable **vars; /* Set of variables. */
{
char *name; /* Name. */
struct variable **vars; /* Set of variables. */
- size_t var_cnt; /* Number of variables. */
+ size_t n_vars; /* Number of variables. */
};
/* Checks that all the variables in VECTOR have consistent
};
/* Checks that all the variables in VECTOR have consistent
int width = var_get_width (vector->vars[0]);
size_t i;
int width = var_get_width (vector->vars[0]);
size_t i;
- for (i = 1; i < vector->var_cnt; i++)
+ for (i = 1; i < vector->n_vars; i++)
assert (width == var_get_width (vector->vars[i]));
}
/* Creates and returns a new vector with the given UTF-8 encoded NAME
assert (width == var_get_width (vector->vars[i]));
}
/* Creates and returns a new vector with the given UTF-8 encoded NAME
- that contains the VAR_CNT variables in VARS.
+ that contains the N_VARS variables in VARS.
All variables in VARS must have the same type and width. */
struct vector *
All variables in VARS must have the same type and width. */
struct vector *
-vector_create (const char *name, struct variable **vars, size_t var_cnt)
+vector_create (const char *name, struct variable **vars, size_t n_vars)
{
struct vector *vector = xmalloc (sizeof *vector);
{
struct vector *vector = xmalloc (sizeof *vector);
assert (id_is_plausible (name, false));
vector->name = xstrdup (name);
assert (id_is_plausible (name, false));
vector->name = xstrdup (name);
- vector->vars = xmemdup (vars, var_cnt * sizeof *vector->vars);
- vector->var_cnt = var_cnt;
+ vector->vars = xmemdup (vars, n_vars * sizeof *vector->vars);
+ vector->n_vars = n_vars;
check_widths (vector);
return vector;
check_widths (vector);
return vector;
size_t i;
new->name = xstrdup (old->name);
size_t i;
new->name = xstrdup (old->name);
- new->vars = xnmalloc (old->var_cnt, sizeof *new->vars);
- new->var_cnt = old->var_cnt;
- for (i = 0; i < new->var_cnt; i++)
+ new->vars = xnmalloc (old->n_vars, sizeof *new->vars);
+ new->n_vars = old->n_vars;
+ for (i = 0; i < new->n_vars; i++)
{
assert (dict_contains_var (old_dict, old->vars[i]));
new->vars[i] = dict_get_var (new_dict,
{
assert (dict_contains_var (old_dict, old->vars[i]));
new->vars[i] = dict_get_var (new_dict,
struct variable *
vector_get_var (const struct vector *vector, size_t index)
{
struct variable *
vector_get_var (const struct vector *vector, size_t index)
{
- assert (index < vector->var_cnt);
+ assert (index < vector->n_vars);
return vector->vars[index];
}
/* Returns the number of variables in VECTOR. */
size_t
return vector->vars[index];
}
/* Returns the number of variables in VECTOR. */
size_t
-vector_get_var_cnt (const struct vector *vector)
+vector_get_n_vars (const struct vector *vector)
- return vector->var_cnt;
}
/* Compares two pointers to vectors represented by A and B and
}
/* Compares two pointers to vectors represented by A and B and
struct dictionary;
struct vector *vector_create (const char *name,
struct dictionary;
struct vector *vector_create (const char *name,
- struct variable **var, size_t var_cnt);
+ struct variable **var, size_t n_vars);
struct vector *vector_clone (const struct vector *old,
const struct dictionary *old_dict,
const struct dictionary *new_dict);
struct vector *vector_clone (const struct vector *old,
const struct dictionary *old_dict,
const struct dictionary *new_dict);
const char *vector_get_name (const struct vector *);
enum val_type vector_get_type (const struct vector *);
struct variable *vector_get_var (const struct vector *, size_t idx);
const char *vector_get_name (const struct vector *);
enum val_type vector_get_type (const struct vector *);
struct variable *vector_get_var (const struct vector *, size_t idx);
-size_t vector_get_var_cnt (const struct vector *);
+size_t vector_get_n_vars (const struct vector *);
bool vector_is_valid_name (const char *name, bool issue_error);
bool vector_is_valid_name (const char *name, bool issue_error);
#undef DEF_CMD
#undef UNIMPL_CMD
#undef DEF_CMD
#undef UNIMPL_CMD
-static const size_t command_cnt = sizeof commands / sizeof *commands;
+static const size_t n_commands = sizeof commands / sizeof *commands;
static bool in_correct_state (const struct command *, enum cmd_state);
static bool report_state_mismatch (const struct command *, enum cmd_state);
static bool in_correct_state (const struct command *, enum cmd_state);
static bool report_state_mismatch (const struct command *, enum cmd_state);
const struct dictionary *dict = dataset_dict (ds);
return cmd_parse_in_state (lexer, ds,
dataset_has_source (ds) &&
const struct dictionary *dict = dataset_dict (ds);
return cmd_parse_in_state (lexer, ds,
dataset_has_source (ds) &&
- dict_get_var_cnt (dict) > 0 ?
+ dict_get_n_vars (dict) > 0 ?
CMD_STATE_DATA : CMD_STATE_INITIAL);
}
CMD_STATE_DATA : CMD_STATE_INITIAL);
}
int missing_words;
command_matcher_init (&cm, s);
int missing_words;
command_matcher_init (&cm, s);
- for (cmd = commands; cmd < &commands[command_cnt]; cmd++)
+ for (cmd = commands; cmd < &commands[n_commands]; cmd++)
command_matcher_add (&cm, ss_cstr (cmd->name), CONST_CAST (void *, cmd));
*matchp = command_matcher_get_match (&cm);
command_matcher_add (&cm, ss_cstr (cmd->name), CONST_CAST (void *, cmd));
*matchp = command_matcher_get_match (&cm);
if (*cmd == NULL)
*cmd = commands;
if (*cmd == NULL)
*cmd = commands;
- for (; *cmd < commands + command_cnt; (*cmd)++)
+ for (; *cmd < commands + n_commands; (*cmd)++)
if (!memcasecmp ((*cmd)->name, prefix, strlen (prefix))
&& (!((*cmd)->flags & F_TESTING) || settings_get_testing_mode ())
&& (!((*cmd)->flags & F_ENHANCED) || settings_get_syntax () == ENHANCED)
if (!memcasecmp ((*cmd)->name, prefix, strlen (prefix))
&& (!((*cmd)->flags & F_TESTING) || settings_get_testing_mode ())
&& (!((*cmd)->flags & F_ENHANCED) || settings_get_syntax () == ENHANCED)
{
struct dataset *ds; /* The dataset */
struct clause *clauses; /* Clauses. */
{
struct dataset *ds; /* The dataset */
struct clause *clauses; /* Clauses. */
- size_t clause_cnt; /* Number of clauses. */
+ size_t n_clauses; /* Number of clauses. */
int past_END_IF_index; /* Transformation just past last clause. */
};
int past_END_IF_index; /* Transformation just past last clause. */
};
{
struct do_if_trns *do_if = xmalloc (sizeof *do_if);
do_if->clauses = NULL;
{
struct do_if_trns *do_if = xmalloc (sizeof *do_if);
do_if->clauses = NULL;
do_if->ds = ds;
ctl_stack_push (&do_if_class, do_if);
do_if->ds = ds;
ctl_stack_push (&do_if_class, do_if);
static bool
has_else (struct do_if_trns *do_if)
{
static bool
has_else (struct do_if_trns *do_if)
{
- return (do_if->clause_cnt != 0
- && do_if->clauses[do_if->clause_cnt - 1].condition == NULL);
+ return (do_if->n_clauses != 0
+ && do_if->clauses[do_if->n_clauses - 1].condition == NULL);
}
/* Parses a DO IF or ELSE IF expression and appends the
}
/* Parses a DO IF or ELSE IF expression and appends the
- if (do_if->clause_cnt > 0)
+ if (do_if->n_clauses > 0)
add_transformation (do_if->ds, break_trns_proc, NULL, do_if);
do_if->clauses = xnrealloc (do_if->clauses,
add_transformation (do_if->ds, break_trns_proc, NULL, do_if);
do_if->clauses = xnrealloc (do_if->clauses,
- do_if->clause_cnt + 1, sizeof *do_if->clauses);
- clause = &do_if->clauses[do_if->clause_cnt++];
+ do_if->n_clauses + 1, sizeof *do_if->clauses);
+ clause = &do_if->clauses[do_if->n_clauses++];
clause->condition = condition;
clause->target_index = next_transformation (do_if->ds);
}
clause->condition = condition;
clause->target_index = next_transformation (do_if->ds);
}
struct do_if_trns *do_if = do_if_;
struct clause *clause;
struct do_if_trns *do_if = do_if_;
struct clause *clause;
- for (clause = do_if->clauses; clause < do_if->clauses + do_if->clause_cnt;
+ for (clause = do_if->clauses; clause < do_if->clauses + do_if->n_clauses;
clause++)
{
if (clause->condition != NULL)
clause++)
{
if (clause->condition != NULL)
struct do_if_trns *do_if = do_if_;
struct clause *clause;
struct do_if_trns *do_if = do_if_;
struct clause *clause;
- for (clause = do_if->clauses; clause < do_if->clauses + do_if->clause_cnt;
+ for (clause = do_if->clauses; clause < do_if->clauses + do_if->n_clauses;
clause++)
expr_free (clause->condition);
free (do_if->clauses);
clause++)
expr_free (clause->condition);
free (do_if->clauses);
for (i = 0; i < proc.n_files; i++)
{
struct comb_file *file = &proc.files[i];
for (i = 0; i < proc.n_files; i++)
{
struct comb_file *file = &proc.files[i];
- size_t src_var_cnt = dict_get_var_cnt (file->dict);
+ size_t src_n_vars = dict_get_n_vars (file->dict);
- file->mv = xnmalloc (src_var_cnt, sizeof *file->mv);
- for (j = 0; j < src_var_cnt; j++)
+ file->mv = xnmalloc (src_n_vars, sizeof *file->mv);
+ for (j = 0; j < src_n_vars; j++)
{
struct variable *src_var = dict_get_var (file->dict, j);
struct variable *dst_var = dict_lookup_var (proc.dict,
{
struct variable *src_var = dict_get_var (file->dict, j);
struct variable *dst_var = dict_lookup_var (proc.dict,
- for (i = 0; i < dict_get_var_cnt (d); i++)
+ for (i = 0; i < dict_get_n_vars (d); i++)
{
struct variable *dv = dict_get_var (d, i);
struct variable *mv = dict_lookup_var (m, var_get_name (dv));
{
struct variable *dv = dict_get_var (d, i);
struct variable *mv = dict_lookup_var (m, var_get_name (dv));
static struct ccase *
create_output_case (const struct comb_proc *proc)
{
static struct ccase *
create_output_case (const struct comb_proc *proc)
{
- size_t n_vars = dict_get_var_cnt (proc->dict);
+ size_t n_vars = dict_get_n_vars (proc->dict);
struct ccase *output;
size_t i;
struct ccase *output;
size_t i;
while (lex_token (lexer) != T_ENDCMD)
{
char **names;
while (lex_token (lexer) != T_ENDCMD)
{
char **names;
- size_t name_cnt, name_idx;
+ size_t n_names, name_idx;
struct fmt_spec *formats, *f;
struct fmt_spec *formats, *f;
/* Parse everything. */
if (!parse_record_placement (lexer, &record, &column)
|| !parse_DATA_LIST_vars_pool (lexer, dict, tmp_pool,
/* Parse everything. */
if (!parse_record_placement (lexer, &record, &column)
|| !parse_DATA_LIST_vars_pool (lexer, dict, tmp_pool,
- &names, &name_cnt, PV_NONE)
- || !parse_var_placements (lexer, tmp_pool, name_cnt, FMT_FOR_INPUT,
- &formats, &format_cnt))
+ &names, &n_names, PV_NONE)
+ || !parse_var_placements (lexer, tmp_pool, n_names, FMT_FOR_INPUT,
+ &formats, &n_formats))
return false;
/* Create variables and var specs. */
name_idx = 0;
return false;
/* Create variables and var specs. */
name_idx = 0;
- for (f = formats; f < &formats[format_cnt]; f++)
+ for (f = formats; f < &formats[n_formats]; f++)
if (!execute_placement_format (f, &record, &column))
{
char *name;
if (!execute_placement_format (f, &record, &column))
{
char *name;
- assert (name_idx == name_cnt);
+ assert (name_idx == n_names);
{
struct fmt_spec input, output;
char **name;
{
struct fmt_spec input, output;
char **name;
size_t i;
if (!parse_DATA_LIST_vars_pool (lexer, dict, tmp_pool,
size_t i;
if (!parse_DATA_LIST_vars_pool (lexer, dict, tmp_pool,
- &name, &name_cnt, PV_NONE))
+ &name, &n_names, PV_NONE))
return false;
if (lex_match (lexer, T_LPAREN))
return false;
if (lex_match (lexer, T_LPAREN))
output = *settings_get_format ();
}
output = *settings_get_format ();
}
- for (i = 0; i < name_cnt; i++)
+ for (i = 0; i < n_names; i++)
int skip_records; /* Records to skip before first real data. */
struct field *fields; /* Fields to parse. */
int skip_records; /* Records to skip before first real data. */
struct field *fields; /* Fields to parse. */
- size_t field_cnt; /* Number of fields. */
+ size_t n_fields; /* Number of fields. */
size_t field_allocated; /* Number of fields spaced allocated for. */
/* DP_DELIMITED parsers only. */
size_t field_allocated; /* Number of fields spaced allocated for. */
/* DP_DELIMITED parsers only. */
parser->skip_records = 0;
parser->fields = NULL;
parser->skip_records = 0;
parser->fields = NULL;
parser->field_allocated = 0;
parser->dict = dict_ref (dict);
parser->field_allocated = 0;
parser->dict = dict_ref (dict);
size_t i;
dict_unref (parser->dict);
size_t i;
dict_unref (parser->dict);
- for (i = 0; i < parser->field_cnt; i++)
+ for (i = 0; i < parser->n_fields; i++)
free (parser->fields[i].name);
free (parser->fields);
ss_dealloc (&parser->quotes);
free (parser->fields[i].name);
free (parser->fields);
ss_dealloc (&parser->quotes);
void
data_parser_set_type (struct data_parser *parser, enum data_parser_type type)
{
void
data_parser_set_type (struct data_parser *parser, enum data_parser_type type)
{
- assert (parser->field_cnt == 0);
+ assert (parser->n_fields == 0);
assert (type == DP_FIXED || type == DP_DELIMITED);
parser->type = type;
}
assert (type == DP_FIXED || type == DP_DELIMITED);
parser->type = type;
}
- if (p->field_cnt == p->field_allocated)
+ if (p->n_fields == p->field_allocated)
p->fields = x2nrealloc (p->fields, &p->field_allocated, sizeof *p->fields);
p->fields = x2nrealloc (p->fields, &p->field_allocated, sizeof *p->fields);
- field = &p->fields[p->field_cnt++];
+ field = &p->fields[p->n_fields++];
field->format = *format;
field->case_idx = case_idx;
field->name = xstrdup (name);
field->format = *format;
field->case_idx = case_idx;
field->name = xstrdup (name);
int record, int first_column)
{
assert (parser->type == DP_FIXED);
int record, int first_column)
{
assert (parser->type == DP_FIXED);
- assert (parser->field_cnt == 0
- || record >= parser->fields[parser->field_cnt - 1].record);
+ assert (parser->n_fields == 0
+ || record >= parser->fields[parser->n_fields - 1].record);
if (record > parser->records_per_case)
parser->records_per_case = record;
add_field (parser, format, case_idx, name, record, first_column);
if (record > parser->records_per_case)
parser->records_per_case = record;
add_field (parser, format, case_idx, name, record, first_column);
bool
data_parser_any_fields (const struct data_parser *parser)
{
bool
data_parser_any_fields (const struct data_parser *parser)
{
- return parser->field_cnt > 0;
+ return parser->n_fields > 0;
dfm_expand_tabs (reader);
line = dfm_get_record (reader);
dfm_expand_tabs (reader);
line = dfm_get_record (reader);
- for (; f < &parser->fields[parser->field_cnt] && f->record == row; f++)
+ for (; f < &parser->fields[parser->n_fields] && f->record == row; f++)
{
struct substring s = ss_substr (line, f->first_column - 1,
f->format.w);
{
struct substring s = ss_substr (line, f->first_column - 1,
f->format.w);
struct string tmp = DS_EMPTY_INITIALIZER;
struct field *f;
struct string tmp = DS_EMPTY_INITIALIZER;
struct field *f;
- for (f = parser->fields; f < &parser->fields[parser->field_cnt]; f++)
+ for (f = parser->fields; f < &parser->fields[parser->n_fields]; f++)
{
struct substring s;
int first_column, last_column;
{
struct substring s;
int first_column, last_column;
if (dfm_eof (reader))
return false;
if (dfm_eof (reader))
return false;
- end = &parser->fields[parser->field_cnt];
+ end = &parser->fields[parser->n_fields];
for (f = parser->fields; f < end; f++)
{
int first_column, last_column;
for (f = parser->fields; f < end; f++)
{
int first_column, last_column;
struct pivot_dimension *variables = pivot_dimension_create (
table, PIVOT_AXIS_ROW, N_("Variable"));
variables->root->show_label = true;
struct pivot_dimension *variables = pivot_dimension_create (
table, PIVOT_AXIS_ROW, N_("Variable"));
variables->root->show_label = true;
- for (size_t i = 0; i < parser->field_cnt; i++)
+ for (size_t i = 0; i < parser->n_fields; i++)
{
struct field *f = &parser->fields[i];
{
struct field *f = &parser->fields[i];
struct pivot_dimension *variables = pivot_dimension_create (
table, PIVOT_AXIS_ROW, N_("Variable"));
variables->root->show_label = true;
struct pivot_dimension *variables = pivot_dimension_create (
table, PIVOT_AXIS_ROW, N_("Variable"));
variables->root->show_label = true;
- for (size_t i = 0; i < parser->field_cnt; i++)
+ for (size_t i = 0; i < parser->n_fields; i++)
{
struct field *f = &parser->fields[i];
{
struct field *f = &parser->fields[i];
enum dfm_reader_flags flags; /* Zero or more of DFM_*. */
FILE *file; /* Associated file. */
size_t pos; /* Offset in line of current character. */
enum dfm_reader_flags flags; /* Zero or more of DFM_*. */
FILE *file; /* Associated file. */
size_t pos; /* Offset in line of current character. */
- unsigned eof_cnt; /* # of attempts to advance past EOF. */
+ unsigned n_eofs; /* # of attempts to advance past EOF. */
struct lexer *lexer; /* The lexer reading the file */
char *encoding; /* Current encoding. */
struct lexer *lexer; /* The lexer reading the file */
char *encoding; /* Current encoding. */
ds_init_empty (&r->line);
ds_init_empty (&r->scratch);
r->flags = DFM_ADVANCE;
ds_init_empty (&r->line);
ds_init_empty (&r->scratch);
r->flags = DFM_ADVANCE;
r->block_left = 0;
if (fh_get_referent (fh) != FH_REF_INLINE)
{
r->block_left = 0;
if (fh_get_referent (fh) != FH_REF_INLINE)
{
{
r->flags &= ~DFM_ADVANCE;
{
r->flags &= ~DFM_ADVANCE;
- if (r->eof_cnt == 0 && read_record (r))
+ if (r->n_eofs == 0 && read_record (r))
{
r->pos = 0;
return 0;
}
{
r->pos = 0;
return 0;
}
- r->eof_cnt++;
- if (r->eof_cnt == 2)
+ r->n_eofs++;
+ if (r->n_eofs == 2)
{
if (r->fh != fh_inline_file ())
msg (ME, _("Attempt to read beyond end-of-file on file %s."),
{
if (r->fh != fh_inline_file ())
msg (ME, _("Attempt to read beyond end-of-file on file %s."),
}
/* Returns the current record in the file corresponding to
}
/* Returns the current record in the file corresponding to
dfm_get_record (struct dfm_reader *r)
{
assert ((r->flags & DFM_ADVANCE) == 0);
dfm_get_record (struct dfm_reader *r)
{
assert ((r->flags & DFM_ADVANCE) == 0);
- assert (r->eof_cnt == 0);
+ assert (r->n_eofs == 0);
return ds_substr (&r->line, r->pos, SIZE_MAX);
}
return ds_substr (&r->line, r->pos, SIZE_MAX);
}
size_t ofs, new_pos, tab_width;
assert ((r->flags & DFM_ADVANCE) == 0);
size_t ofs, new_pos, tab_width;
assert ((r->flags & DFM_ADVANCE) == 0);
- assert (r->eof_cnt == 0);
+ assert (r->n_eofs == 0);
if (r->flags & DFM_TABS_EXPANDED)
return;
if (r->flags & DFM_TABS_EXPANDED)
return;
if (reader == NULL)
goto error;
if (reader == NULL)
goto error;
- if (dict_get_var_cnt (dict) == 0)
+ if (dict_get_n_vars (dict) == 0)
{
msg (SE, _("%s: Data file dictionary has no variables."),
fh_get_name (fh));
{
msg (SE, _("%s: Data file dictionary has no variables."),
fh_get_name (fh));
if (!dict)
return CMD_FAILURE;
if (!dict)
return CMD_FAILURE;
- size_t n_input_vars = dict_get_var_cnt (dict);
+ size_t n_input_vars = dict_get_n_vars (dict);
struct variable **input_vars = xnmalloc (n_input_vars, sizeof *input_vars);
for (size_t i = 0; i < n_input_vars; i++)
input_vars[i] = dict_get_var (dict, i);
struct variable **input_vars = xnmalloc (n_input_vars, sizeof *input_vars);
for (size_t i = 0; i < n_input_vars; i++)
input_vars[i] = dict_get_var (dict, i);
- struct variable **order = xnmalloc (dict_get_var_cnt (dict), sizeof *order);
+ struct variable **order = xnmalloc (dict_get_n_vars (dict), sizeof *order);
size_t n_order = 0;
for (size_t i = 0; i < mf.n_svars; i++)
order[n_order++] = mf.svars[i];
size_t n_order = 0;
for (size_t i = 0; i < mf.n_svars; i++)
order[n_order++] = mf.svars[i];
order[n_order++] = mf.varname;
for (size_t i = 0; i < mf.n_cvars; i++)
order[n_order++] = mf.cvars[i];
order[n_order++] = mf.varname;
for (size_t i = 0; i < mf.n_cvars; i++)
order[n_order++] = mf.cvars[i];
- assert (n_order == dict_get_var_cnt (dict));
+ assert (n_order == dict_get_n_vars (dict));
dict_reorder_vars (dict, order, n_order);
free (order);
dict_reorder_vars (dict, order, n_order);
free (order);
- for (size_t i = 0; i < dict_get_var_cnt (dict); i++)
+ for (size_t i = 0; i < dict_get_n_vars (dict); i++)
{
const struct variable *v = dict_get_var (dict, i);
if (!var_is_numeric (v) && v != rowtype && v != varname)
{
const struct variable *v = dict_get_var (dict, i);
if (!var_is_numeric (v) && v != rowtype && v != varname)
PRS_TYPE_NEW_REC /* Next record. */
};
PRS_TYPE_NEW_REC /* Next record. */
};
-static bool fixed_parse_columns (struct lexer *, struct pool *, size_t var_cnt,
+static bool fixed_parse_columns (struct lexer *, struct pool *, size_t n_vars,
enum fmt_use, struct fmt_spec **, size_t *);
static bool fixed_parse_fortran (struct lexer *l, struct pool *, enum fmt_use,
struct fmt_spec **, size_t *);
enum fmt_use, struct fmt_spec **, size_t *);
static bool fixed_parse_fortran (struct lexer *l, struct pool *, enum fmt_use,
struct fmt_spec **, size_t *);
in addition to regular formats. If USE is FMT_FOR_OUTPUT, then
T and X "formats" are parsed but not /.
in addition to regular formats. If USE is FMT_FOR_OUTPUT, then
T and X "formats" are parsed but not /.
- If successful, formats for VAR_CNT variables are stored in
+ If successful, formats for N_VARS variables are stored in
*FORMATS, and the number of formats required is stored in
*FORMATS, and the number of formats required is stored in
- *FORMAT_CNT. *FORMAT_CNT may be greater than VAR_CNT because
+ *FORMAT_CNT. *FORMAT_CNT may be greater than N_VARS because
of T, X, and / "formats", but success guarantees that exactly
of T, X, and / "formats", but success guarantees that exactly
- VAR_CNT variables will be placed by the output formats. The
+ N_VARS variables will be placed by the output formats. The
caller should call execute_placement_format to process those
"formats" in interpreting the output.
Uses POOL for allocation. When the caller is finished
interpreting *FORMATS, POOL may be destroyed. */
bool
caller should call execute_placement_format to process those
"formats" in interpreting the output.
Uses POOL for allocation. When the caller is finished
interpreting *FORMATS, POOL may be destroyed. */
bool
-parse_var_placements (struct lexer *lexer, struct pool *pool, size_t var_cnt,
+parse_var_placements (struct lexer *lexer, struct pool *pool, size_t n_vars,
- struct fmt_spec **formats, size_t *format_cnt)
+ struct fmt_spec **formats, size_t *n_formats)
if (lex_is_number (lexer))
if (lex_is_number (lexer))
- return fixed_parse_columns (lexer, pool, var_cnt, use,
- formats, format_cnt);
+ return fixed_parse_columns (lexer, pool, n_vars, use,
+ formats, n_formats);
else if (lex_match (lexer, T_LPAREN))
{
else if (lex_match (lexer, T_LPAREN))
{
- if (!fixed_parse_fortran (lexer, pool, use, formats, format_cnt))
+ if (!fixed_parse_fortran (lexer, pool, use, formats, n_formats))
- assignment_cnt = 0;
- for (i = 0; i < *format_cnt; i++)
- assignment_cnt += (*formats)[i].type < FMT_NUMBER_OF_FORMATS;
+ n_assignments = 0;
+ for (i = 0; i < *n_formats; i++)
+ n_assignments += (*formats)[i].type < FMT_NUMBER_OF_FORMATS;
- if (assignment_cnt != var_cnt)
+ if (n_assignments != n_vars)
{
msg (SE, _("Number of variables specified (%zu) "
"differs from number of variable formats (%zu)."),
{
msg (SE, _("Number of variables specified (%zu) "
"differs from number of variable formats (%zu)."),
- var_cnt, assignment_cnt);
+ n_vars, n_assignments);
/* Implements parse_var_placements for column-based formats. */
static bool
/* Implements parse_var_placements for column-based formats. */
static bool
-fixed_parse_columns (struct lexer *lexer, struct pool *pool, size_t var_cnt,
+fixed_parse_columns (struct lexer *lexer, struct pool *pool, size_t n_vars,
- struct fmt_spec **formats, size_t *format_cnt)
+ struct fmt_spec **formats, size_t *n_formats)
{
struct fmt_spec format;
int fc, lc;
{
struct fmt_spec format;
int fc, lc;
return false;
/* Divide columns evenly. */
return false;
/* Divide columns evenly. */
- format.w = (lc - fc + 1) / var_cnt;
- if ((lc - fc + 1) % var_cnt)
+ format.w = (lc - fc + 1) / n_vars;
+ if ((lc - fc + 1) % n_vars)
{
msg (SE, _("The %d columns %d-%d "
"can't be evenly divided into %zu fields."),
{
msg (SE, _("The %d columns %d-%d "
"can't be evenly divided into %zu fields."),
- lc - fc + 1, fc, lc, var_cnt);
+ lc - fc + 1, fc, lc, n_vars);
if (!fmt_check (&format, use))
return false;
if (!fmt_check (&format, use))
return false;
- *formats = pool_nalloc (pool, var_cnt + 1, sizeof **formats);
- *format_cnt = var_cnt + 1;
+ *formats = pool_nalloc (pool, n_vars + 1, sizeof **formats);
+ *n_formats = n_vars + 1;
(*formats)[0].type = (enum fmt_type) PRS_TYPE_T;
(*formats)[0].w = fc;
(*formats)[0].type = (enum fmt_type) PRS_TYPE_T;
(*formats)[0].w = fc;
- for (i = 1; i <= var_cnt; i++)
+ for (i = 1; i <= n_vars; i++)
(*formats)[i] = format;
return true;
}
(*formats)[i] = format;
return true;
}
/* Implements parse_var_placements for Fortran-like formats. */
static bool
fixed_parse_fortran (struct lexer *lexer, struct pool *pool, enum fmt_use use,
/* Implements parse_var_placements for Fortran-like formats. */
static bool
fixed_parse_fortran (struct lexer *lexer, struct pool *pool, enum fmt_use use,
- struct fmt_spec **formats, size_t *format_cnt)
+ struct fmt_spec **formats, size_t *n_formats)
{
size_t formats_allocated = 0;
size_t formats_used = 0;
{
size_t formats_allocated = 0;
size_t formats_used = 0;
{
struct fmt_spec f;
struct fmt_spec *new_formats;
{
struct fmt_spec f;
struct fmt_spec *new_formats;
size_t count;
size_t formats_needed;
size_t count;
size_t formats_needed;
{
/* Call ourselves recursively to handle parentheses. */
if (!fixed_parse_fortran (lexer, pool, use,
{
/* Call ourselves recursively to handle parentheses. */
if (!fixed_parse_fortran (lexer, pool, use,
- &new_formats, &new_format_cnt))
+ &new_formats, &n_new_formats))
return false;
}
else
{
new_formats = &f;
return false;
}
else
{
new_formats = &f;
if (use == FMT_FOR_INPUT && lex_match (lexer, T_SLASH))
f.type = (enum fmt_type) PRS_TYPE_NEW_REC;
else
if (use == FMT_FOR_INPUT && lex_match (lexer, T_SLASH))
f.type = (enum fmt_type) PRS_TYPE_NEW_REC;
else
/* Add COUNT copies of the NEW_FORMAT_CNT formats in
NEW_FORMATS to FORMATS. */
/* Add COUNT copies of the NEW_FORMAT_CNT formats in
NEW_FORMATS to FORMATS. */
- if (new_format_cnt != 0
&& size_overflow_p (xtimes (xsum (formats_used,
&& size_overflow_p (xtimes (xsum (formats_used,
- xtimes (count, new_format_cnt)),
+ xtimes (count, n_new_formats)),
sizeof *formats)))
xalloc_die ();
sizeof *formats)))
xalloc_die ();
- formats_needed = count * new_format_cnt;
+ formats_needed = count * n_new_formats;
if (formats_used + formats_needed > formats_allocated)
{
formats_allocated = formats_used + formats_needed;
if (formats_used + formats_needed > formats_allocated)
{
formats_allocated = formats_used + formats_needed;
for (; count > 0; count--)
{
memcpy (&(*formats)[formats_used], new_formats,
for (; count > 0; count--)
{
memcpy (&(*formats)[formats_used], new_formats,
- sizeof **formats * new_format_cnt);
- formats_used += new_format_cnt;
+ sizeof **formats * n_new_formats);
+ formats_used += n_new_formats;
}
lex_match (lexer, T_COMMA);
}
}
lex_match (lexer, T_COMMA);
}
- *format_cnt = formats_used;
+ *n_formats = formats_used;
struct lexer;
bool parse_record_placement (struct lexer *, int *record, int *column);
struct lexer;
bool parse_record_placement (struct lexer *, int *record, int *column);
-bool parse_var_placements (struct lexer *, struct pool *, size_t var_cnt,
+bool parse_var_placements (struct lexer *, struct pool *, size_t n_vars,
- struct fmt_spec **, size_t *format_cnt);
+ struct fmt_spec **, size_t *n_formats);
bool execute_placement_format (const struct fmt_spec *,
int *record, int *column);
bool parse_column (struct lexer *lexer, int base, int *column);
bool execute_placement_format (const struct fmt_spec *,
int *record, int *column);
bool parse_column (struct lexer *lexer, int base, int *column);
const char *encoding; /* Encoding to use for output. */
struct dfm_writer *writer; /* Output file, NULL=listing file. */
struct ll_list specs; /* List of struct prt_out_specs. */
const char *encoding; /* Encoding to use for output. */
struct dfm_writer *writer; /* Output file, NULL=listing file. */
struct ll_list specs; /* List of struct prt_out_specs. */
- size_t record_cnt; /* Number of records to write. */
+ size_t n_records; /* Number of records to write. */
trns = pool_create_container (struct print_trns, pool);
trns->eject = eject;
trns->writer = NULL;
trns = pool_create_container (struct print_trns, pool);
trns->eject = eject;
trns->writer = NULL;
ll_init (&trns->specs);
tmp_pool = pool_create_subpool (trns->pool);
ll_init (&trns->specs);
tmp_pool = pool_create_subpool (trns->pool);
lex_match (lexer, T_LPAREN);
if (!lex_force_int_range (lexer, "RECORDS", 0, INT_MAX))
goto error;
lex_match (lexer, T_LPAREN);
if (!lex_force_int_range (lexer, "RECORDS", 0, INT_MAX))
goto error;
- trns->record_cnt = lex_integer (lexer);
+ trns->n_records = lex_integer (lexer);
lex_get (lexer);
lex_match (lexer, T_RPAREN);
}
lex_get (lexer);
lex_match (lexer, T_RPAREN);
}
if (lex_token (lexer) == T_ENDCMD)
{
if (lex_token (lexer) == T_ENDCMD)
{
lex_match (lexer, T_COMMA);
}
lex_match (lexer, T_COMMA);
}
- if (trns->record_cnt != 0 && trns->record_cnt != record)
+ if (trns->n_records != 0 && trns->n_records != record)
msg (SW, _("Output calls for %d records but %zu specified on RECORDS "
"subcommand."),
msg (SW, _("Output calls for %d records but %zu specified on RECORDS "
"subcommand."),
- record, trns->record_cnt);
- trns->record_cnt = record;
+ record, trns->n_records);
+ trns->n_records = record;
enum which_formats which_formats)
{
const struct variable **vars;
enum which_formats which_formats)
{
const struct variable **vars;
- size_t var_cnt, var_idx;
+ size_t n_vars, var_idx;
struct fmt_spec *formats, *f;
struct fmt_spec *formats, *f;
bool add_space;
if (!parse_variables_const_pool (lexer, tmp_pool, dict,
bool add_space;
if (!parse_variables_const_pool (lexer, tmp_pool, dict,
- &vars, &var_cnt, PV_DUPLICATE))
+ &vars, &n_vars, PV_DUPLICATE))
return false;
if (lex_is_number (lexer) || lex_token (lexer) == T_LPAREN)
{
return false;
if (lex_is_number (lexer) || lex_token (lexer) == T_LPAREN)
{
- if (!parse_var_placements (lexer, tmp_pool, var_cnt, FMT_FOR_OUTPUT,
- &formats, &format_cnt))
+ if (!parse_var_placements (lexer, tmp_pool, n_vars, FMT_FOR_OUTPUT,
+ &formats, &n_formats))
return false;
add_space = false;
}
return false;
add_space = false;
}
lex_match (lexer, T_ASTERISK);
lex_match (lexer, T_ASTERISK);
- formats = pool_nmalloc (tmp_pool, var_cnt, sizeof *formats);
- format_cnt = var_cnt;
- for (i = 0; i < var_cnt; i++)
+ formats = pool_nmalloc (tmp_pool, n_vars, sizeof *formats);
+ n_formats = n_vars;
+ for (i = 0; i < n_vars; i++)
{
const struct variable *v = vars[i];
formats[i] = (which_formats == PRINT
{
const struct variable *v = vars[i];
formats[i] = (which_formats == PRINT
- for (f = formats; f < &formats[format_cnt]; f++)
+ for (f = formats; f < &formats[n_formats]; f++)
if (!execute_placement_format (f, record, column))
{
const struct variable *var;
if (!execute_placement_format (f, record, column))
{
const struct variable *var;
*column += f->w + add_space;
}
*column += f->w + add_space;
}
- assert (var_idx == var_cnt);
+ assert (var_idx == n_vars);
int row = pivot_category_create_leaf (
variables->root, pivot_value_new_text (N_("N of Records")));
pivot_table_put2 (table, 0, row,
int row = pivot_category_create_leaf (
variables->root, pivot_value_new_text (N_("N of Records")));
pivot_table_put2 (table, 0, row,
- pivot_value_new_integer (trns->record_cnt));
+ pivot_value_new_integer (trns->n_records));
pivot_table_submit (table);
}
pivot_table_submit (table);
}
ds_data (s), ds_length (s));
}
}
ds_data (s), ds_length (s));
}
}
- print_text_flush_records (trns, &line, trns->record_cnt + 1,
+ print_text_flush_records (trns, &line, trns->n_records + 1,
&eject, &record);
u8_line_destroy (&line);
&eject, &record);
u8_line_destroy (&line);
- print_binary_flush_records (trns, &line, trns->record_cnt + 1,
+ print_binary_flush_records (trns, &line, trns->n_records + 1,
&eject, &record);
ds_destroy (&line);
&eject, &record);
ds_destroy (&line);
dict_delete_vars (dict, v, nv);
free (v);
dict_delete_vars (dict, v, nv);
free (v);
- if (dict_get_var_cnt (dict) == 0)
+ if (dict_get_n_vars (dict) == 0)
{
msg (SE, _("Cannot DROP all variables from dictionary."));
return false;
{
msg (SE, _("Cannot DROP all variables from dictionary."));
return false;
dict_reorder_vars (dict, v, nv);
/* Delete the remaining variables. */
dict_reorder_vars (dict, v, nv);
/* Delete the remaining variables. */
- if (dict_get_var_cnt (dict) == nv)
+ if (dict_get_n_vars (dict) == nv)
{
free (v);
return true;
}
{
free (v);
return true;
}
- v = xnrealloc (v, dict_get_var_cnt (dict) - nv, sizeof *v);
- for (i = nv; i < dict_get_var_cnt (dict); i++)
+ v = xnrealloc (v, dict_get_n_vars (dict) - nv, sizeof *v);
+ for (i = nv; i < dict_get_n_vars (dict); i++)
v[i - nv] = dict_get_var (dict, i);
v[i - nv] = dict_get_var (dict, i);
- dict_delete_vars (dict, v, dict_get_var_cnt (dict) - nv);
+ dict_delete_vars (dict, v, dict_get_n_vars (dict) - nv);
casereader_destroy (reader);
casereader_destroy (reader);
- for (i = 0; i < dict_get_var_cnt (dict); i++)
+ for (i = 0; i < dict_get_n_vars (dict); i++)
{
const struct variable *s = dict_get_var (dict, i);
struct variable *t = dict_lookup_var (dataset_dict (ds),
{
const struct variable *s = dict_get_var (dict, i);
struct variable *t = dict_lookup_var (dataset_dict (ds),
cmd_delete_variables (struct lexer *lexer, struct dataset *ds)
{
struct variable **vars;
cmd_delete_variables (struct lexer *lexer, struct dataset *ds)
{
struct variable **vars;
bool ok;
if (proc_make_temporary_transformations_permanent (ds))
bool ok;
if (proc_make_temporary_transformations_permanent (ds))
"Temporary transformations will be made permanent."),
"DELETE VARIABLES", "TEMPORARY");
"Temporary transformations will be made permanent."),
"DELETE VARIABLES", "TEMPORARY");
- if (!parse_variables (lexer, dataset_dict (ds), &vars, &var_cnt, PV_NONE))
+ if (!parse_variables (lexer, dataset_dict (ds), &vars, &n_vars, PV_NONE))
- if (var_cnt == dict_get_var_cnt (dataset_dict (ds)))
+ if (n_vars == dict_get_n_vars (dataset_dict (ds)))
{
msg (SE, _("%s may not be used to delete all variables "
"from the active dataset dictionary. "
{
msg (SE, _("%s may not be used to delete all variables "
"from the active dataset dictionary. "
- dict_delete_vars (dataset_dict (ds), vars, var_cnt);
+ dict_delete_vars (dataset_dict (ds), vars, n_vars);
/* XXX A bunch of bugs conspire to make executing transformations again here
necessary, even though it shouldn't be.
/* XXX A bunch of bugs conspire to make executing transformations again here
necessary, even though it shouldn't be.
vm.drop_vars = drop_vars;
vm.n_drop = n_drop;
vm.drop_vars = drop_vars;
vm.n_drop = n_drop;
- if (n_drop == dict_get_var_cnt (dataset_dict (ds)))
+ if (n_drop == dict_get_n_vars (dataset_dict (ds)))
{
msg (SE, _("%s may not be used to delete all variables "
"from the active dataset dictionary. "
{
msg (SE, _("%s may not be used to delete all variables "
"from the active dataset dictionary. "
output_split_file_values (const struct dataset *ds, const struct ccase *c)
{
const struct dictionary *dict = dataset_dict (ds);
output_split_file_values (const struct dataset *ds, const struct ccase *c)
{
const struct dictionary *dict = dataset_dict (ds);
- size_t n_vars = dict_get_split_cnt (dict);
+ size_t n_vars = dict_get_n_splits (dict);
: N_("Unknown")));
add_row (table, N_("Variables"),
: N_("Unknown")));
add_row (table, N_("Variables"),
- pivot_value_new_integer (dict_get_var_cnt (d)));
+ pivot_value_new_integer (dict_get_n_vars (d)));
add_row (table, N_("Cases"),
add_row (table, N_("Cases"),
? pivot_value_new_text (N_("Unknown"))
? pivot_value_new_text (N_("Unknown"))
- : pivot_value_new_integer (info.case_cnt)));
+ : pivot_value_new_integer (info.n_cases)));
add_row (table, N_("Type"),
pivot_value_new_text (info.klass->name));
add_row (table, N_("Type"),
pivot_value_new_text (info.klass->name));
add_row (table, N_("Encoding"),
pivot_value_new_user_text (dict_get_encoding (d), -1));
add_row (table, N_("Encoding"),
pivot_value_new_user_text (dict_get_encoding (d), -1));
- if (dict_get_document_line_cnt (d) > 0)
+ if (dict_get_document_n_lines (d) > 0)
add_row (table, N_("Documents"),
pivot_value_new_user_text_nocopy (get_documents_as_string (d)));
pivot_table_submit (table);
add_row (table, N_("Documents"),
pivot_value_new_user_text_nocopy (get_documents_as_string (d)));
pivot_table_submit (table);
- size_t n_vars = dict_get_var_cnt (d);
+ size_t n_vars = dict_get_n_vars (d);
const struct variable **vars = xnmalloc (n_vars, sizeof *vars);
const struct variable **vars = xnmalloc (n_vars, sizeof *vars);
- for (size_t i = 0; i < dict_get_var_cnt (d); i++)
+ for (size_t i = 0; i < dict_get_n_vars (d); i++)
vars[i] = dict_get_var (d, i);
display_variables (vars, n_vars, DF_ALL_VARIABLE);
display_value_labels (vars, n_vars);
vars[i] = dict_get_var (d, i);
display_variables (vars, n_vars, DF_ALL_VARIABLE);
display_value_labels (vars, n_vars);
static void
display_vectors (const struct dictionary *dict, int sorted)
{
static void
display_vectors (const struct dictionary *dict, int sorted)
{
- size_t n_vectors = dict_get_vector_cnt (dict);
+ size_t n_vectors = dict_get_n_vectors (dict);
if (n_vectors == 0)
{
msg (SW, _("No vectors defined."));
if (n_vectors == 0)
{
msg (SW, _("No vectors defined."));
vector_dim->root, pivot_value_new_user_text (
vector_get_name (vectors[i]), -1));
vector_dim->root, pivot_value_new_user_text (
vector_get_name (vectors[i]), -1));
- for (size_t j = 0; j < vector_get_var_cnt (vec); j++)
+ for (size_t j = 0; j < vector_get_n_vars (vec); j++)
{
struct variable *var = vector_get_var (vec, j);
{
struct variable *var = vector_get_var (vec, j);
static int do_value_labels (struct lexer *,
const struct dictionary *dict, bool);
static int do_value_labels (struct lexer *,
const struct dictionary *dict, bool);
-static void erase_labels (struct variable **vars, size_t var_cnt);
-static int get_label (struct lexer *, struct variable **vars, size_t var_cnt,
+static void erase_labels (struct variable **vars, size_t n_vars);
+static int get_label (struct lexer *, struct variable **vars, size_t n_vars,
const char *dict_encoding);
\f
/* Stubs. */
const char *dict_encoding);
\f
/* Stubs. */
do_value_labels (struct lexer *lexer, const struct dictionary *dict, bool erase)
{
struct variable **vars; /* Variable list. */
do_value_labels (struct lexer *lexer, const struct dictionary *dict, bool erase)
{
struct variable **vars; /* Variable list. */
- size_t var_cnt; /* Number of variables. */
+ size_t n_vars; /* Number of variables. */
int parse_err=0; /* true if error parsing variables */
lex_match (lexer, T_SLASH);
while (lex_token (lexer) != T_ENDCMD)
{
int parse_err=0; /* true if error parsing variables */
lex_match (lexer, T_SLASH);
while (lex_token (lexer) != T_ENDCMD)
{
- parse_err = !parse_variables (lexer, dict, &vars, &var_cnt,
+ parse_err = !parse_variables (lexer, dict, &vars, &n_vars,
{
free(vars);
return CMD_FAILURE;
}
if (erase)
{
free(vars);
return CMD_FAILURE;
}
if (erase)
- erase_labels (vars, var_cnt);
+ erase_labels (vars, n_vars);
while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
- if (!get_label (lexer, vars, var_cnt, dict_get_encoding (dict)))
+ if (!get_label (lexer, vars, n_vars, dict_get_encoding (dict)))
goto lossage;
if (lex_token (lexer) != T_SLASH)
goto lossage;
if (lex_token (lexer) != T_SLASH)
-/* Erases all the labels for the VAR_CNT variables in VARS. */
+/* Erases all the labels for the N_VARS variables in VARS. */
-erase_labels (struct variable **vars, size_t var_cnt)
+erase_labels (struct variable **vars, size_t n_vars)
/* Erase old value labels if desired. */
/* Erase old value labels if desired. */
- for (i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
var_clear_value_labels (vars[i]);
}
var_clear_value_labels (vars[i]);
}
-/* Parse all the labels for the VAR_CNT variables in VARS and add
+/* Parse all the labels for the N_VARS variables in VARS and add
the specified labels to those variables. */
static int
the specified labels to those variables. */
static int
-get_label (struct lexer *lexer, struct variable **vars, size_t var_cnt,
+get_label (struct lexer *lexer, struct variable **vars, size_t n_vars,
const char *dict_encoding)
{
/* Parse all the labels and add them to the variables. */
const char *dict_encoding)
{
/* Parse all the labels and add them to the variables. */
ds_truncate (&label, trunc_len);
}
ds_truncate (&label, trunc_len);
}
- for (i = 0; i < var_cnt; i++)
+ for (i = 0; i < n_vars; i++)
var_replace_value_label (vars[i], &value, ds_cstr (&label));
ds_destroy (&label);
var_replace_value_label (vars[i], &value, ds_cstr (&label));
ds_destroy (&label);
- size_t vector_cnt, vector_cap;
+ size_t n_vectors, allocated_vectors;
/* Get the name(s) of the new vector(s). */
if (!lex_force_id (lexer)
/* Get the name(s) of the new vector(s). */
if (!lex_force_id (lexer)
return CMD_CASCADING_FAILURE;
vectors = NULL;
return CMD_CASCADING_FAILURE;
vectors = NULL;
- vector_cnt = vector_cap = 0;
+ n_vectors = allocated_vectors = 0;
while (lex_token (lexer) == T_ID)
{
size_t i;
while (lex_token (lexer) == T_ID)
{
size_t i;
- for (i = 0; i < vector_cnt; i++)
+ for (i = 0; i < n_vectors; i++)
if (!utf8_strcasecmp (vectors[i], lex_tokcstr (lexer)))
{
msg (SE, _("Vector name %s is given twice."),
if (!utf8_strcasecmp (vectors[i], lex_tokcstr (lexer)))
{
msg (SE, _("Vector name %s is given twice."),
- if (vector_cnt == vector_cap)
- vectors = pool_2nrealloc (pool,
- vectors, &vector_cap, sizeof *vectors);
- vectors[vector_cnt++] = pool_strdup (pool, lex_tokcstr (lexer));
+ if (n_vectors == allocated_vectors)
+ vectors = pool_2nrealloc (pool, vectors, &allocated_vectors,
+ sizeof *vectors);
+ vectors[n_vectors++] = pool_strdup (pool, lex_tokcstr (lexer));
lex_get (lexer);
lex_match (lexer, T_COMMA);
lex_get (lexer);
lex_match (lexer, T_COMMA);
struct variable **v;
size_t nv;
struct variable **v;
size_t nv;
{
msg (SE, _("A slash must separate each vector "
"specification in VECTOR's long form."));
{
msg (SE, _("A slash must separate each vector "
"specification in VECTOR's long form."));
bool seen_format = false;
struct variable **vars;
bool seen_format = false;
struct variable **vars;
format = fmt_for_output (FMT_F, 8, 2);
seen_format = false;
while (!lex_match (lexer, T_RPAREN))
{
format = fmt_for_output (FMT_F, 8, 2);
seen_format = false;
while (!lex_match (lexer, T_RPAREN))
{
- if (lex_is_integer (lexer) && var_cnt == 0)
+ if (lex_is_integer (lexer) && n_vars == 0)
{
if (!lex_force_int_range (lexer, NULL, 1, INT_MAX))
goto fail;
{
if (!lex_force_int_range (lexer, NULL, 1, INT_MAX))
goto fail;
- var_cnt = lex_integer (lexer);
+ n_vars = lex_integer (lexer);
lex_get (lexer);
}
else if (lex_token (lexer) == T_ID && !seen_format)
lex_get (lexer);
}
else if (lex_token (lexer) == T_ID && !seen_format)
}
lex_match (lexer, T_COMMA);
}
}
lex_match (lexer, T_COMMA);
}
{
lex_error (lexer, _("expecting vector length"));
goto fail;
{
lex_error (lexer, _("expecting vector length"));
goto fail;
/* Check that none of the variables exist and that their names are
not excessively long. */
/* Check that none of the variables exist and that their names are
not excessively long. */
- for (i = 0; i < vector_cnt; i++)
+ for (i = 0; i < n_vectors; i++)
- for (j = 0; j < var_cnt; j++)
+ for (j = 0; j < n_vars; j++)
{
char *name = xasprintf ("%s%d", vectors[i], j + 1);
if (!dict_id_is_valid (dict, name, true))
{
char *name = xasprintf ("%s%d", vectors[i], j + 1);
if (!dict_id_is_valid (dict, name, true))
}
/* Finally create the variables and vectors. */
}
/* Finally create the variables and vectors. */
- vars = pool_nmalloc (pool, var_cnt, sizeof *vars);
- for (i = 0; i < vector_cnt; i++)
+ vars = pool_nmalloc (pool, n_vars, sizeof *vars);
+ for (i = 0; i < n_vectors; i++)
- for (j = 0; j < var_cnt; j++)
+ for (j = 0; j < n_vars; j++)
{
char *name = xasprintf ("%s%d", vectors[i], j + 1);
vars[j] = dict_create_var_assert (dict, name,
{
char *name = xasprintf ("%s%d", vectors[i], j + 1);
vars[j] = dict_create_var_assert (dict, name,
var_set_both_formats (vars[j], &format);
free (name);
}
var_set_both_formats (vars[j], &format);
free (name);
}
- dict_create_vector_assert (dict, vectors[i], vars, var_cnt);
+ dict_create_vector_assert (dict, vectors[i], vars, n_vars);
- assert (op < e->ops + e->op_cnt);
+ assert (op < e->ops + e->n_ops);
switch (op++->operation)
{
case OP_number:
switch (op++->operation)
{
case OP_number:
{
struct string s = DS_EMPTY_INITIALIZER;
{
struct string s = DS_EMPTY_INITIALIZER;
- for (size_t i = 0; i < e->op_cnt; i++)
+ for (size_t i = 0; i < e->n_ops; i++)
{
union operation_data *op = &e->ops[i];
if (i > 0)
{
union operation_data *op = &e->ops[i];
if (i > 0)
my ($prefix, $first, $last) = @_;
print " ${prefix}_first = $first,\n";
print " ${prefix}_last = $last,\n";
my ($prefix, $first, $last) = @_;
print " ${prefix}_first = $first,\n";
print " ${prefix}_last = $last,\n";
- print " ${prefix}_cnt = ${prefix}_last - ${prefix}_first + 1";
+ print " n_${prefix} = ${prefix}_last - ${prefix}_first + 1";
my ($func) = "get_$type->{ATOM}_arg";
push (@decls, "${ctype}arg_$name = $func (node, $arg_idx)");
} else {
my ($func) = "get_$type->{ATOM}_arg";
push (@decls, "${ctype}arg_$name = $func (node, $arg_idx)");
} else {
- my ($decl) = "size_t arg_$idx = node->arg_cnt";
+ my ($decl) = "size_t arg_$idx = node->n_args";
$decl .= " - $arg_idx" if $arg_idx;
push (@decls, $decl);
$decl .= " - $arg_idx" if $arg_idx;
push (@decls, $decl);
{ DATE_MINUTES, SS_LITERAL_INITIALIZER ("minutes") },
{ DATE_SECONDS, SS_LITERAL_INITIALIZER ("seconds") },
};
{ DATE_MINUTES, SS_LITERAL_INITIALIZER ("minutes") },
{ DATE_SECONDS, SS_LITERAL_INITIALIZER ("seconds") },
};
- const int unit_name_cnt = sizeof unit_names / sizeof *unit_names;
+ const int n_unit_names = sizeof unit_names / sizeof *unit_names;
const struct unit_name *un;
const struct unit_name *un;
- for (un = unit_names; un < &unit_names[unit_name_cnt]; un++)
+ for (un = unit_names; un < &unit_names[n_unit_names]; un++)
if (ss_equals_case (un->name, name))
{
*unit = un->unit;
if (ss_equals_case (un->name, name))
{
*unit = un->unit;
-count_valid (double *d, size_t d_cnt)
+count_valid (double *d, size_t n)
- size_t valid_cnt;
- size_t i;
-
- valid_cnt = 0;
- for (i = 0; i < d_cnt; i++)
- valid_cnt += is_valid (d[i]);
- return valid_cnt;
+ size_t n_valid = 0;
+ for (size_t i = 0; i < n; i++)
+ n_valid += is_valid (d[i]);
+ return n_valid;
absorb_miss function NMISS (a[n])
{
absorb_miss function NMISS (a[n])
{
- size_t i;
- size_t missing_cnt = 0;
-
- for (i = 0; i < n; i++)
- missing_cnt += a[i] == SYSMIS;
- return missing_cnt;
+ size_t n_missings = 0;
+ for (size_t i = 0; i < n; i++)
+ n_missings += a[i] == SYSMIS;
+ return n_missings;
}
absorb_miss function NVALID (a[n])
{
}
absorb_miss function NVALID (a[n])
{
- size_t i;
- size_t valid_cnt = 0;
-
- for (i = 0; i < n; i++)
- valid_cnt += a[i] != SYSMIS;
- return valid_cnt;
+ size_t n_valids = 0;
+ for (size_t i = 0; i < n; i++)
+ n_valids += a[i] != SYSMIS;
+ return n_valids;
}
absorb_miss boolean function RANGE (x != SYSMIS, a[n*2])
}
absorb_miss boolean function RANGE (x != SYSMIS, a[n*2])
- if (idx >= 1 && idx <= vector_get_var_cnt (v))
+ if (idx >= 1 && idx <= vector_get_n_vars (v))
{
const struct variable *var = vector_get_var (v, (size_t) idx - 1);
double value = case_num (c, var);
{
const struct variable *var = vector_get_var (v, (size_t) idx - 1);
double value = case_num (c, var);
- if (idx >= 1 && idx <= vector_get_var_cnt (v))
+ if (idx >= 1 && idx <= vector_get_n_vars (v))
{
struct variable *var = vector_get_var (v, (size_t) idx - 1);
return copy_string (e, CHAR_CAST_BUG (char *, case_str (c, var)),
{
struct variable *var = vector_get_var (v, (size_t) idx - 1);
return copy_string (e, CHAR_CAST_BUG (char *, case_str (c, var)),
union any_node *
expr_optimize (union any_node *node, struct expression *e)
{
union any_node *
expr_optimize (union any_node *node, struct expression *e)
{
- int nonconst_cnt = 0; /* Number of nonconstant children. */
- int sysmis_cnt = 0; /* Number of system-missing children. */
+ int n_nonconst = 0; /* Number of nonconstant children. */
+ int n_sysmis = 0; /* Number of system-missing children. */
const struct operation *op;
struct composite_node *c;
int i;
const struct operation *op;
struct composite_node *c;
int i;
/* Start by optimizing all the children. */
c = &node->composite;
/* Start by optimizing all the children. */
c = &node->composite;
- for (i = 0; i < c->arg_cnt; i++)
+ for (i = 0; i < c->n_args; i++)
{
c->args[i] = expr_optimize (c->args[i], e);
if (c->args[i]->type == OP_number)
{
if (c->args[i]->number.n == SYSMIS)
{
c->args[i] = expr_optimize (c->args[i], e);
if (c->args[i]->type == OP_number)
{
if (c->args[i]->number.n == SYSMIS)
}
if (!is_atom (c->args[i]->type))
}
if (!is_atom (c->args[i]->type))
}
op = &operations[c->type];
}
op = &operations[c->type];
- if (sysmis_cnt && (op->flags & OPF_ABSORB_MISS) == 0)
+ if (n_sysmis && (op->flags & OPF_ABSORB_MISS) == 0)
{
/* Most operations produce SYSMIS given any SYSMIS
argument. */
{
/* Most operations produce SYSMIS given any SYSMIS
argument. */
else
return expr_allocate_boolean (e, SYSMIS);
}
else
return expr_allocate_boolean (e, SYSMIS);
}
- else if (!nonconst_cnt && (op->flags & OPF_NONOPTIMIZABLE) == 0)
+ else if (!n_nonconst && (op->flags & OPF_NONOPTIMIZABLE) == 0)
{
/* Evaluate constant expressions. */
return evaluate_tree (&node->composite, e);
{
/* Evaluate constant expressions. */
return evaluate_tree (&node->composite, e);
static double get_number_arg (struct composite_node *, size_t arg_idx);
static double *get_number_args (struct composite_node *,
static double get_number_arg (struct composite_node *, size_t arg_idx);
static double *get_number_args (struct composite_node *,
- size_t arg_idx, size_t arg_cnt,
+ size_t arg_idx, size_t n_args,
struct expression *);
static struct substring get_string_arg (struct composite_node *,
size_t arg_idx);
static struct substring *get_string_args (struct composite_node *,
struct expression *);
static struct substring get_string_arg (struct composite_node *,
size_t arg_idx);
static struct substring *get_string_args (struct composite_node *,
- size_t arg_idx, size_t arg_cnt,
+ size_t arg_idx, size_t n_args,
struct expression *);
static const struct fmt_spec *get_format_arg (struct composite_node *,
size_t arg_idx);
struct expression *);
static const struct fmt_spec *get_format_arg (struct composite_node *,
size_t arg_idx);
static double
get_number_arg (struct composite_node *c, size_t arg_idx)
{
static double
get_number_arg (struct composite_node *c, size_t arg_idx)
{
- assert (arg_idx < c->arg_cnt);
+ assert (arg_idx < c->n_args);
assert (c->args[arg_idx]->type == OP_number
|| c->args[arg_idx]->type == OP_boolean);
return c->args[arg_idx]->number.n;
}
static double *
assert (c->args[arg_idx]->type == OP_number
|| c->args[arg_idx]->type == OP_boolean);
return c->args[arg_idx]->number.n;
}
static double *
-get_number_args (struct composite_node *c, size_t arg_idx, size_t arg_cnt,
+get_number_args (struct composite_node *c, size_t arg_idx, size_t n_args,
struct expression *e)
{
double *d;
size_t i;
struct expression *e)
{
double *d;
size_t i;
- d = pool_alloc (e->expr_pool, sizeof *d * arg_cnt);
- for (i = 0; i < arg_cnt; i++)
+ d = pool_alloc (e->expr_pool, sizeof *d * n_args);
+ for (i = 0; i < n_args; i++)
d[i] = get_number_arg (c, i + arg_idx);
return d;
}
d[i] = get_number_arg (c, i + arg_idx);
return d;
}
static struct substring
get_string_arg (struct composite_node *c, size_t arg_idx)
{
static struct substring
get_string_arg (struct composite_node *c, size_t arg_idx)
{
- assert (arg_idx < c->arg_cnt);
+ assert (arg_idx < c->n_args);
assert (c->args[arg_idx]->type == OP_string);
return c->args[arg_idx]->string.s;
}
static struct substring *
assert (c->args[arg_idx]->type == OP_string);
return c->args[arg_idx]->string.s;
}
static struct substring *
-get_string_args (struct composite_node *c, size_t arg_idx, size_t arg_cnt,
+get_string_args (struct composite_node *c, size_t arg_idx, size_t n_args,
struct expression *e)
{
struct substring *s;
size_t i;
struct expression *e)
{
struct substring *s;
size_t i;
- s = pool_alloc (e->expr_pool, sizeof *s * arg_cnt);
- for (i = 0; i < arg_cnt; i++)
+ s = pool_alloc (e->expr_pool, sizeof *s * n_args);
+ for (i = 0; i < n_args; i++)
s[i] = get_string_arg (c, i + arg_idx);
return s;
}
s[i] = get_string_arg (c, i + arg_idx);
return s;
}
static const struct fmt_spec *
get_format_arg (struct composite_node *c, size_t arg_idx)
{
static const struct fmt_spec *
get_format_arg (struct composite_node *c, size_t arg_idx)
{
- assert (arg_idx < c->arg_cnt);
+ assert (arg_idx < c->n_args);
assert (c->args[arg_idx]->type == OP_ni_format
|| c->args[arg_idx]->type == OP_no_format);
return &c->args[arg_idx]->format.f;
assert (c->args[arg_idx]->type == OP_ni_format
|| c->args[arg_idx]->type == OP_no_format);
return &c->args[arg_idx]->format.f;
const struct operation *op = &operations[n->type];
size_t i;
const struct operation *op = &operations[n->type];
size_t i;
- for (i = 0; i < n->composite.arg_cnt; i++)
+ for (i = 0; i < n->composite.n_args; i++)
flatten_node (n->composite.args[i], e);
if (n->type != OP_BOOLEAN_TO_NUM)
emit_operation (e, n->type);
flatten_node (n->composite.args[i], e);
if (n->type != OP_BOOLEAN_TO_NUM)
emit_operation (e, n->type);
- for (i = 0; i < n->composite.arg_cnt; i++)
+ for (i = 0; i < n->composite.n_args; i++)
{
union any_node *arg = n->composite.args[i];
switch (arg->type)
{
union any_node *arg = n->composite.args[i];
switch (arg->type)
}
if (op->flags & OPF_ARRAY_OPERAND)
}
if (op->flags & OPF_ARRAY_OPERAND)
- emit_integer (e, n->composite.arg_cnt - op->arg_cnt + 1);
+ emit_integer (e, n->composite.n_args - op->n_args + 1);
if (op->flags & OPF_MIN_VALID)
emit_integer (e, n->composite.min_valid);
}
if (op->flags & OPF_MIN_VALID)
emit_integer (e, n->composite.min_valid);
}
static union operation_data *
allocate_aux (struct expression *e, operation_type type)
{
static union operation_data *
allocate_aux (struct expression *e, operation_type type)
{
- if (e->op_cnt >= e->op_cap)
+ if (e->n_ops >= e->allocated_ops)
- e->op_cap = (e->op_cap + 8) * 3 / 2;
- e->ops = pool_realloc (e->expr_pool, e->ops, sizeof *e->ops * e->op_cap);
+ e->allocated_ops = (e->allocated_ops + 8) * 3 / 2;
+ e->ops = pool_realloc (e->expr_pool, e->ops,
+ sizeof *e->ops * e->allocated_ops);
e->op_types = pool_realloc (e->expr_pool, e->op_types,
e->op_types = pool_realloc (e->expr_pool, e->op_types,
- sizeof *e->op_types * e->op_cap);
+ sizeof *e->op_types * e->allocated_ops);
- e->op_types[e->op_cnt] = type;
- return &e->ops[e->op_cnt++];
+ e->op_types[e->n_ops] = type;
+ return &e->ops[e->n_ops++];
- for (i = 0; i < n->composite.arg_cnt; i++)
+ for (i = 0; i < n->composite.n_args; i++)
measure_stack (n->composite.args[i], &args, max);
return_height = atom_type_stack (operations[n->type].returns);
measure_stack (n->composite.args[i], &args, max);
return_height = atom_type_stack (operations[n->type].returns);
On failure, returns false and, if OPERATOR is non-null, sets
*OPERATOR to a null pointer. */
static bool
On failure, returns false and, if OPERATOR is non-null, sets
*OPERATOR to a null pointer. */
static bool
-match_operator (struct lexer *lexer, const struct operator ops[], size_t op_cnt,
+match_operator (struct lexer *lexer, const struct operator ops[], size_t n_ops,
const struct operator **operator)
{
const struct operator *op;
const struct operator **operator)
{
const struct operator *op;
- for (op = ops; op < ops + op_cnt; op++)
+ for (op = ops; op < ops + n_ops; op++)
if (lex_token (lexer) == op->token)
{
if (op->token != T_NEG_NUM)
if (lex_token (lexer) == op->token)
{
if (op->token != T_NEG_NUM)
-check_operator (const struct operator *op, int arg_cnt, atom_type arg_type)
+check_operator (const struct operator *op, int n_args, atom_type arg_type)
{
const struct operation *o;
size_t i;
assert (op != NULL);
o = &operations[op->type];
{
const struct operation *o;
size_t i;
assert (op != NULL);
o = &operations[op->type];
- assert (o->arg_cnt == arg_cnt);
+ assert (o->n_args == n_args);
assert ((o->flags & OPF_ARRAY_OPERAND) == 0);
assert ((o->flags & OPF_ARRAY_OPERAND) == 0);
- for (i = 0; i < arg_cnt; i++)
+ for (i = 0; i < n_args; i++)
assert (is_compatible (arg_type, o->args[i]));
return true;
}
static bool
assert (is_compatible (arg_type, o->args[i]));
return true;
}
static bool
-check_binary_operators (const struct operator ops[], size_t op_cnt,
+check_binary_operators (const struct operator ops[], size_t n_ops,
atom_type arg_type)
{
size_t i;
atom_type arg_type)
{
size_t i;
- for (i = 0; i < op_cnt; i++)
+ for (i = 0; i < n_ops; i++)
check_operator (&ops[i], 2, arg_type);
return true;
}
check_operator (&ops[i], 2, arg_type);
return true;
}
one operator/operand pair is parsed. */
static union any_node *
parse_binary_operators (struct lexer *lexer, struct expression *e, union any_node *node,
one operator/operand pair is parsed. */
static union any_node *
parse_binary_operators (struct lexer *lexer, struct expression *e, union any_node *node,
- const struct operator ops[], size_t op_cnt,
+ const struct operator ops[], size_t n_ops,
parse_recursively_func *parse_next_level,
const char *chain_warning)
{
parse_recursively_func *parse_next_level,
const char *chain_warning)
{
int op_count;
const struct operator *operator;
int op_count;
const struct operator *operator;
- assert (check_binary_operators (ops, op_cnt, operand_type));
+ assert (check_binary_operators (ops, n_ops, operand_type));
if (node == NULL)
return node;
if (node == NULL)
return node;
- for (op_count = 0; match_operator (lexer, ops, op_cnt, &operator); op_count++)
+ for (op_count = 0; match_operator (lexer, ops, n_ops, &operator); op_count++)
\f
/* Individual function parsing. */
\f
/* Individual function parsing. */
-const struct operation operations[OP_first + OP_cnt] = {
+const struct operation operations[OP_first + n_OP] = {
static atom_type
function_arg_type (const struct operation *f, size_t arg_idx)
{
static atom_type
function_arg_type (const struct operation *f, size_t arg_idx)
{
- assert (arg_idx < f->arg_cnt || (f->flags & OPF_ARRAY_OPERAND));
+ assert (arg_idx < f->n_args || (f->flags & OPF_ARRAY_OPERAND));
- return f->args[arg_idx < f->arg_cnt ? arg_idx : f->arg_cnt - 1];
+ return f->args[arg_idx < f->n_args ? arg_idx : f->n_args - 1];
-match_function (union any_node **args, int arg_cnt, const struct operation *f)
+match_function (union any_node **args, int n_args, const struct operation *f)
- if (arg_cnt < f->arg_cnt
- || (arg_cnt > f->arg_cnt && (f->flags & OPF_ARRAY_OPERAND) == 0)
- || arg_cnt - (f->arg_cnt - 1) < f->array_min_elems)
+ if (n_args < f->n_args
+ || (n_args > f->n_args && (f->flags & OPF_ARRAY_OPERAND) == 0)
+ || n_args - (f->n_args - 1) < f->array_min_elems)
- for (i = 0; i < arg_cnt; i++)
+ for (i = 0; i < n_args; i++)
if (!is_coercible (function_arg_type (f, i), &args[i]))
return false;
if (!is_coercible (function_arg_type (f, i), &args[i]))
return false;
static void
coerce_function_args (struct expression *e, const struct operation *f,
static void
coerce_function_args (struct expression *e, const struct operation *f,
- union any_node **args, size_t arg_cnt)
+ union any_node **args, size_t n_args)
- for (i = 0; i < arg_cnt; i++)
+ for (i = 0; i < n_args; i++)
type_coercion_assert (e, function_arg_type (f, i), &args[i]);
}
static bool
type_coercion_assert (e, function_arg_type (f, i), &args[i]);
}
static bool
-validate_function_args (const struct operation *f, int arg_cnt, int min_valid)
+validate_function_args (const struct operation *f, int n_args, int min_valid)
{
/* Count the function arguments that go into the trailing array (if any). We
know that there must be at least the minimum number because
match_function() already checked. */
{
/* Count the function arguments that go into the trailing array (if any). We
know that there must be at least the minimum number because
match_function() already checked. */
- int array_arg_cnt = arg_cnt - (f->arg_cnt - 1);
- assert (array_arg_cnt >= f->array_min_elems);
+ int array_n_args = n_args - (f->n_args - 1);
+ assert (array_n_args >= f->array_min_elems);
if ((f->flags & OPF_ARRAY_OPERAND)
if ((f->flags & OPF_ARRAY_OPERAND)
- && array_arg_cnt % f->array_granularity != 0)
+ && array_n_args % f->array_granularity != 0)
{
/* RANGE is the only case we have so far. It has paired arguments with
one initial argument, and that's the only special case we deal with
here. */
assert (f->array_granularity == 2);
{
/* RANGE is the only case we have so far. It has paired arguments with
one initial argument, and that's the only special case we deal with
here. */
assert (f->array_granularity == 2);
- assert (arg_cnt % 2 == 0);
+ assert (n_args % 2 == 0);
msg (SE, _("%s must have an odd number of arguments."), f->prototype);
return false;
}
msg (SE, _("%s must have an odd number of arguments."), f->prototype);
return false;
}
else
{
assert (f->flags & OPF_MIN_VALID);
else
{
assert (f->flags & OPF_MIN_VALID);
- if (min_valid > array_arg_cnt)
+ if (min_valid > array_n_args)
{
msg (SE, _("For %s with %d arguments, at most %d (not %d) may be "
"required to be valid."),
{
msg (SE, _("For %s with %d arguments, at most %d (not %d) may be "
"required to be valid."),
- f->prototype, arg_cnt, array_arg_cnt, min_valid);
+ f->prototype, n_args, array_n_args, min_valid);
-add_arg (union any_node ***args, int *arg_cnt, int *arg_cap,
+add_arg (union any_node ***args, int *n_args, int *allocated_args,
- if (*arg_cnt >= *arg_cap)
+ if (*n_args >= *allocated_args)
- *arg_cap += 8;
- *args = xrealloc (*args, sizeof **args * *arg_cap);
+ *allocated_args += 8;
+ *args = xrealloc (*args, sizeof **args * *allocated_args);
- (*args)[(*arg_cnt)++] = arg;
+ (*args)[(*n_args)++] = arg;
}
static void
put_invocation (struct string *s,
}
static void
put_invocation (struct string *s,
- const char *func_name, union any_node **args, size_t arg_cnt)
+ const char *func_name, union any_node **args, size_t n_args)
{
size_t i;
ds_put_format (s, "%s(", func_name);
{
size_t i;
ds_put_format (s, "%s(", func_name);
- for (i = 0; i < arg_cnt; i++)
+ for (i = 0; i < n_args; i++)
{
if (i > 0)
ds_put_cstr (s, ", ");
{
if (i > 0)
ds_put_cstr (s, ", ");
static void
no_match (const char *func_name,
static void
no_match (const char *func_name,
- union any_node **args, size_t arg_cnt,
+ union any_node **args, size_t n_args,
const struct operation *first, const struct operation *last)
{
struct string s;
const struct operation *first, const struct operation *last)
{
struct string s;
if (last - first == 1)
{
ds_put_format (&s, _("Type mismatch invoking %s as "), first->prototype);
if (last - first == 1)
{
ds_put_format (&s, _("Type mismatch invoking %s as "), first->prototype);
- put_invocation (&s, func_name, args, arg_cnt);
+ put_invocation (&s, func_name, args, n_args);
}
else
{
ds_put_cstr (&s, _("Function invocation "));
}
else
{
ds_put_cstr (&s, _("Function invocation "));
- put_invocation (&s, func_name, args, arg_cnt);
+ put_invocation (&s, func_name, args, n_args);
ds_put_cstr (&s, _(" does not match any known function. Candidates are:"));
for (f = first; f < last; f++)
ds_put_cstr (&s, _(" does not match any known function. Candidates are:"));
for (f = first; f < last; f++)
const struct operation *f, *first, *last;
union any_node **args = NULL;
const struct operation *f, *first, *last;
union any_node **args = NULL;
- int arg_cnt = 0;
- int arg_cap = 0;
+ int n_args = 0;
+ int allocated_args = 0;
+ n_args = allocated_args = 0;
if (lex_token (lexer) != T_RPAREN)
for (;;)
{
if (lex_token (lexer) != T_RPAREN)
for (;;)
{
&& lex_next_token (lexer, 1) == T_TO)
{
const struct variable **vars;
&& lex_next_token (lexer, 1) == T_TO)
{
const struct variable **vars;
- if (!parse_variables_const (lexer, dataset_dict (e->ds), &vars, &var_cnt, PV_SINGLE))
+ if (!parse_variables_const (lexer, dataset_dict (e->ds), &vars, &n_vars, PV_SINGLE))
- for (i = 0; i < var_cnt; i++)
- add_arg (&args, &arg_cnt, &arg_cap,
+ for (i = 0; i < n_vars; i++)
+ add_arg (&args, &n_args, &allocated_args,
allocate_unary_variable (e, vars[i]));
free (vars);
}
allocate_unary_variable (e, vars[i]));
free (vars);
}
if (arg == NULL)
goto fail;
if (arg == NULL)
goto fail;
- add_arg (&args, &arg_cnt, &arg_cap, arg);
+ add_arg (&args, &n_args, &allocated_args, arg);
}
if (lex_match (lexer, T_RPAREN))
break;
}
if (lex_match (lexer, T_RPAREN))
break;
}
for (f = first; f < last; f++)
}
for (f = first; f < last; f++)
- if (match_function (args, arg_cnt, f))
+ if (match_function (args, n_args, f))
- no_match (ds_cstr (&func_name), args, arg_cnt, first, last);
+ no_match (ds_cstr (&func_name), args, n_args, first, last);
- coerce_function_args (e, f, args, arg_cnt);
- if (!validate_function_args (f, arg_cnt, min_valid))
+ coerce_function_args (e, f, args, n_args);
+ if (!validate_function_args (f, n_args, min_valid))
goto fail;
if ((f->flags & OPF_EXTENSION) && settings_get_syntax () == COMPATIBLE)
goto fail;
if ((f->flags & OPF_EXTENSION) && settings_get_syntax () == COMPATIBLE)
- n = expr_allocate_composite (e, f - operations, args, arg_cnt);
+ n = expr_allocate_composite (e, f - operations, args, n_args);
n->composite.min_valid = min_valid != -1 ? min_valid : f->array_min_elems;
if (n->type == OP_LAG_Vn || n->type == OP_LAG_Vs)
n->composite.min_valid = min_valid != -1 ? min_valid : f->array_min_elems;
if (n->type == OP_LAG_Vn || n->type == OP_LAG_Vs)
else if (n->type == OP_LAG_Vnn || n->type == OP_LAG_Vsn)
{
int n_before;
else if (n->type == OP_LAG_Vnn || n->type == OP_LAG_Vsn)
{
int n_before;
- assert (n->composite.arg_cnt == 2);
+ assert (n->composite.n_args == 2);
assert (n->composite.args[1]->type == OP_pos_int);
n_before = n->composite.args[1]->integer.i;
dataset_need_lag (e->ds, n_before);
assert (n->composite.args[1]->type == OP_pos_int);
n_before = n->composite.args[1]->integer.i;
dataset_need_lag (e->ds, n_before);
e->eval_pool = pool_create_subpool (e->expr_pool);
e->ops = NULL;
e->op_types = NULL;
e->eval_pool = pool_create_subpool (e->expr_pool);
e->ops = NULL;
e->op_types = NULL;
- e->op_cnt = e->op_cap = 0;
+ e->n_ops = e->allocated_ops = 0;
struct composite_node *c = &n->composite;
assert (is_composite (n->type));
struct composite_node *c = &n->composite;
assert (is_composite (n->type));
- assert (c->arg_cnt >= op->arg_cnt);
- for (i = 0; i < op->arg_cnt; i++)
+ assert (c->n_args >= op->n_args);
+ for (i = 0; i < op->n_args; i++)
assert (is_compatible (op->args[i], expr_node_returns (c->args[i])));
assert (is_compatible (op->args[i], expr_node_returns (c->args[i])));
- if (c->arg_cnt > op->arg_cnt && !is_operator (n->type))
+ if (c->n_args > op->n_args && !is_operator (n->type))
{
assert (op->flags & OPF_ARRAY_OPERAND);
{
assert (op->flags & OPF_ARRAY_OPERAND);
- for (i = 0; i < c->arg_cnt; i++)
- assert (is_compatible (op->args[op->arg_cnt - 1],
+ for (i = 0; i < c->n_args; i++)
+ assert (is_compatible (op->args[op->n_args - 1],
expr_node_returns (c->args[i])));
}
}
expr_node_returns (c->args[i])));
}
}
union any_node *
expr_allocate_composite (struct expression *e, operation_type op,
union any_node *
expr_allocate_composite (struct expression *e, operation_type op,
- union any_node **args, size_t arg_cnt)
+ union any_node **args, size_t n_args)
{
union any_node *n;
size_t i;
n = pool_alloc (e->expr_pool, sizeof n->composite);
n->type = op;
{
union any_node *n;
size_t i;
n = pool_alloc (e->expr_pool, sizeof n->composite);
n->type = op;
- n->composite.arg_cnt = arg_cnt;
+ n->composite.n_args = n_args;
n->composite.args = pool_alloc (e->expr_pool,
n->composite.args = pool_alloc (e->expr_pool,
- sizeof *n->composite.args * arg_cnt);
- for (i = 0; i < arg_cnt; i++)
+ sizeof *n->composite.args * n_args);
+ for (i = 0; i < n_args; i++)
{
if (args[i] == NULL)
return NULL;
n->composite.args[i] = args[i];
}
{
if (args[i] == NULL)
return NULL;
n->composite.args[i] = args[i];
}
- memcpy (n->composite.args, args, sizeof *n->composite.args * arg_cnt);
+ memcpy (n->composite.args, args, sizeof *n->composite.args * n_args);
n->composite.min_valid = 0;
assert (is_valid_node (n));
return n;
n->composite.min_valid = 0;
assert (is_valid_node (n));
return n;
const struct operation *
expr_get_function (size_t idx)
{
const struct operation *
expr_get_function (size_t idx)
{
- assert (idx < OP_function_cnt);
+ assert (idx < n_OP_function);
return &operations[OP_function_first + idx];
}
/* Returns the number of expression functions. */
size_t
return &operations[OP_function_first + idx];
}
/* Returns the number of expression functions. */
size_t
-expr_get_function_cnt (void)
+expr_get_n_functions (void)
- return OP_function_cnt;
}
/* Returns the name of operation OP. */
}
/* Returns the name of operation OP. */
/* Returns the number of arguments for operation OP. */
int
/* Returns the number of arguments for operation OP. */
int
-expr_operation_get_arg_cnt (const struct operation *op)
+expr_operation_get_n_args (const struct operation *op)
const char *prototype;
enum operation_flags flags;
atom_type returns;
const char *prototype;
enum operation_flags flags;
atom_type returns;
atom_type args[EXPR_ARG_MAX];
int array_min_elems;
int array_granularity;
atom_type args[EXPR_ARG_MAX];
int array_min_elems;
int array_granularity;
struct composite_node
{
operation_type type; /* One of OP_*. */
struct composite_node
{
operation_type type; /* One of OP_*. */
- size_t arg_cnt; /* Number of arguments. */
- union any_node **args; /* Arguments. */
- size_t min_valid; /* Min valid array args to get valid result. */
+ size_t n_args; /* Number of arguments. */
+ union any_node **args; /* Arguments. */
+ size_t min_valid; /* Min valid array args to get valid result. */
union operation_data *ops; /* Expression data. */
operation_type *op_types; /* ops[] element types (for debugging). */
union operation_data *ops; /* Expression data. */
operation_type *op_types; /* ops[] element types (for debugging). */
- size_t op_cnt, op_cap; /* Number of ops, amount of allocated space. */
+ size_t n_ops, allocated_ops; /* Number of ops, amount of allocated space. */
double *number_stack; /* Evaluation stack: numerics, Booleans. */
struct substring *string_stack; /* Evaluation stack: strings. */
double *number_stack; /* Evaluation stack: numerics, Booleans. */
struct substring *string_stack; /* Evaluation stack: strings. */
int case_idx, char *dst, size_t dst_size);
const struct operation *expr_get_function (size_t idx);
int case_idx, char *dst, size_t dst_size);
const struct operation *expr_get_function (size_t idx);
-size_t expr_get_function_cnt (void);
+size_t expr_get_n_functions (void);
const char *expr_operation_get_name (const struct operation *);
const char *expr_operation_get_prototype (const struct operation *);
const char *expr_operation_get_name (const struct operation *);
const char *expr_operation_get_prototype (const struct operation *);
-int expr_operation_get_arg_cnt (const struct operation *);
+int expr_operation_get_n_args (const struct operation *);
// Try each possible command.
command_matcher_init (&cm, string);
// Try each possible command.
command_matcher_init (&cm, string);
- for (cmd = commands; cmd < &commands[command_cnt]; cmd++)
+ for (cmd = commands; cmd < &commands[n_commands]; cmd++)
command_matcher_add (&cm, cmd->name, cmd);
// Get the result.
command_matcher_add (&cm, cmd->name, cmd);
// Get the result.
assert (cnt != NULL);
vs = var_set_create_from_dict (d);
assert (cnt != NULL);
vs = var_set_create_from_dict (d);
- if (var_set_get_cnt (vs) == 0)
+ if (var_set_get_n (vs) == 0)
{
*cnt = 0;
var_set_destroy (vs);
{
*cnt = 0;
var_set_destroy (vs);
/* Parses a set of variables from dictionary D given options
OPTS. Resulting list of variables stored in *VARS and the
/* Parses a set of variables from dictionary D given options
OPTS. Resulting list of variables stored in *VARS and the
- number of variables into *VAR_CNT. Returns true only if
+ number of variables into *N_VARS. Returns true only if
successful. Same behavior as parse_variables, except that all
allocations are taken from the given POOL. */
bool
parse_variables_pool (struct lexer *lexer, struct pool *pool,
const struct dictionary *dict,
successful. Same behavior as parse_variables, except that all
allocations are taken from the given POOL. */
bool
parse_variables_pool (struct lexer *lexer, struct pool *pool,
const struct dictionary *dict,
- struct variable ***vars, size_t *var_cnt, int opts)
+ struct variable ***vars, size_t *n_vars, int opts)
later. */
assert (!(opts & PV_APPEND));
later. */
assert (!(opts & PV_APPEND));
- retval = parse_variables (lexer, dict, vars, var_cnt, opts);
+ retval = parse_variables (lexer, dict, vars, n_vars, opts);
if (retval)
pool_register (pool, free, *vars);
return retval;
if (retval)
pool_register (pool, free, *vars);
return retval;
- included = xcalloc (var_set_get_cnt (vs), sizeof *included);
+ included = xcalloc (var_set_get_n (vs), sizeof *included);
for (i = 0; i < *nv; i++)
{
size_t index;
for (i = 0; i < *nv; i++)
{
size_t index;
{
if (lex_match (lexer, T_ALL))
add_variables (v, nv, &mv, included, pv_opts,
{
if (lex_match (lexer, T_ALL))
add_variables (v, nv, &mv, included, pv_opts,
- vs, 0, var_set_get_cnt (vs) - 1, DC_ORDINARY);
+ vs, 0, var_set_get_n (vs) - 1, DC_ORDINARY);
else
{
enum dict_class class;
else
{
enum dict_class class;
struct var_set
{
bool names_must_be_ids;
struct var_set
{
bool names_must_be_ids;
- size_t (*get_cnt) (const struct var_set *);
+ size_t (*get_n) (const struct var_set *);
struct variable *(*get_var) (const struct var_set *, size_t idx);
bool (*lookup_var_idx) (const struct var_set *, const char *, size_t *);
void (*destroy) (struct var_set *);
struct variable *(*get_var) (const struct var_set *, size_t idx);
bool (*lookup_var_idx) (const struct var_set *, const char *, size_t *);
void (*destroy) (struct var_set *);
/* Returns the number of variables in VS. */
size_t
/* Returns the number of variables in VS. */
size_t
-var_set_get_cnt (const struct var_set *vs)
+var_set_get_n (const struct var_set *vs)
- return vs->get_cnt (vs);
}
/* Return variable with index IDX in VS.
}
/* Return variable with index IDX in VS.
var_set_get_var (const struct var_set *vs, size_t idx)
{
assert (vs != NULL);
var_set_get_var (const struct var_set *vs, size_t idx)
{
assert (vs != NULL);
- assert (idx < var_set_get_cnt (vs));
+ assert (idx < var_set_get_n (vs));
return vs->get_var (vs, idx);
}
return vs->get_var (vs, idx);
}
\f
/* Returns the number of variables in VS. */
static size_t
\f
/* Returns the number of variables in VS. */
static size_t
-dict_var_set_get_cnt (const struct var_set *vs)
+dict_var_set_get_n (const struct var_set *vs)
{
struct dictionary *d = vs->aux;
{
struct dictionary *d = vs->aux;
- return dict_get_var_cnt (d);
+ return dict_get_n_vars (d);
}
/* Return variable with index IDX in VS.
}
/* Return variable with index IDX in VS.
{
struct var_set *vs = xmalloc (sizeof *vs);
vs->names_must_be_ids = dict_get_names_must_be_ids (d);
{
struct var_set *vs = xmalloc (sizeof *vs);
vs->names_must_be_ids = dict_get_names_must_be_ids (d);
- vs->get_cnt = dict_var_set_get_cnt;
+ vs->get_n = dict_var_set_get_n;
vs->get_var = dict_var_set_get_var;
vs->lookup_var_idx = dict_var_set_lookup_var_idx;
vs->destroy = dict_var_set_destroy;
vs->get_var = dict_var_set_get_var;
vs->lookup_var_idx = dict_var_set_lookup_var_idx;
vs->destroy = dict_var_set_destroy;
struct array_var_set
{
struct variable *const *var;/* Array of variables. */
struct array_var_set
{
struct variable *const *var;/* Array of variables. */
- size_t var_cnt; /* Number of elements in var. */
+ size_t n_vars; /* Number of elements in var. */
struct hmapx vars_by_name; /* Variables hashed by name. */
};
/* Returns the number of variables in VS. */
static size_t
struct hmapx vars_by_name; /* Variables hashed by name. */
};
/* Returns the number of variables in VS. */
static size_t
-array_var_set_get_cnt (const struct var_set *vs)
+array_var_set_get_n (const struct var_set *vs)
{
struct array_var_set *avs = vs->aux;
{
struct array_var_set *avs = vs->aux;
}
/* Return variable with index IDX in VS.
}
/* Return variable with index IDX in VS.
-/* Returns a variable set based on the VAR_CNT variables in VAR. */
+/* Returns a variable set based on the N_VARS variables in VAR. */
-var_set_create_from_array (struct variable *const *var, size_t var_cnt)
+var_set_create_from_array (struct variable *const *var, size_t n_vars)
{
struct var_set *vs;
struct array_var_set *avs;
{
struct var_set *vs;
struct array_var_set *avs;
vs = xmalloc (sizeof *vs);
vs->names_must_be_ids = true;
vs = xmalloc (sizeof *vs);
vs->names_must_be_ids = true;
- vs->get_cnt = array_var_set_get_cnt;
+ vs->get_n = array_var_set_get_n;
vs->get_var = array_var_set_get_var;
vs->lookup_var_idx = array_var_set_lookup_var_idx;
vs->destroy = array_var_set_destroy;
vs->aux = avs = xmalloc (sizeof *avs);
avs->var = var;
vs->get_var = array_var_set_get_var;
vs->lookup_var_idx = array_var_set_lookup_var_idx;
vs->destroy = array_var_set_destroy;
vs->aux = avs = xmalloc (sizeof *avs);
avs->var = var;
- avs->var_cnt = var_cnt;
hmapx_init (&avs->vars_by_name);
hmapx_init (&avs->vars_by_name);
- for (i = 0; i < var_cnt; i++)
+ for (i = 0; i < n_vars; i++)
{
const char *name = var_get_name (var[i]);
size_t idx;
{
const char *name = var_get_name (var[i]);
size_t idx;
struct var_set *var_set_create_from_array (struct variable *const *var,
size_t);
struct var_set *var_set_create_from_array (struct variable *const *var,
size_t);
-size_t var_set_get_cnt (const struct var_set *vs);
+size_t var_set_get_n (const struct var_set *vs);
void var_set_destroy (struct var_set *vs);
void var_set_destroy (struct var_set *vs);
/* Break variables. */
struct subcase sort; /* Sort criteria (break variables). */
const struct variable **break_vars; /* Break variables. */
/* Break variables. */
struct subcase sort; /* Sort criteria (break variables). */
const struct variable **break_vars; /* Break variables. */
- size_t break_var_cnt; /* Number of break variables. */
+ size_t break_n_vars; /* Number of break variables. */
enum missing_treatment missing; /* How to treat missing values. */
struct agr_var *agr_vars; /* First aggregate variable. */
struct dictionary *dict; /* Aggregate dictionary. */
const struct dictionary *src_dict; /* Dict of the source */
enum missing_treatment missing; /* How to treat missing values. */
struct agr_var *agr_vars; /* First aggregate variable. */
struct dictionary *dict; /* Aggregate dictionary. */
const struct dictionary *src_dict; /* Dict of the source */
- int case_cnt; /* Counts aggregated cases. */
+ int n_cases; /* Counts aggregated cases. */
bool add_variables; /* True iff the aggregated variables should
be appended to the existing dictionary */
bool add_variables; /* True iff the aggregated variables should
be appended to the existing dictionary */
if (!parse_sort_criteria (lexer, dict, &agr.sort, &agr.break_vars,
&saw_direction))
goto error;
if (!parse_sort_criteria (lexer, dict, &agr.sort, &agr.break_vars,
&saw_direction))
goto error;
- agr.break_var_cnt = subcase_get_n_fields (&agr.sort);
+ agr.break_n_vars = subcase_get_n_fields (&agr.sort);
- for (i = 0; i < agr.break_var_cnt; i++)
+ for (i = 0; i < agr.break_n_vars; i++)
dict_clone_var_assert (agr.dict, agr.break_vars[i]);
/* BREAK must follow the options. */
dict_clone_var_assert (agr.dict, agr.break_vars[i]);
/* BREAK must follow the options. */
dict_set_split_vars (agr.dict, NULL, 0);
/* Initialize. */
dict_set_split_vars (agr.dict, NULL, 0);
/* Initialize. */
}
for (grouper = casegrouper_create_vars (input, agr.break_vars,
}
for (grouper = casegrouper_create_vars (input, agr.break_vars,
casegrouper_get_next_group (grouper, &group);
casereader_destroy (group))
{
casegrouper_get_next_group (grouper, &group);
casereader_destroy (group))
{
if (agr->add_variables)
{
if (agr->add_variables)
{
- case_copy (c, 0, break_case, 0, dict_get_var_cnt (agr->src_dict));
+ case_copy (c, 0, break_case, 0, dict_get_n_vars (agr->src_dict));
}
else
{
int value_idx = 0;
int i;
}
else
{
int value_idx = 0;
int i;
- for (i = 0; i < agr->break_var_cnt; i++)
+ for (i = 0; i < agr->break_n_vars; i++)
{
const struct variable *v = agr->break_vars[i];
value_copy (case_data_rw_idx (c, value_idx),
{
const struct variable *v = agr->break_vars[i];
value_copy (case_data_rw_idx (c, value_idx),
struct dsc_trns
{
struct dsc_z_score *z_scores; /* Array of Z-scores. */
struct dsc_trns
{
struct dsc_z_score *z_scores; /* Array of Z-scores. */
- int z_score_cnt; /* Number of Z-scores. */
+ int n_z_scores; /* Number of Z-scores. */
const struct variable **vars; /* Variables for listwise missing checks. */
const struct variable **vars; /* Variables for listwise missing checks. */
- size_t var_cnt; /* Number of variables. */
+ size_t n_vars; /* Number of variables. */
enum dsc_missing_type missing_type; /* Treatment of missing values. */
enum mv_class exclude; /* Classes of missing values to exclude. */
const struct variable *filter; /* Dictionary FILTER BY variable. */
enum dsc_missing_type missing_type; /* Treatment of missing values. */
enum mv_class exclude; /* Classes of missing values to exclude. */
const struct variable *filter; /* Dictionary FILTER BY variable. */
/* Per-variable info. */
struct dictionary *dict; /* Dictionary. */
struct dsc_var *vars; /* Variables. */
/* Per-variable info. */
struct dictionary *dict; /* Dictionary. */
struct dsc_var *vars; /* Variables. */
- size_t var_cnt; /* Number of variables. */
+ size_t n_vars; /* Number of variables. */
/* User options. */
enum dsc_missing_type missing_type; /* Treatment of missing values. */
/* User options. */
enum dsc_missing_type missing_type; /* Treatment of missing values. */
struct dsc_proc *dsc, const char *name);
static char *generate_z_varname (const struct dictionary *dict,
struct dsc_proc *dsc,
struct dsc_proc *dsc, const char *name);
static char *generate_z_varname (const struct dictionary *dict,
struct dsc_proc *dsc,
- const char *name, int *z_cnt);
+ const char *name, int *n_zs);
static void dump_z_table (struct dsc_proc *);
static void setup_z_trns (struct dsc_proc *, struct dataset *);
static void dump_z_table (struct dsc_proc *);
static void setup_z_trns (struct dsc_proc *, struct dataset *);
struct dictionary *dict = dataset_dict (ds);
struct dsc_proc *dsc;
const struct variable **vars = NULL;
struct dictionary *dict = dataset_dict (ds);
struct dsc_proc *dsc;
const struct variable **vars = NULL;
dsc = xmalloc (sizeof *dsc);
dsc->dict = dict;
dsc->vars = NULL;
dsc = xmalloc (sizeof *dsc);
dsc->dict = dict;
dsc->vars = NULL;
dsc->missing_type = DSC_VARIABLE;
dsc->exclude = MV_ANY;
dsc->missing_listwise = 0.;
dsc->missing_type = DSC_VARIABLE;
dsc->exclude = MV_ANY;
dsc->missing_listwise = 0.;
{
if (lex_next_token (lexer, 1) == T_EQUALS)
{
{
if (lex_next_token (lexer, 1) == T_EQUALS)
{
- if (!parse_variables_const (lexer, dict, &vars, &var_cnt,
+ if (!parse_variables_const (lexer, dict, &vars, &n_vars,
PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC))
goto error;
PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC))
goto error;
- dsc->vars = xnrealloc ((void *)dsc->vars, var_cnt, sizeof *dsc->vars);
- for (i = dsc->var_cnt; i < var_cnt; i++)
+ dsc->vars = xnrealloc ((void *)dsc->vars, n_vars, sizeof *dsc->vars);
+ for (i = dsc->n_vars; i < n_vars; i++)
{
struct dsc_var *dv = &dsc->vars[i];
dv->v = vars[i];
dv->z_name = NULL;
dv->moments = NULL;
}
{
struct dsc_var *dv = &dsc->vars[i];
dv->v = vars[i];
dv->z_name = NULL;
dv->moments = NULL;
}
- dsc->var_cnt = var_cnt;
if (lex_match (lexer, T_LPAREN))
{
if (lex_match (lexer, T_LPAREN))
{
}
if (try_name (dict, dsc, lex_tokcstr (lexer)))
{
}
if (try_name (dict, dsc, lex_tokcstr (lexer)))
{
- struct dsc_var *dsc_var = &dsc->vars[dsc->var_cnt - 1];
+ struct dsc_var *dsc_var = &dsc->vars[dsc->n_vars - 1];
dsc_var->z_name = xstrdup (lex_tokcstr (lexer));
dsc_var->z_name = xstrdup (lex_tokcstr (lexer));
}
else
msg (SE, _("Z-score variable name %s would be"
}
else
msg (SE, _("Z-score variable name %s would be"
lex_match (lexer, T_SLASH);
}
lex_match (lexer, T_SLASH);
}
{
msg (SE, _("No variables specified."));
goto error;
}
/* Construct z-score varnames, show translation table. */
{
msg (SE, _("No variables specified."));
goto error;
}
/* Construct z-score varnames, show translation table. */
- if (z_cnt || save_z_scores)
+ if (n_zs || save_z_scores)
{
struct caseproto *proto;
if (save_z_scores)
{
{
struct caseproto *proto;
if (save_z_scores)
{
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dsc_var = &dsc->vars[i];
if (dsc_var->z_name == NULL)
{
const char *name = var_get_name (dsc_var->v);
dsc_var->z_name = generate_z_varname (dict, dsc, name,
{
struct dsc_var *dsc_var = &dsc->vars[i];
if (dsc_var->z_name == NULL)
{
const char *name = var_get_name (dsc_var->v);
dsc_var->z_name = generate_z_varname (dict, dsc, name,
if (dsc_var->z_name == NULL)
goto error;
if (dsc_var->z_name == NULL)
goto error;
"Temporary transformations will be made permanent."));
proto = caseproto_create ();
"Temporary transformations will be made permanent."));
proto = caseproto_create ();
- for (i = 0; i < 1 + 2 * z_cnt; i++)
+ for (i = 0; i < 1 + 2 * n_zs; i++)
proto = caseproto_add_width (proto, 0);
dsc->z_writer = autopaging_writer_create (proto);
caseproto_unref (proto);
proto = caseproto_add_width (proto, 0);
dsc->z_writer = autopaging_writer_create (proto);
caseproto_unref (proto);
/* Figure out which statistics to calculate. */
dsc->calc_stats = dsc->show_stats;
/* Figure out which statistics to calculate. */
dsc->calc_stats = dsc->show_stats;
dsc->calc_stats |= (1ul << DSC_MEAN) | (1ul << DSC_STDDEV);
if (dsc->sort_by_stat >= 0)
dsc->calc_stats |= 1ul << dsc->sort_by_stat;
dsc->calc_stats |= (1ul << DSC_MEAN) | (1ul << DSC_STDDEV);
if (dsc->sort_by_stat >= 0)
dsc->calc_stats |= 1ul << dsc->sort_by_stat;
if (dsc->calc_stats & (1ul << i) && dsc_info[i].moment > dsc->max_moment)
dsc->max_moment = dsc_info[i].moment;
if (dsc->max_moment != MOMENT_NONE)
if (dsc->calc_stats & (1ul << i) && dsc_info[i].moment > dsc->max_moment)
dsc->max_moment = dsc_info[i].moment;
if (dsc->max_moment != MOMENT_NONE)
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
dsc->vars[i].moments = moments_create (dsc->max_moment);
/* Data pass. */
dsc->vars[i].moments = moments_create (dsc->max_moment);
/* Data pass. */
ok = proc_commit (ds) && ok;
/* Z-scoring! */
ok = proc_commit (ds) && ok;
/* Z-scoring! */
setup_z_trns (dsc, ds);
/* Done. */
setup_z_trns (dsc, ds);
/* Done. */
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dsc_var = &dsc->vars[i];
free (dsc_var->z_name);
{
struct dsc_var *dsc_var = &dsc->vars[i];
free (dsc_var->z_name);
if (dict_lookup_var (dict, name) != NULL)
return false;
if (dict_lookup_var (dict, name) != NULL)
return false;
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dsc_var = &dsc->vars[i];
if (dsc_var->z_name != NULL && !utf8_strcasecmp (dsc_var->z_name, name))
{
struct dsc_var *dsc_var = &dsc->vars[i];
if (dsc_var->z_name != NULL && !utf8_strcasecmp (dsc_var->z_name, name))
as a dynamically allocated string. On failure, returns NULL. */
static char *
generate_z_varname (const struct dictionary *dict, struct dsc_proc *dsc,
as a dynamically allocated string. On failure, returns NULL. */
static char *
generate_z_varname (const struct dictionary *dict, struct dsc_proc *dsc,
- const char *var_name, int *z_cnt)
+ const char *var_name, int *n_zs)
{
char *z_name, *trunc_name;
{
char *z_name, *trunc_name;
- if (*z_cnt <= 99)
- sprintf (name, "ZSC%03d", *z_cnt);
- else if (*z_cnt <= 108)
- sprintf (name, "STDZ%02d", *z_cnt - 99);
- else if (*z_cnt <= 117)
- sprintf (name, "ZZZZ%02d", *z_cnt - 108);
- else if (*z_cnt <= 126)
- sprintf (name, "ZQZQ%02d", *z_cnt - 117);
+ if (*n_zs <= 99)
+ sprintf (name, "ZSC%03d", *n_zs);
+ else if (*n_zs <= 108)
+ sprintf (name, "STDZ%02d", *n_zs - 99);
+ else if (*n_zs <= 117)
+ sprintf (name, "ZZZZ%02d", *n_zs - 108);
+ else if (*n_zs <= 126)
+ sprintf (name, "ZQZQ%02d", *n_zs - 117);
else
{
msg (SE, _("Ran out of generic names for Z-score variables. "
else
{
msg (SE, _("Ran out of generic names for Z-score variables. "
table, PIVOT_AXIS_ROW, N_("Variables"));
names->hide_all_labels = true;
table, PIVOT_AXIS_ROW, N_("Variables"));
names->hide_all_labels = true;
- for (size_t i = 0; i < dsc->var_cnt; i++)
+ for (size_t i = 0; i < dsc->n_vars; i++)
if (dsc->vars[i].z_name != NULL)
{
int row = pivot_category_create_leaf (names->root,
if (dsc->vars[i].z_name != NULL)
{
int row = pivot_category_create_leaf (names->root,
{
const struct dsc_z_score *z;
{
const struct dsc_z_score *z;
- for (z = t->z_scores; z < t->z_scores + t->z_score_cnt; z++)
+ for (z = t->z_scores; z < t->z_scores + t->n_z_scores; z++)
*case_num_rw (c, z->z_var) = SYSMIS;
}
*case_num_rw (c, z->z_var) = SYSMIS;
}
size_t z_idx = 0;
t->count = case_num_idx (z_case, z_idx++);
size_t z_idx = 0;
t->count = case_num_idx (z_case, z_idx++);
- for (z = t->z_scores; z < t->z_scores + t->z_score_cnt; z++)
+ for (z = t->z_scores; z < t->z_scores + t->n_z_scores; z++)
{
z->mean = case_num_idx (z_case, z_idx++);
z->std_dev = case_num_idx (z_case, z_idx++);
{
z->mean = case_num_idx (z_case, z_idx++);
z->std_dev = case_num_idx (z_case, z_idx++);
if (t->missing_type == DSC_LISTWISE)
{
assert(t->vars);
if (t->missing_type == DSC_LISTWISE)
{
assert(t->vars);
- for (vars = t->vars; vars < t->vars + t->var_cnt; vars++)
+ for (vars = t->vars; vars < t->vars + t->n_vars; vars++)
{
double score = case_num (*c, *vars);
if (var_is_num_missing (*vars, score, t->exclude))
{
double score = case_num (*c, *vars);
if (var_is_num_missing (*vars, score, t->exclude))
- for (z = t->z_scores; z < t->z_scores + t->z_score_cnt; z++)
+ for (z = t->z_scores; z < t->z_scores + t->n_z_scores; z++)
{
double input = case_num (*c, z->src_var);
double *output = case_num_rw (*c, z->z_var);
{
double input = case_num (*c, z->src_var);
double *output = case_num_rw (*c, z->z_var);
struct dsc_trns *t;
size_t cnt, i;
struct dsc_trns *t;
size_t cnt, i;
- for (cnt = i = 0; i < dsc->var_cnt; i++)
+ for (cnt = i = 0; i < dsc->n_vars; i++)
if (dsc->vars[i].z_name != NULL)
cnt++;
t = xmalloc (sizeof *t);
t->z_scores = xnmalloc (cnt, sizeof *t->z_scores);
if (dsc->vars[i].z_name != NULL)
cnt++;
t = xmalloc (sizeof *t);
t->z_scores = xnmalloc (cnt, sizeof *t->z_scores);
t->missing_type = dsc->missing_type;
t->exclude = dsc->exclude;
if (t->missing_type == DSC_LISTWISE)
{
t->missing_type = dsc->missing_type;
t->exclude = dsc->exclude;
if (t->missing_type == DSC_LISTWISE)
{
- t->var_cnt = dsc->var_cnt;
- t->vars = xnmalloc (t->var_cnt, sizeof *t->vars);
- for (i = 0; i < t->var_cnt; i++)
+ t->n_vars = dsc->n_vars;
+ t->vars = xnmalloc (t->n_vars, sizeof *t->vars);
+ for (i = 0; i < t->n_vars; i++)
t->vars[i] = dsc->vars[i].v;
}
else
{
t->vars[i] = dsc->vars[i].v;
}
else
{
t->vars = NULL;
}
t->filter = dict_get_filter (dataset_dict (ds));
t->vars = NULL;
}
t->filter = dict_get_filter (dataset_dict (ds));
t->ok = true;
dsc->z_writer = NULL;
t->ok = true;
dsc->z_writer = NULL;
- for (cnt = i = 0; i < dsc->var_cnt; i++)
+ for (cnt = i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dv = &dsc->vars[i];
if (dv->z_name != NULL)
{
struct dsc_var *dv = &dsc->vars[i];
if (dv->z_name != NULL)
pass1 = group;
pass2 = dsc->max_moment <= MOMENT_MEAN ? NULL : casereader_clone (pass1);
pass1 = group;
pass2 = dsc->max_moment <= MOMENT_MEAN ? NULL : casereader_clone (pass1);
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dv = &dsc->vars[i];
{
struct dsc_var *dv = &dsc->vars[i];
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dv = &dsc->vars[i];
double x = case_num (c, dv->v);
{
struct dsc_var *dv = &dsc->vars[i];
double x = case_num (c, dv->v);
if (dsc->missing_type == DSC_LISTWISE && listwise_missing (dsc, c))
continue;
if (dsc->missing_type == DSC_LISTWISE && listwise_missing (dsc, c))
continue;
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dv = &dsc->vars[i];
double x = case_num (c, dv->v);
{
struct dsc_var *dv = &dsc->vars[i];
double x = case_num (c, dv->v);
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dv = &dsc->vars[i];
double W;
{
struct dsc_var *dv = &dsc->vars[i];
double W;
- for (i = 0; i < dsc->var_cnt; i++)
+ for (i = 0; i < dsc->n_vars; i++)
{
struct dsc_var *dv = &dsc->vars[i];
double x = case_num (c, dv->v);
{
struct dsc_var *dv = &dsc->vars[i];
double x = case_num (c, dv->v);
pivot_value_new_text (dsc_info[i].name));
if (dsc->sort_by_stat != DSC_NONE)
pivot_value_new_text (dsc_info[i].name));
if (dsc->sort_by_stat != DSC_NONE)
- sort (dsc->vars, dsc->var_cnt, sizeof *dsc->vars,
+ sort (dsc->vars, dsc->n_vars, sizeof *dsc->vars,
descriptives_compare_dsc_vars, dsc);
struct pivot_dimension *variables = pivot_dimension_create (
table, PIVOT_AXIS_ROW, N_("Variable"));
descriptives_compare_dsc_vars, dsc);
struct pivot_dimension *variables = pivot_dimension_create (
table, PIVOT_AXIS_ROW, N_("Variable"));
- for (size_t i = 0; i < dsc->var_cnt; i++)
+ for (size_t i = 0; i < dsc->n_vars; i++)
{
const struct dsc_var *dv = &dsc->vars[i];
{
const struct dsc_var *dv = &dsc->vars[i];
es[v].sorted_reader = casewriter_make_reader (es[v].sorted_writer);
es[v].sorted_writer = NULL;
es[v].sorted_reader = casewriter_make_reader (es[v].sorted_writer);
es[v].sorted_writer = NULL;
- imax = casereader_get_case_cnt (es[v].sorted_reader);
+ imax = casereader_get_n_cases (es[v].sorted_reader);
es[v].maxima = pool_calloc (examine->pool, examine->calc_extremes, sizeof (*es[v].maxima));
es[v].minima = pool_calloc (examine->pool, examine->calc_extremes, sizeof (*es[v].minima));
es[v].maxima = pool_calloc (examine->pool, examine->calc_extremes, sizeof (*es[v].maxima));
es[v].minima = pool_calloc (examine->pool, examine->calc_extremes, sizeof (*es[v].minima));
{
struct ccase *c = casereader_peek (input, 0);
{
struct ccase *c = casereader_peek (input, 0);
- cmd->id_idx = case_get_value_cnt (c);
+ cmd->id_idx = case_get_n_values (c);
input = casereader_create_arithmetic_sequence (input, 1.0, 1.0);
case_unref (c);
input = casereader_create_arithmetic_sequence (input, 1.0, 1.0);
case_unref (c);
struct stringi_set strings;
stringi_set_clone (&strings, &sf->strings);
struct stringi_set strings;
stringi_set_clone (&strings, &sf->strings);
- for (size_t i = 0; dict_get_var_cnt (dict) < m->size2; i++)
+ for (size_t i = 0; dict_get_n_vars (dict) < m->size2; i++)
{
char tmp_name[64];
const char *name;
{
char tmp_name[64];
const char *name;
- n_vars = dict_get_var_cnt (dict);
+ n_vars = dict_get_n_vars (dict);
vars = xnmalloc (n_vars, sizeof *vars);
for (size_t i = 0; i < n_vars; i++)
{
vars = xnmalloc (n_vars, sizeof *vars);
for (size_t i = 0; i < n_vars; i++)
{
- if (dict_get_var_cnt (dataset_dict (dataset)) == 0)
+ if (dict_get_n_vars (dataset_dict (dataset)) == 0)
{
msg_at (ME, cmd->location,
_("The %s command cannot read an empty active file."),
{
msg_at (ME, cmd->location,
_("The %s command cannot read an empty active file."),
_("ROWTYPE_ must precede VARNAME_ in matrix data file."));
return;
}
_("ROWTYPE_ must precede VARNAME_ in matrix data file."));
return;
}
- if (var_get_dict_index (varname_) + 1 >= dict_get_var_cnt (d))
+ if (var_get_dict_index (varname_) + 1 >= dict_get_n_vars (d))
{
msg_at (SE, loc, _("Matrix data file contains no continuous variables."));
return;
}
{
msg_at (SE, loc, _("Matrix data file contains no continuous variables."));
return;
}
- for (size_t i = 0; i < dict_get_var_cnt (d); i++)
+ for (size_t i = 0; i < dict_get_n_vars (d); i++)
{
const struct variable *v = dict_get_var (d, i);
if (v != rowtype_ && v != varname_ && var_get_width (v) != 0)
{
const struct variable *v = dict_get_var (d, i);
if (v != rowtype_ && v != varname_ && var_get_width (v) != 0)
/* Continuous variables. */
size_t cs = var_get_dict_index (varname_) + 1;
/* Continuous variables. */
size_t cs = var_get_dict_index (varname_) + 1;
- size_t cn = dict_get_var_cnt (d) - cs;
+ size_t cn = dict_get_n_vars (d) - cs;
struct ccase *cc = NULL;
/* Pivot table. */
struct ccase *cc = NULL;
/* Pivot table. */
subcase_add_vars_always (&projection,
cmd->group_vars, cmd->n_group_vars);
subcase_add_vars_always (&projection, dict_get_split_vars (d),
subcase_add_vars_always (&projection,
cmd->group_vars, cmd->n_group_vars);
subcase_add_vars_always (&projection, dict_get_split_vars (d),
- dict_get_split_cnt (d));
+ dict_get_n_splits (d));
if (weight_var != NULL)
{
subcase_add_var_always (&projection, weight_var, SC_ASCEND);
if (weight_var != NULL)
{
subcase_add_var_always (&projection, weight_var, SC_ASCEND);
- weight_idx = 2 + cmd->n_group_vars + dict_get_split_cnt (d);
+ weight_idx = 2 + cmd->n_group_vars + dict_get_n_splits (d);
/* Group by split variables */
subcase_init_empty (&split_vars);
/* Group by split variables */
subcase_init_empty (&split_vars);
- for (j = 0; j < dict_get_split_cnt (d); j++)
+ for (j = 0; j < dict_get_n_splits (d); j++)
subcase_add_always (&split_vars, 2 + j + cmd->n_group_vars,
var_get_width (dict_get_split_vars (d)[j]),
SC_ASCEND);
subcase_add_always (&split_vars, 2 + j + cmd->n_group_vars,
var_get_width (dict_get_split_vars (d)[j]),
SC_ASCEND);
for (; (c = casereader_read (r)); case_unref (c))
{
int i;
for (; (c = casereader_read (r)); case_unref (c))
{
int i;
- for (i = 0 ; i < case_get_value_cnt (c); ++i)
+ for (i = 0 ; i < case_get_n_values (c); ++i)
printf ("%g ", case_num_idx (c, i));
printf ("\n");
}
printf ("%g ", case_num_idx (c, i));
printf ("\n");
}
const struct variable ***vars, bool *saw_direction)
{
const struct variable **local_vars = NULL;
const struct variable ***vars, bool *saw_direction)
{
const struct variable **local_vars = NULL;
if (vars == NULL)
vars = &local_vars;
if (vars == NULL)
vars = &local_vars;
- size_t prev_var_cnt = var_cnt;
+ size_t prev_n_vars = n_vars;
enum subcase_direction direction;
size_t i;
/* Variables. */
enum subcase_direction direction;
size_t i;
/* Variables. */
- if (!parse_variables_const (lexer, dict, vars, &var_cnt,
+ if (!parse_variables_const (lexer, dict, vars, &n_vars,
PV_APPEND | PV_NO_SCRATCH))
goto error;
PV_APPEND | PV_NO_SCRATCH))
goto error;
else
direction = SC_ASCEND;
else
direction = SC_ASCEND;
- for (i = prev_var_cnt; i < var_cnt; i++)
+ for (i = prev_n_vars; i < n_vars; i++)
{
const struct variable *var = (*vars)[i];
if (!subcase_add_var (ordering, var, direction))
{
const struct variable *var = (*vars)[i];
if (!subcase_add_var (ordering, var, direction))
{"X", FLOAT_HEX},
{"FP", FLOAT_FP},
};
{"X", FLOAT_HEX},
{"FP", FLOAT_FP},
};
-static const size_t format_cnt = sizeof fp_formats / sizeof *fp_formats;
+static const size_t n_formats = sizeof fp_formats / sizeof *fp_formats;
/* Parses a floating-point format name into *FORMAT,
and returns success. */
/* Parses a floating-point format name into *FORMAT,
and returns success. */
- for (i = 0; i < format_cnt; i++)
+ for (i = 0; i < n_formats; i++)
if (lex_match_id (lexer, fp_formats[i].name))
{
*format = fp_formats[i].format;
if (lex_match_id (lexer, fp_formats[i].name))
{
*format = fp_formats[i].format;
- for (i = 0; i < format_cnt; i++)
+ for (i = 0; i < n_formats; i++)
if (fp_formats[i].format == format)
return fp_formats[i].name;
if (fp_formats[i].format == format)
return fp_formats[i].name;
cmd_debug_float_format (struct lexer *lexer, struct dataset *ds UNUSED)
{
struct fp fp[16];
cmd_debug_float_format (struct lexer *lexer, struct dataset *ds UNUSED)
{
struct fp fp[16];
bool bijective = false;
bool ok;
for (;;)
{
bool bijective = false;
bool ok;
for (;;)
{
- if (fp_cnt >= sizeof fp / sizeof *fp)
+ if (n_fps >= sizeof fp / sizeof *fp)
{
msg (SE, "Too many values in single command.");
return CMD_FAILURE;
}
{
msg (SE, "Too many values in single command.");
return CMD_FAILURE;
}
- if (!parse_fp (lexer, &fp[fp_cnt++]))
+ if (!parse_fp (lexer, &fp[n_fps++]))
- if (lex_token (lexer) == T_ENDCMD && fp_cnt > 1)
+ if (lex_token (lexer) == T_ENDCMD && n_fps > 1)
break;
else if (!lex_force_match (lexer, T_EQUALS))
return CMD_FAILURE;
break;
else if (!lex_force_match (lexer, T_EQUALS))
return CMD_FAILURE;
{
if (lex_match (lexer, T_EQUALS))
bijective = true;
{
if (lex_match (lexer, T_EQUALS))
bijective = true;
- for (i = 0; i < fp_cnt; i++)
- for (j = 0; j < fp_cnt; j++)
+ for (i = 0; i < n_fps; i++)
+ for (j = 0; j < n_fps; j++)
if (!verify_conversion (&fp[i], &fp[j]))
ok = false;
}
if (!verify_conversion (&fp[i], &fp[j]))
ok = false;
}
- for (i = 1; i < fp_cnt; i++)
+ for (i = 1; i < n_fps; i++)
if (!verify_conversion (&fp[i - 1], &fp[i]))
ok = false;
}
if (!verify_conversion (&fp[i - 1], &fp[i]))
ok = false;
}
index = expr_evaluate_num (compute->element, *c, case_num);
rindx = floor (index + EPSILON);
if (index == SYSMIS
index = expr_evaluate_num (compute->element, *c, case_num);
rindx = floor (index + EPSILON);
if (index == SYSMIS
- || rindx < 1 || rindx > vector_get_var_cnt (compute->vector))
+ || rindx < 1 || rindx > vector_get_n_vars (compute->vector))
{
if (index == SYSMIS)
msg (SW, _("When executing COMPUTE: SYSMIS is not a valid value "
{
if (index == SYSMIS)
msg (SW, _("When executing COMPUTE: SYSMIS is not a valid value "
vector_get_name (compute->vector));
return TRNS_CONTINUE;
}
vector_get_name (compute->vector));
return TRNS_CONTINUE;
}
- else if (rindx < 1 || rindx > vector_get_var_cnt (compute->vector))
+ else if (rindx < 1 || rindx > vector_get_n_vars (compute->vector))
{
msg (SW, _("When executing COMPUTE: %.*g is not a valid value as "
"an index into vector %s."),
{
msg (SW, _("When executing COMPUTE: %.*g is not a valid value as "
"an index into vector %s."),
/* Variables to count. */
const struct variable **vars;
/* Variables to count. */
const struct variable **vars;
/* Count special values? */
bool count_system_missing; /* Count system missing? */
bool count_user_missing; /* Count user missing? */
/* Criterion values. */
/* Count special values? */
bool count_system_missing; /* Count system missing? */
bool count_user_missing; /* Count user missing? */
/* Criterion values. */
union
{
struct num_value *num;
union
{
struct num_value *num;
crit->next = NULL;
crit->vars = NULL;
if (!parse_variables_const (lexer, dict, &crit->vars,
crit->next = NULL;
crit->vars = NULL;
if (!parse_variables_const (lexer, dict, &crit->vars,
PV_DUPLICATE | PV_SAME_TYPE))
goto fail;
pool_register (trns->pool, free, crit->vars);
PV_DUPLICATE | PV_SAME_TYPE))
goto fail;
pool_register (trns->pool, free, crit->vars);
if (!lex_force_match (lexer, T_LPAREN))
goto fail;
if (!lex_force_match (lexer, T_LPAREN))
goto fail;
if (var_is_numeric (crit->vars[0]))
ok = parse_numeric_criteria (lexer, trns->pool, crit);
else
if (var_is_numeric (crit->vars[0]))
ok = parse_numeric_criteria (lexer, trns->pool, crit);
else
- if (crit->value_cnt >= allocated)
+ if (crit->n_values >= allocated)
crit->values.num = pool_2nrealloc (pool, crit->values.num,
&allocated,
sizeof *crit->values.num);
crit->values.num = pool_2nrealloc (pool, crit->values.num,
&allocated,
sizeof *crit->values.num);
- cur = &crit->values.num[crit->value_cnt++];
+ cur = &crit->values.num[crit->n_values++];
cur->type = low == high ? CNT_SINGLE : CNT_RANGE;
cur->a = low;
cur->b = high;
cur->type = low == high ? CNT_SINGLE : CNT_RANGE;
cur->a = low;
cur->b = high;
size_t allocated = 0;
size_t i;
size_t allocated = 0;
size_t i;
- for (i = 0; i < crit->var_cnt; i++)
+ for (i = 0; i < crit->n_vars; i++)
if (var_get_width (crit->vars[i]) > len)
len = var_get_width (crit->vars[i]);
if (var_get_width (crit->vars[i]) > len)
len = var_get_width (crit->vars[i]);
- if (crit->value_cnt >= allocated)
+ if (crit->n_values >= allocated)
crit->values.str = pool_2nrealloc (pool, crit->values.str,
&allocated,
sizeof *crit->values.str);
crit->values.str = pool_2nrealloc (pool, crit->values.str,
&allocated,
sizeof *crit->values.str);
s = recode_string (dict_encoding, "UTF-8", lex_tokcstr (lexer),
ss_length (lex_tokss (lexer)));
s = recode_string (dict_encoding, "UTF-8", lex_tokcstr (lexer),
ss_length (lex_tokss (lexer)));
- cur = &crit->values.str[crit->value_cnt++];
+ cur = &crit->values.str[crit->n_values++];
*cur = pool_alloc (pool, len + 1);
str_copy_rpad (*cur, len + 1, s);
lex_get (lexer);
*cur = pool_alloc (pool, len + 1);
str_copy_rpad (*cur, len + 1, s);
lex_get (lexer);
int counter = 0;
size_t i;
int counter = 0;
size_t i;
- for (i = 0; i < crit->var_cnt; i++)
+ for (i = 0; i < crit->n_vars; i++)
{
double x = case_num (c, crit->vars[i]);
struct num_value *v;
{
double x = case_num (c, crit->vars[i]);
struct num_value *v;
- for (v = crit->values.num; v < crit->values.num + crit->value_cnt;
+ for (v = crit->values.num; v < crit->values.num + crit->n_values;
v++)
if (v->type == CNT_SINGLE ? x == v->a : x >= v->a && x <= v->b)
{
v++)
if (v->type == CNT_SINGLE ? x == v->a : x >= v->a && x <= v->b)
{
int counter = 0;
size_t i;
int counter = 0;
size_t i;
- for (i = 0; i < crit->var_cnt; i++)
+ for (i = 0; i < crit->n_vars; i++)
- for (v = crit->values.str; v < crit->values.str + crit->value_cnt; v++)
+ for (v = crit->values.str; v < crit->values.str + crit->n_values; v++)
if (!memcmp (case_str (c, crit->vars[i]), *v,
var_get_width (crit->vars[i])))
{
if (!memcmp (case_str (c, crit->vars[i]), *v,
var_get_width (crit->vars[i])))
{
const struct variable **dst_vars; /* Destination variables. */
const struct dictionary *dst_dict; /* Dictionary of dst_vars */
char **dst_names; /* Name of dest variables, if they're new. */
const struct variable **dst_vars; /* Destination variables. */
const struct dictionary *dst_dict; /* Dictionary of dst_vars */
char **dst_names; /* Name of dest variables, if they're new. */
- size_t var_cnt; /* Number of variables. */
+ size_t n_vars; /* Number of variables. */
/* Mappings. */
struct mapping *mappings; /* Value mappings. */
/* Mappings. */
struct mapping *mappings; /* Value mappings. */
- size_t map_cnt; /* Number of mappings. */
+ size_t n_maps; /* Number of mappings. */
int max_src_width; /* Maximum width of src_vars[*]. */
int max_dst_width; /* Maximum width of any map_out in mappings. */
};
int max_src_width; /* Maximum width of src_vars[*]. */
int max_dst_width; /* Maximum width of any map_out in mappings. */
};
}
/* Parses a set of variables to recode into TRNS->src_vars and
}
/* Parses a set of variables to recode into TRNS->src_vars and
- TRNS->var_cnt. Sets TRNS->src_type. Returns true if
+ TRNS->n_vars. Sets TRNS->src_type. Returns true if
successful, false on parse error. */
static bool
parse_src_vars (struct lexer *lexer,
struct recode_trns *trns, const struct dictionary *dict)
{
successful, false on parse error. */
static bool
parse_src_vars (struct lexer *lexer,
struct recode_trns *trns, const struct dictionary *dict)
{
- if (!parse_variables_const (lexer, dict, &trns->src_vars, &trns->var_cnt,
+ if (!parse_variables_const (lexer, dict, &trns->src_vars, &trns->n_vars,
PV_SAME_TYPE))
return false;
pool_register (trns->pool, free, trns->src_vars);
PV_SAME_TYPE))
return false;
pool_register (trns->pool, free, trns->src_vars);
}
/* Parses a set of mappings, which take the form (input=output),
}
/* Parses a set of mappings, which take the form (input=output),
- into TRNS->mappings and TRNS->map_cnt. Sets TRNS->dst_type.
+ into TRNS->mappings and TRNS->n_maps. Sets TRNS->dst_type.
Returns true if successful, false on parse error. */
static bool
parse_mappings (struct lexer *lexer, struct recode_trns *trns,
Returns true if successful, false on parse error. */
static bool
parse_mappings (struct lexer *lexer, struct recode_trns *trns,
/* Find length of longest source variable. */
trns->max_src_width = var_get_width (trns->src_vars[0]);
/* Find length of longest source variable. */
trns->max_src_width = var_get_width (trns->src_vars[0]);
- for (i = 1; i < trns->var_cnt; i++)
+ for (i = 1; i < trns->n_vars; i++)
{
size_t var_width = var_get_width (trns->src_vars[i]);
if (var_width > trns->max_src_width)
{
size_t var_width = var_get_width (trns->src_vars[i]);
if (var_width > trns->max_src_width)
/* Parse the mappings in parentheses. */
trns->mappings = NULL;
/* Parse the mappings in parentheses. */
trns->mappings = NULL;
map_allocated = 0;
have_dst_type = false;
if (!lex_force_match (lexer, T_LPAREN))
map_allocated = 0;
have_dst_type = false;
if (!lex_force_match (lexer, T_LPAREN))
size_t first_map_idx;
size_t i;
size_t first_map_idx;
size_t i;
- first_map_idx = trns->map_cnt;
+ first_map_idx = trns->n_maps;
/* Parse source specifications. */
do
/* Parse source specifications. */
do
- for (i = first_map_idx; i < trns->map_cnt; i++)
+ for (i = first_map_idx; i < trns->n_maps; i++)
trns->mappings[i].out = out;
}
else
trns->mappings[i].out = out;
}
else
struct map_in in;
set_map_in_generic (&in, MAP_CONVERT);
add_mapping (trns, &map_allocated, &in);
struct map_in in;
set_map_in_generic (&in, MAP_CONVERT);
add_mapping (trns, &map_allocated, &in);
- set_map_out_num (&trns->mappings[trns->map_cnt - 1].out, 0.0);
+ set_map_out_num (&trns->mappings[trns->n_maps - 1].out, 0.0);
dst_type = VAL_NUMERIC;
if (trns->src_type != VAL_STRING
dst_type = VAL_NUMERIC;
if (trns->src_type != VAL_STRING
size_t *map_allocated, const struct map_in *in)
{
struct mapping *m;
size_t *map_allocated, const struct map_in *in)
{
struct mapping *m;
- if (trns->map_cnt >= *map_allocated)
+ if (trns->n_maps >= *map_allocated)
trns->mappings = pool_2nrealloc (trns->pool, trns->mappings,
map_allocated,
sizeof *trns->mappings);
trns->mappings = pool_2nrealloc (trns->pool, trns->mappings,
map_allocated,
sizeof *trns->mappings);
- m = &trns->mappings[trns->map_cnt++];
+ m = &trns->mappings[trns->n_maps++];
if (lex_match_id (lexer, "INTO"))
{
if (lex_match_id (lexer, "INTO"))
{
size_t i;
if (!parse_mixed_vars_pool (lexer, dict, trns->pool,
size_t i;
if (!parse_mixed_vars_pool (lexer, dict, trns->pool,
- &trns->dst_names, &name_cnt,
+ &trns->dst_names, &n_names,
- if (name_cnt != trns->var_cnt)
+ if (n_names != trns->n_vars)
{
msg (SE, _("%zu variable(s) cannot be recoded into "
"%zu variable(s). Specify the same number "
"of variables as source and target variables."),
{
msg (SE, _("%zu variable(s) cannot be recoded into "
"%zu variable(s). Specify the same number "
"of variables as source and target variables."),
- trns->var_cnt, name_cnt);
+ trns->n_vars, n_names);
return false;
}
trns->dst_vars = pool_nalloc (trns->pool,
return false;
}
trns->dst_vars = pool_nalloc (trns->pool,
- trns->var_cnt, sizeof *trns->dst_vars);
- for (i = 0; i < trns->var_cnt; i++)
+ trns->n_vars, sizeof *trns->dst_vars);
+ for (i = 0; i < trns->n_vars; i++)
{
const struct variable *v;
v = trns->dst_vars[i] = dict_lookup_var (dict, trns->dst_names[i]);
{
const struct variable *v;
v = trns->dst_vars[i] = dict_lookup_var (dict, trns->dst_names[i]);
- for (i = 0; i < trns->var_cnt; i++)
+ for (i = 0; i < trns->n_vars; i++)
{
const struct variable *v = trns->dst_vars[i];
if (v != NULL && var_get_type (v) != trns->dst_type)
{
const struct variable *v = trns->dst_vars[i];
if (v != NULL && var_get_type (v) != trns->dst_type)
int min_dst_width = INT_MAX;
trns->max_dst_width = 0;
int min_dst_width = INT_MAX;
trns->max_dst_width = 0;
- for (i = 0; i < trns->var_cnt; i++)
+ for (i = 0; i < trns->n_vars; i++)
{
const struct variable *v = trns->dst_vars[i];
if (var_get_width (v) > trns->max_dst_width)
{
const struct variable *v = trns->dst_vars[i];
if (var_get_width (v) > trns->max_dst_width)
- for (i = 0; i < trns->map_cnt; i++)
+ for (i = 0; i < trns->n_maps; i++)
{
struct map_out *out = &trns->mappings[i].out;
if (!out->copy_input)
{
struct map_out *out = &trns->mappings[i].out;
if (!out->copy_input)
- for (i = 0; i < trns->var_cnt; i++)
+ for (i = 0; i < trns->n_vars; i++)
{
const struct variable **var = &trns->dst_vars[i];
const char *name = trns->dst_names[i];
{
const struct variable **var = &trns->dst_vars[i];
const char *name = trns->dst_names[i];
- for (m = trns->mappings; m < trns->mappings + trns->map_cnt; m++)
+ for (m = trns->mappings; m < trns->mappings + trns->n_maps; m++)
{
const struct map_in *in = &m->in;
const struct map_out *out = &m->out;
{
const struct map_in *in = &m->in;
const struct map_out *out = &m->out;
int width = var_get_width (src_var);
struct mapping *m;
int width = var_get_width (src_var);
struct mapping *m;
- for (m = trns->mappings; m < trns->mappings + trns->map_cnt; m++)
+ for (m = trns->mappings; m < trns->mappings + trns->n_maps; m++)
{
const struct map_in *in = &m->in;
struct map_out *out = &m->out;
{
const struct map_in *in = &m->in;
struct map_out *out = &m->out;
size_t i;
*c = case_unshare (*c);
size_t i;
*c = case_unshare (*c);
- for (i = 0; i < trns->var_cnt; i++)
+ for (i = 0; i < trns->n_vars; i++)
{
const struct variable *src_var = trns->src_vars[i];
const struct variable *dst_var = trns->dst_vars[i];
{
const struct variable *src_var = trns->src_vars[i];
const struct variable *dst_var = trns->dst_vars[i];
algo_compare_func *compare, const void *aux)
{
const char *first = array;
algo_compare_func *compare, const void *aux)
{
const char *first = array;
while (count-- > 0)
{
if (compare (element, first, aux) == 0)
while (count-- > 0)
{
if (compare (element, first, aux) == 0)
}
/* Counts and return the number of elements in ARRAY, which
}
/* Counts and return the number of elements in ARRAY, which
algo_predicate_func *predicate, const void *aux)
{
const char *first = array;
algo_predicate_func *predicate, const void *aux)
{
const char *first = array;
while (count-- > 0)
{
if (predicate (first, aux) != 0)
while (count-- > 0)
{
if (predicate (first, aux) != 0)
}
\f
/* Byte-wise swap objects A and B, each SIZE bytes. */
}
\f
/* Byte-wise swap objects A and B, each SIZE bytes. */
partition (void *array, size_t count, size_t size,
algo_predicate_func *predicate, const void *aux)
{
partition (void *array, size_t count, size_t size,
algo_predicate_func *predicate, const void *aux)
{
- size_t true_cnt = count;
+ size_t n_trues = count;
- char *last = first + true_cnt * size;
+ char *last = first + n_trues * size;
/* Move LAST backward to point to last element that passes
PREDICATE. */
/* Move LAST backward to point to last element that passes
PREDICATE. */
else if (predicate (last, aux))
break;
else
else if (predicate (last, aux))
break;
else
}
/* By swapping FIRST and LAST we extend the starting and
}
/* By swapping FIRST and LAST we extend the starting and
- assert (is_partitioned (array, count, size, true_cnt, predicate, aux));
- return true_cnt;
+ assert (is_partitioned (array, count, size, n_trues, predicate, aux));
+ return n_trues;
}
/* Checks whether ARRAY, which contains COUNT elements of SIZE
}
/* Checks whether ARRAY, which contains COUNT elements of SIZE
elements. AUX is passed as auxiliary data to PREDICATE. */
bool
is_partitioned (const void *array, size_t count, size_t size,
elements. AUX is passed as auxiliary data to PREDICATE. */
bool
is_partitioned (const void *array, size_t count, size_t size,
algo_predicate_func *predicate, const void *aux)
{
const char *first = array;
size_t idx;
algo_predicate_func *predicate, const void *aux)
{
const char *first = array;
size_t idx;
- assert (true_cnt <= count);
- for (idx = 0; idx < true_cnt; idx++)
+ assert (n_trues <= count);
+ for (idx = 0; idx < n_trues; idx++)
if (predicate (first + idx * size, aux) == 0)
return false;
if (predicate (first + idx * size, aux) == 0)
return false;
- for (idx = true_cnt; idx < count; idx++)
+ for (idx = n_trues; idx < count; idx++)
if (predicate (first + idx * size, aux) != 0)
return false;
return true;
if (predicate (first + idx * size, aux) != 0)
return false;
return true;
const char *input = array;
const char *last = input + size * count;
char *output = result;
const char *input = array;
const char *last = input + size * count;
char *output = result;
- size_t nonzero_cnt = 0;
{
memcpy (output, input, size);
output += size;
{
memcpy (output, input, size);
output += size;
- assert (nonzero_cnt == count_if (array, count, size, predicate, aux));
- assert (nonzero_cnt == count_if (result, nonzero_cnt, size, predicate, aux));
+ assert (n_nonzeros == count_if (array, count, size, predicate, aux));
+ assert (n_nonzeros == count_if (result, n_nonzeros, size, predicate, aux));
}
/* Removes N elements starting at IDX from ARRAY, which consists
}
/* Removes N elements starting at IDX from ARRAY, which consists
for the first TRUE_CNT elements and zero for the remaining
elements. AUX is passed as auxiliary data to PREDICATE. */
bool is_partitioned (const void *array, size_t count, size_t size,
for the first TRUE_CNT elements and zero for the remaining
elements. AUX is passed as auxiliary data to PREDICATE. */
bool is_partitioned (const void *array, size_t count, size_t size,
algo_predicate_func *predicate, const void *aux);
/* Randomly reorders ARRAY, which contains COUNT elements of SIZE
algo_predicate_func *predicate, const void *aux);
/* Randomly reorders ARRAY, which contains COUNT elements of SIZE
size_t new_capacity = MAX (4, old_capacity * 2);
char *old_data = old_data_;
char *new_data = xnmalloc (new_capacity, elem_size);
size_t new_capacity = MAX (4, old_capacity * 2);
char *old_data = old_data_;
char *new_data = xnmalloc (new_capacity, elem_size);
- size_t idx, copy_cnt;
- for (idx = deque->back; idx != deque->front; idx += copy_cnt)
+ size_t idx, n_copy;
+ for (idx = deque->back; idx != deque->front; idx += n_copy)
{
size_t can_copy = old_capacity - (idx & (old_capacity - 1));
size_t want_copy = deque->front - idx;
{
size_t can_copy = old_capacity - (idx & (old_capacity - 1));
size_t want_copy = deque->front - idx;
- copy_cnt = MIN (can_copy, want_copy);
+ n_copy = MIN (can_copy, want_copy);
memcpy (new_data + (idx & (new_capacity - 1)) * elem_size,
old_data + (idx & (old_capacity - 1)) * elem_size,
memcpy (new_data + (idx & (new_capacity - 1)) * elem_size,
old_data + (idx & (old_capacity - 1)) * elem_size,
}
deque->capacity = new_capacity;
free (old_data);
}
deque->capacity = new_capacity;
free (old_data);
FLOAT_Z_SHORT,
FLOAT_Z_LONG,
};
FLOAT_Z_SHORT,
FLOAT_Z_LONG,
};
- const size_t candidate_cnt = sizeof candidates / sizeof *candidates;
+ const size_t n_candidates = sizeof candidates / sizeof *candidates;
- match_cnt = 0;
- for (p = candidates; p < candidates + candidate_cnt; p++)
+ n_matches = 0;
+ for (p = candidates; p < candidates + n_candidates; p++)
if (float_get_size (*p) == length)
{
char tmp[8];
assert (sizeof tmp >= float_get_size (*p));
float_convert (FLOAT_NATIVE_DOUBLE, &expected_value, *p, tmp);
if (float_get_size (*p) == length)
{
char tmp[8];
assert (sizeof tmp >= float_get_size (*p));
float_convert (FLOAT_NATIVE_DOUBLE, &expected_value, *p, tmp);
- if (!memcmp (tmp, number, length) && match_cnt++ == 0)
+ if (!memcmp (tmp, number, length) && n_matches++ == 0)
}
/* Returns the double value that is just greater than -DBL_MAX,
}
/* Returns the double value that is just greater than -DBL_MAX,
ll_sort (struct ll *r0, struct ll *r1, ll_compare_func *compare, void *aux)
{
struct ll *pre_r0;
ll_sort (struct ll *r0, struct ll *r1, ll_compare_func *compare, void *aux)
{
struct ll *pre_r0;
if (r0 == r1 || ll_next (r0) == r1)
return;
if (r0 == r1 || ll_next (r0) == r1)
return;
do
{
struct ll *a0 = ll_next (pre_r0);
do
{
struct ll *a0 = ll_next (pre_r0);
- for (output_run_cnt = 1; ; output_run_cnt++)
+ for (output_run_len = 1; ; output_run_len++)
{
struct ll *a1 = ll_find_run (a0, r1, compare, aux);
struct ll *a2 = ll_find_run (a1, r1, compare, aux);
{
struct ll *a1 = ll_find_run (a0, r1, compare, aux);
struct ll *a2 = ll_find_run (a1, r1, compare, aux);
a0 = ll_merge (a0, a1, a1, a2, compare, aux);
}
}
a0 = ll_merge (a0, a1, a1, a2, compare, aux);
}
}
- while (output_run_cnt > 1);
+ while (output_run_len > 1);
}
/* Finds the extent of a run of nodes of increasing value
}
/* Finds the extent of a run of nodes of increasing value
llx_sort (struct llx *r0, struct llx *r1, llx_compare_func *compare, void *aux)
{
struct llx *pre_r0;
llx_sort (struct llx *r0, struct llx *r1, llx_compare_func *compare, void *aux)
{
struct llx *pre_r0;
if (r0 == r1 || llx_next (r0) == r1)
return;
if (r0 == r1 || llx_next (r0) == r1)
return;
do
{
struct llx *a0 = llx_next (pre_r0);
do
{
struct llx *a0 = llx_next (pre_r0);
- for (output_run_cnt = 1; ; output_run_cnt++)
+ for (output_run_len = 1; ; output_run_len++)
{
struct llx *a1 = llx_find_run (a0, r1, compare, aux);
struct llx *a2 = llx_find_run (a1, r1, compare, aux);
{
struct llx *a1 = llx_find_run (a0, r1, compare, aux);
struct llx *a2 = llx_find_run (a1, r1, compare, aux);
a0 = llx_merge (a0, a1, a1, a2, compare, aux);
}
}
a0 = llx_merge (a0, a1, a1, a2, compare, aux);
}
}
- while (output_run_cnt > 1);
+ while (output_run_len > 1);
}
/* Finds the extent of a run of nodes of increasing value
}
/* Finds the extent of a run of nodes of increasing value
memcpy (dst, src, dst_size);
else
{
memcpy (dst, src, dst_size);
else
{
- size_t pad_cnt = dst_size - src_len;
- memset (&dst[0], pad, pad_cnt);
- memcpy (dst + pad_cnt, src, src_len);
+ size_t n_pad = dst_size - src_len;
+ memset (&dst[0], pad, n_pad);
+ memcpy (dst + n_pad, src, src_len);
{
struct subcase ordering;
struct merge_input inputs[MAX_MERGE_ORDER];
{
struct subcase ordering;
struct merge_input inputs[MAX_MERGE_ORDER];
struct caseproto *proto;
};
struct caseproto *proto;
};
{
struct merge *m = xmalloc (sizeof *m);
subcase_clone (&m->ordering, ordering);
{
struct merge *m = xmalloc (sizeof *m);
subcase_clone (&m->ordering, ordering);
m->proto = caseproto_ref (proto);
return m;
}
m->proto = caseproto_ref (proto);
return m;
}
size_t i;
subcase_destroy (&m->ordering);
size_t i;
subcase_destroy (&m->ordering);
- for (i = 0; i < m->input_cnt; i++)
+ for (i = 0; i < m->n_inputs; i++)
casereader_destroy (m->inputs[i].reader);
caseproto_unref (m->proto);
free (m);
casereader_destroy (m->inputs[i].reader);
caseproto_unref (m->proto);
free (m);
merge_append (struct merge *m, struct casereader *r)
{
r = casereader_rename (r);
merge_append (struct merge *m, struct casereader *r)
{
r = casereader_rename (r);
- m->inputs[m->input_cnt++].reader = r;
- if (m->input_cnt >= MAX_MERGE_ORDER)
+ m->inputs[m->n_inputs++].reader = r;
+ if (m->n_inputs >= MAX_MERGE_ORDER)
{
struct casereader *r = NULL;
{
struct casereader *r = NULL;
{
r = m->inputs[0].reader;
{
r = m->inputs[0].reader;
- else if (m->input_cnt == 0)
+ else if (m->n_inputs == 0)
{
struct casewriter *writer = mem_writer_create (m->proto);
r = casewriter_make_reader (writer);
{
struct casewriter *writer = mem_writer_create (m->proto);
r = casewriter_make_reader (writer);
else
{
casereader_destroy (i->reader);
else
{
casereader_destroy (i->reader);
- remove_element (m->inputs, m->input_cnt, sizeof *m->inputs, idx);
- m->input_cnt--;
+ remove_element (m->inputs, m->n_inputs, sizeof *m->inputs, idx);
+ m->n_inputs--;
struct casewriter *w;
size_t i;
struct casewriter *w;
size_t i;
- assert (m->input_cnt > 1);
+ assert (m->n_inputs > 1);
w = tmpfile_writer_create (m->proto);
w = tmpfile_writer_create (m->proto);
- for (i = 0; i < m->input_cnt; i++)
+ for (i = 0; i < m->n_inputs; i++)
taint_propagate (casereader_get_taint (m->inputs[i].reader),
casewriter_get_taint (w));
taint_propagate (casereader_get_taint (m->inputs[i].reader),
casewriter_get_taint (w));
- for (i = 0; i < m->input_cnt;)
+ for (i = 0; i < m->n_inputs;)
if (read_input_case (m, i))
i++;
if (read_input_case (m, i))
i++;
- while (m->input_cnt > 0)
+ while (m->n_inputs > 0)
- for (i = 1; i < m->input_cnt; i++)
+ for (i = 1; i < m->n_inputs; i++)
if (subcase_compare_3way (&m->ordering, m->inputs[i].c,
&m->ordering, m->inputs[min].c) < 0)
min = i;
if (subcase_compare_3way (&m->ordering, m->inputs[i].c,
&m->ordering, m->inputs[min].c) < 0)
min = i;
read_input_case (m, min);
}
read_input_case (m, min);
}
m->inputs[0].reader = casewriter_make_reader (w);
}
m->inputs[0].reader = casewriter_make_reader (w);
}
{
struct subcase ordering;
struct pqueue_record *records;
{
struct subcase ordering;
struct pqueue_record *records;
- size_t record_cnt; /* Current number of records. */
- size_t record_cap; /* Space currently allocated for records. */
- size_t record_max; /* Max space we are willing to allocate. */
+ size_t n_records; /* Current number of records. */
+ size_t allocated_records; /* Space currently allocated for records. */
+ size_t max_records; /* Max space we are willing to allocate. */
pq = xmalloc (sizeof *pq);
subcase_clone (&pq->ordering, ordering);
pq = xmalloc (sizeof *pq);
subcase_clone (&pq->ordering, ordering);
- pq->record_max = settings_get_workspace_cases (proto);
- if (pq->record_max > max_buffers)
- pq->record_max = max_buffers;
- else if (pq->record_max < min_buffers)
- pq->record_max = min_buffers;
- pq->record_cnt = 0;
- pq->record_cap = 0;
+ pq->max_records = settings_get_workspace_cases (proto);
+ if (pq->max_records > max_buffers)
+ pq->max_records = max_buffers;
+ else if (pq->max_records < min_buffers)
+ pq->max_records = min_buffers;
+ pq->n_records = 0;
+ pq->allocated_records = 0;
pq->records = NULL;
pq->idx = 0;
pq->records = NULL;
pq->idx = 0;
static bool
pqueue_is_full (const struct pqueue *pq)
{
static bool
pqueue_is_full (const struct pqueue *pq)
{
- return pq->record_cnt >= pq->record_max;
+ return pq->n_records >= pq->max_records;
}
static bool
pqueue_is_empty (const struct pqueue *pq)
{
}
static bool
pqueue_is_empty (const struct pqueue *pq)
{
- return pq->record_cnt == 0;
+ return pq->n_records == 0;
assert (!pqueue_is_full (pq));
assert (!pqueue_is_full (pq));
- if (pq->record_cnt >= pq->record_cap)
+ if (pq->n_records >= pq->allocated_records)
- pq->record_cap = pq->record_cap * 2;
- if (pq->record_cap < 16)
- pq->record_cap = 16;
- else if (pq->record_cap > pq->record_max)
- pq->record_cap = pq->record_max;
+ pq->allocated_records = pq->allocated_records * 2;
+ if (pq->allocated_records < 16)
+ pq->allocated_records = 16;
+ else if (pq->allocated_records > pq->max_records)
+ pq->allocated_records = pq->max_records;
pq->records = xrealloc (pq->records,
pq->records = xrealloc (pq->records,
- pq->record_cap * sizeof *pq->records);
+ pq->allocated_records * sizeof *pq->records);
- r = &pq->records[pq->record_cnt++];
+ r = &pq->records[pq->n_records++];
r->id = id;
r->c = c;
r->idx = pq->idx++;
r->id = id;
r->c = c;
r->idx = pq->idx++;
- push_heap (pq->records, pq->record_cnt, sizeof *pq->records,
+ push_heap (pq->records, pq->n_records, sizeof *pq->records,
compare_pqueue_records_minheap, pq);
}
compare_pqueue_records_minheap, pq);
}
assert (!pqueue_is_empty (pq));
assert (!pqueue_is_empty (pq));
- pop_heap (pq->records, pq->record_cnt--, sizeof *pq->records,
+ pop_heap (pq->records, pq->n_records--, sizeof *pq->records,
compare_pqueue_records_minheap, pq);
compare_pqueue_records_minheap, pq);
- r = &pq->records[pq->record_cnt];
+ r = &pq->records[pq->n_records];
*id = r->id;
return r->c;
}
*id = r->id;
return r->c;
}
bool error; /* Output error? */
struct u8_line *lines; /* Page content. */
int allocated_lines; /* Number of lines allocated. */
bool error; /* Output error? */
struct u8_line *lines; /* Page content. */
int allocated_lines; /* Number of lines allocated. */
- int chart_cnt; /* Number of charts so far. */
- int object_cnt; /* Number of objects so far. */
+ int n_charts; /* Number of charts so far. */
+ int n_objects; /* Number of objects so far. */
const struct pivot_table *pt;
struct render_params params;
};
const struct pivot_table *pt;
struct render_params params;
};
a->error = false;
a->lines = NULL;
a->allocated_lines = 0;
a->error = false;
a->lines = NULL;
a->allocated_lines = 0;
- a->chart_cnt = 0;
- a->object_cnt = 0;
+ a->n_charts = 0;
+ a->n_objects = 0;
static const struct render_ops ascii_render_ops = {
.draw_line = ascii_draw_line,
static const struct render_ops ascii_render_ops = {
.draw_line = ascii_draw_line,
layer_indexes);
for (int i = 0; render_pager_has_next (p); i++)
{
layer_indexes);
for (int i = 0; render_pager_has_next (p); i++)
{
putc ('\n', a->file);
ascii_output_lines (a, render_pager_draw_next (p, INT_MAX));
putc ('\n', a->file);
ascii_output_lines (a, render_pager_draw_next (p, INT_MAX));
if (a->chart_file_name != NULL)
{
char *file_name = xr_write_png_image (
if (a->chart_file_name != NULL)
{
char *file_name = xr_write_png_image (
- item->image, a->chart_file_name, ++a->chart_cnt);
+ item->image, a->chart_file_name, ++a->n_charts);
if (file_name != NULL)
{
struct output_item *text_item = text_item_create_nocopy (
if (file_name != NULL)
{
struct output_item *text_item = text_item_create_nocopy (
if (a->chart_file_name != NULL)
{
char *file_name = xr_draw_png_chart (
if (a->chart_file_name != NULL)
{
char *file_name = xr_draw_png_chart (
- item->chart, a->chart_file_name, ++a->chart_cnt, &a->fg, &a->bg);
+ item->chart, a->chart_file_name, ++a->n_charts, &a->fg, &a->bg);
if (file_name != NULL)
{
struct output_item *text_item = text_item_create_nocopy (
if (file_name != NULL)
{
struct output_item *text_item = text_item_create_nocopy (
char *chart_file_name;
FILE *file;
char *chart_file_name;
FILE *file;
html->chart_file_name = parse_chart_file_name (opt (d, o, "charts",
fh_get_file_name (fh)));
html->file = NULL;
html->chart_file_name = parse_chart_file_name (opt (d, o, "charts",
fh_get_file_name (fh)));
html->file = NULL;
html->bg = parse_color (opt (d, o, "background-color", "#FFFFFFFFFFFF"));
html->fg = parse_color (opt (d, o, "foreground-color", "#000000000000"));
html->file = fn_open (html->handle, "w");
html->bg = parse_color (opt (d, o, "background-color", "#FFFFFFFFFFFF"));
html->fg = parse_color (opt (d, o, "foreground-color", "#000000000000"));
html->file = fn_open (html->handle, "w");
{
char *file_name = xr_draw_png_chart (item->chart,
html->chart_file_name,
{
char *file_name = xr_draw_png_chart (item->chart,
html->chart_file_name,
&html->fg, &html->bg);
if (file_name != NULL)
{
&html->fg, &html->bg);
if (file_name != NULL)
{
if (html->chart_file_name)
{
char *file_name = xr_write_png_image (
if (html->chart_file_name)
{
char *file_name = xr_write_png_image (
- item->image, html->chart_file_name, ++html->chart_cnt);
+ item->image, html->chart_file_name, ++html->n_charts);
if (file_name != NULL)
{
fprintf (html->file, "<img src=\"%s\">", file_name);
if (file_name != NULL)
{
fprintf (html->file, "<img src=\"%s\">", file_name);
char *chart_file_name;
FILE *file;
char *chart_file_name;
FILE *file;
struct ll_list preamble_list;
struct ll_list token_list;
struct ll_list preamble_list;
struct ll_list token_list;
tex->handle = fh;
tex->chart_file_name = parse_chart_file_name (opt (d, o, "charts",
fh_get_file_name (fh)));
tex->handle = fh;
tex->chart_file_name = parse_chart_file_name (opt (d, o, "charts",
fh_get_file_name (fh)));
tex->bg = parse_color (opt (d, o, "background-color", "#FFFFFFFFFFFF"));
tex->fg = parse_color (opt (d, o, "foreground-color", "#000000000000"));
tex->bg = parse_color (opt (d, o, "background-color", "#FFFFFFFFFFFF"));
tex->fg = parse_color (opt (d, o, "foreground-color", "#000000000000"));
{
char *file_name = xr_draw_png_chart (item->chart,
tex->chart_file_name,
{
char *file_name = xr_draw_png_chart (item->chart,
tex->chart_file_name,
&tex->fg, &tex->bg);
if (file_name != NULL)
{
&tex->fg, &tex->bg);
if (file_name != NULL)
{
case OUTPUT_ITEM_IMAGE:
{
char *file_name = xr_write_png_image (
case OUTPUT_ITEM_IMAGE:
{
char *file_name = xr_write_png_image (
- item->image, tex->chart_file_name, tex->chart_cnt++);
+ item->image, tex->chart_file_name, tex->n_charts++);
if (file_name != NULL)
{
shipout (&tex->token_list, "\\includegraphics{%s}\n", file_name);
if (file_name != NULL)
{
shipout (&tex->token_list, "\\includegraphics{%s}\n", file_name);
{
const struct caseproto *proto;
struct casereader *reader;
{
const struct caseproto *proto;
struct casereader *reader;
/* When the user executes a number of snippets of syntax in a
row, none of which read from the active dataset, the GUI becomes
/* When the user executes a number of snippets of syntax in a
row, none of which read from the active dataset, the GUI becomes
it is reused the next time syntax is run, without wrapping
it in another layer. */
proto = psppire_data_store_get_proto (pdw->data_store);
it is reused the next time syntax is run, without wrapping
it in another layer. */
proto = psppire_data_store_get_proto (pdw->data_store);
- case_cnt = psppire_data_store_get_case_count (pdw->data_store);
- reader = lazy_casereader_create (proto, case_cnt,
+ n_cases = psppire_data_store_get_case_count (pdw->data_store);
+ reader = lazy_casereader_create (proto, n_cases,
create_casereader_from_data_store,
pdw->data_store, &pdw->lazy_serial);
dataset_set_source (pdw->dataset, reader);
create_casereader_from_data_store,
pdw->data_store, &pdw->lazy_serial);
dataset_set_source (pdw->dataset, reader);
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (tree_model);
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (tree_model);
- return psppire_dict_get_var_cnt (store->dict);
+ return psppire_dict_get_n_vars (store->dict);
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
- while (col >= psppire_dict_get_var_cnt (store->dict))
+ while (col >= psppire_dict_get_n_vars (store->dict))
{
const struct variable *var =
psppire_dict_insert_variable (store->dict,
{
const struct variable *var =
psppire_dict_insert_variable (store->dict,
- psppire_dict_get_var_cnt (store->dict),
+ psppire_dict_get_n_vars (store->dict),
NULL);
g_return_val_if_fail (var, FALSE);
}
NULL);
g_return_val_if_fail (var, FALSE);
}
size_t
psppire_data_store_get_value_count (const PsppireDataStore *store)
{
size_t
psppire_data_store_get_value_count (const PsppireDataStore *store)
{
- return psppire_dict_get_value_cnt (store->dict);
+ return psppire_dict_get_n_values (store->dict);
}
const struct caseproto *
}
const struct caseproto *
{
PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
{
PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
- size_t n_split_vars = dict_get_split_cnt (dict->dict);
+ size_t n_split_vars = dict_get_n_splits (dict->dict);
GtkWidget *split_status_area =
get_widget_assert (de->builder, "split-file-status-area");
GtkWidget *split_status_area =
get_widget_assert (de->builder, "split-file-status-area");
static void
enable_save (PsppireDataWindow *dw)
{
static void
enable_save (PsppireDataWindow *dw)
{
- gboolean enable = psppire_dict_get_var_cnt (dw->dict) > 0;
+ gboolean enable = psppire_dict_get_n_vars (dw->dict) > 0;
GAction *save_as = g_action_map_lookup_action (G_ACTION_MAP (dw), "save-as");
GAction *save = g_action_map_lookup_action (G_ACTION_MAP (dw), "save");
GAction *save_as = g_action_map_lookup_action (G_ACTION_MAP (dw), "save-as");
GAction *save = g_action_map_lookup_action (G_ACTION_MAP (dw), "save");
bool
psppire_data_window_is_empty (PsppireDataWindow *dw)
{
bool
psppire_data_window_is_empty (PsppireDataWindow *dw)
{
- return psppire_dict_get_var_cnt (dw->dict) == 0;
+ return psppire_dict_get_n_vars (dw->dict) == 0;
gtk_text_buffer_set_text (buffer, "", 0);
gtk_text_buffer_set_text (buffer, "", 0);
- for (i = 0 ; i < dict_get_document_line_cnt (pda->dict->dict); ++i)
+ for (i = 0 ; i < dict_get_document_n_lines (pda->dict->dict); ++i)
add_line_to_buffer (buffer, dict_get_document_line (pda->dict->dict, i));
}
add_line_to_buffer (buffer, dict_get_document_line (pda->dict->dict, i));
}
GtkTreeIter iter;
gint i;
GtkTreeIter iter;
gint i;
- const gint n_funcs = expr_get_function_cnt ();
+ const gint n_funcs = expr_get_n_functions ();
liststore = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
liststore = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
gtk_list_store_set (liststore, &iter,
COMPUTE_COL_NAME, expr_operation_get_name (op),
COMPUTE_COL_USAGE, expr_operation_get_prototype (op),
gtk_list_store_set (liststore, &iter,
COMPUTE_COL_NAME, expr_operation_get_name (op),
COMPUTE_COL_USAGE, expr_operation_get_prototype (op),
- COMPUTE_COL_ARITY, expr_operation_get_arg_cnt (op),
+ COMPUTE_COL_ARITY, expr_operation_get_n_args (op),
GtkTreeModel *liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (act->tv));
GtkTreeModel *liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (act->tv));
- gint n_vars = dict_get_split_cnt (pda->dict->dict);
+ gint n_vars = dict_get_n_splits (pda->dict->dict);
gtk_list_store_clear (GTK_LIST_STORE (liststore));
gtk_list_store_clear (GTK_LIST_STORE (liststore));
{
PsppireDict *dict = PSPPIRE_DICT (list);
{
PsppireDict *dict = PSPPIRE_DICT (list);
- return psppire_dict_get_var_cnt (dict);
+ return psppire_dict_get_n_vars (dict);
PsppireDict *dict = PSPPIRE_DICT (list);
PsppireDict *dict = PSPPIRE_DICT (list);
- if (id >= psppire_dict_get_var_cnt (dict))
+ if (id >= psppire_dict_get_n_vars (dict))
{
gtk_button_set_label (GTK_BUTTON (button), _("Var"));
}
{
gtk_button_set_label (GTK_BUTTON (button), _("Var"));
}
struct dictionary *old_dict = dict->dict;
struct dictionary *old_dict = dict->dict;
- guint old_n = dict_get_var_cnt (dict->dict);
- guint new_n = dict_get_var_cnt (d);
+ guint old_n = dict_get_n_vars (dict->dict);
+ guint new_n = dict_get_n_vars (d);
dict->dict = dict_ref (d);
dict_unref (old_dict);
dict->dict = dict_ref (d);
dict_unref (old_dict);
g_return_if_fail (d);
g_return_if_fail (d->dict);
g_return_if_fail (PSPPIRE_IS_DICT (d));
g_return_if_fail (d);
g_return_if_fail (d->dict);
g_return_if_fail (PSPPIRE_IS_DICT (d));
- size_t varcnt = dict_get_var_cnt (d->dict);
+ size_t varcnt = dict_get_n_vars (d->dict);
g_return_if_fail (first < varcnt);
g_return_if_fail (first >= 0);
g_return_if_fail (n > 0);
g_return_if_fail (first < varcnt);
g_return_if_fail (first >= 0);
g_return_if_fail (n > 0);
if (! dict_id_is_valid (d->dict, name, false))
return FALSE;
if (! dict_id_is_valid (d->dict, name, false))
return FALSE;
- if (idx < dict_get_var_cnt (d->dict))
+ if (idx < dict_get_n_vars (d->dict))
{
/* This is an existing variable? */
struct variable * var = dict_get_var (d->dict, idx);
{
/* This is an existing variable? */
struct variable * var = dict_get_var (d->dict, idx);
g_return_val_if_fail (d, NULL);
g_return_val_if_fail (d->dict, NULL);
g_return_val_if_fail (d, NULL);
g_return_val_if_fail (d->dict, NULL);
- if (dict_get_var_cnt (d->dict) <= idx)
+ if (dict_get_n_vars (d->dict) <= idx)
return NULL;
return dict_get_var (d->dict, idx);
return NULL;
return dict_get_var (d->dict, idx);
/* Return the number of variables in the dictionary */
gint
/* Return the number of variables in the dictionary */
gint
-psppire_dict_get_var_cnt (const PsppireDict *d)
+psppire_dict_get_n_vars (const PsppireDict *d)
{
g_return_val_if_fail (d, -1);
g_return_val_if_fail (d->dict, -1);
{
g_return_val_if_fail (d, -1);
g_return_val_if_fail (d->dict, -1);
- return dict_get_var_cnt (d->dict);
+ return dict_get_n_vars (d->dict);
}
/* Return the number of `union value's in the dictionary */
size_t
}
/* Return the number of `union value's in the dictionary */
size_t
-psppire_dict_get_value_cnt (const PsppireDict *d)
+psppire_dict_get_n_values (const PsppireDict *d)
{
g_return_val_if_fail (d, -1);
g_return_val_if_fail (d->dict, -1);
{
g_return_val_if_fail (d, -1);
g_return_val_if_fail (d->dict, -1);
- if (n < 0 || n >= psppire_dict_get_var_cnt (dict))
+ if (n < 0 || n >= psppire_dict_get_n_vars (dict))
{
iter->stamp = 0;
iter->user_data = NULL;
{
iter->stamp = 0;
iter->user_data = NULL;
idx = var_get_dict_index (var);
idx = var_get_dict_index (var);
- if (idx + 1 >= psppire_dict_get_var_cnt (dict))
+ if (idx + 1 >= psppire_dict_get_n_vars (dict))
{
iter->user_data = NULL;
iter->stamp = 0;
{
iter->user_data = NULL;
iter->stamp = 0;
PsppireDict *dict = PSPPIRE_DICT (model);
if (iter == NULL)
PsppireDict *dict = PSPPIRE_DICT (model);
if (iter == NULL)
- return psppire_dict_get_var_cnt (dict);
+ return psppire_dict_get_n_vars (dict);
if (parent)
return FALSE;
if (parent)
return FALSE;
- if (n >= psppire_dict_get_var_cnt (dict))
+ if (n >= psppire_dict_get_n_vars (dict))
return FALSE;
iter->stamp = dict->stamp;
return FALSE;
iter->stamp = dict->stamp;
void psppire_dict_delete_var (PsppireDict *s, gint idx);
/* Return the number of variables in the dictionary */
void psppire_dict_delete_var (PsppireDict *s, gint idx);
/* Return the number of variables in the dictionary */
-gint psppire_dict_get_var_cnt (const PsppireDict *d);
+gint psppire_dict_get_n_vars (const PsppireDict *d);
/* Return the number of `union value's in the dictionary */
/* Return the number of `union value's in the dictionary */
-size_t psppire_dict_get_value_cnt (const PsppireDict *d);
+size_t psppire_dict_get_n_values (const PsppireDict *d);
/* Returns the prototype for the cases that match the dictionary */
const struct caseproto *psppire_dict_get_proto (const PsppireDict *d);
/* Returns the prototype for the cases that match the dictionary */
const struct caseproto *psppire_dict_get_proto (const PsppireDict *d);
"preview purposes in the following screens. ",
"Only the first %zu lines of the file will be shown for "
"preview purposes in the following screens. ",
"preview purposes in the following screens. ",
"Only the first %zu lines of the file will be shown for "
"preview purposes in the following screens. ",
- ia->text_file->line_cnt),
- ia->text_file->line_cnt);
+ ia->text_file->n_lines),
+ ia->text_file->n_lines);
static struct casereader *
textfile_create_reader (PsppireImportAssistant *ia)
{
static struct casereader *
textfile_create_reader (PsppireImportAssistant *ia)
{
- int n_vars = dict_get_var_cnt (ia->dict);
+ int n_vars = dict_get_n_vars (ia->dict);
PsppireImportAssistant *ia = PSPPIRE_IMPORT_ASSISTANT (data);
struct caseproto *proto = caseproto_create();
PsppireImportAssistant *ia = PSPPIRE_IMPORT_ASSISTANT (data);
struct caseproto *proto = caseproto_create();
- for (int i = 0; i < dict_get_var_cnt (ia->dict); i++)
+ for (int i = 0; i < dict_get_n_vars (ia->dict); i++)
{
const struct variable *var = dict_get_var (ia->dict, i);
int width = var_get_width (var);
{
const struct variable *var = dict_get_var (ia->dict, i);
int width = var_get_width (var);
static void
apply_dict (const struct dictionary *dict, struct string *s)
{
static void
apply_dict (const struct dictionary *dict, struct string *s)
{
- size_t var_cnt = dict_get_var_cnt (dict);
+ size_t n_vars = dict_get_n_vars (dict);
- for (size_t i = 0; i < var_cnt; i++)
+ for (size_t i = 0; i < n_vars; i++)
{
struct variable *var = dict_get_var (dict, i);
const char *name = var_get_name (var);
{
struct variable *var = dict_get_var (dict, i);
const char *name = var_get_name (var);
static void
formats_append_syntax (const PsppireImportAssistant *ia, struct string *s)
{
static void
formats_append_syntax (const PsppireImportAssistant *ia, struct string *s)
{
- int i;
- int var_cnt;
-
g_return_if_fail (ia->dict);
ds_put_cstr (s, " /VARIABLES=\n");
g_return_if_fail (ia->dict);
ds_put_cstr (s, " /VARIABLES=\n");
- var_cnt = dict_get_var_cnt (ia->dict);
- for (i = 0; i < var_cnt; i++)
+ int n_vars = dict_get_n_vars (ia->dict);
+ for (int i = 0; i < n_vars; i++)
{
struct variable *var = dict_get_var (ia->dict, i);
char format_string[FMT_STRING_LEN_MAX + 1];
fmt_to_string (var_get_print_format (var), format_string);
ds_put_format (s, " %s %s%s\n",
var_get_name (var), format_string,
{
struct variable *var = dict_get_var (ia->dict, i);
char format_string[FMT_STRING_LEN_MAX + 1];
fmt_to_string (var_get_print_format (var), format_string);
ds_put_format (s, " %s %s%s\n",
var_get_name (var), format_string,
- i == var_cnt - 1 ? "." : "");
+ i == n_vars - 1 ? "." : "");
struct string input;
ds_init_empty (&input);
struct string input;
ds_init_empty (&input);
- for (tf->line_cnt = 0; tf->line_cnt < MAX_PREVIEW_LINES; tf->line_cnt++)
+ for (tf->n_lines = 0; tf->n_lines < MAX_PREVIEW_LINES; tf->n_lines++)
{
ds_clear (&input);
if (!line_reader_read (reader, &input, MAX_LINE_LEN + 1)
{
ds_clear (&input);
if (!line_reader_read (reader, &input, MAX_LINE_LEN + 1)
"a text file."),
tf->file_name, MAX_LINE_LEN);
line_reader_close (reader);
"a text file."),
tf->file_name, MAX_LINE_LEN);
line_reader_close (reader);
- for (i = 0; i < tf->line_cnt; i++)
+ for (i = 0; i < tf->n_lines; i++)
g_free (tf->lines[i].string);
g_free (tf->lines[i].string);
ds_destroy (&input);
return;
}
ds_destroy (&input);
return;
}
- tf->lines[tf->line_cnt]
= recode_substring_pool ("UTF-8",
line_reader_get_encoding (reader),
input.ss, NULL);
}
ds_destroy (&input);
= recode_substring_pool ("UTF-8",
line_reader_get_encoding (reader),
input.ss, NULL);
}
ds_destroy (&input);
{
int i;
msg (ME, _("`%s' is empty."), tf->file_name);
line_reader_close (reader);
{
int i;
msg (ME, _("`%s' is empty."), tf->file_name);
line_reader_close (reader);
- for (i = 0; i < tf->line_cnt; i++)
+ for (i = 0; i < tf->n_lines; i++)
g_free (tf->lines[i].string);
g_free (tf->lines[i].string);
- if (tf->line_cnt < MAX_PREVIEW_LINES)
+ if (tf->n_lines < MAX_PREVIEW_LINES)
- tf->total_lines = tf->line_cnt;
+ tf->total_lines = tf->n_lines;
tf->total_is_exact = true;
}
else
tf->total_is_exact = true;
}
else
off_t position = line_reader_tell (reader);
if (fstat (line_reader_fileno (reader), &s) == 0 && position > 0)
{
off_t position = line_reader_tell (reader);
if (fstat (line_reader_fileno (reader), &s) == 0 && position > 0)
{
- tf->total_lines = (double) tf->line_cnt / position * s.st_size;
+ tf->total_lines = (double) tf->n_lines / position * s.st_size;
tf->total_is_exact = false;
}
else
tf->total_is_exact = false;
}
else
g_value_set_int (value, text_file->maximum_lines);
break;
case PROP_LINE_COUNT:
g_value_set_int (value, text_file->maximum_lines);
break;
case PROP_LINE_COUNT:
- g_value_set_int (value, text_file->line_cnt);
+ g_value_set_int (value, text_file->n_lines);
break;
case PROP_FILE_NAME:
g_value_set_string (value, text_file->file_name);
break;
case PROP_FILE_NAME:
g_value_set_string (value, text_file->file_name);
- if (n >= file->line_cnt)
+ if (n >= file->n_lines)
return FALSE;
iter->user_data = GINT_TO_POINTER (n);
return FALSE;
iter->user_data = GINT_TO_POINTER (n);
gint n = GPOINTER_TO_INT (iter->user_data) + 1;
gint n = GPOINTER_TO_INT (iter->user_data) + 1;
- if (n >= file->line_cnt)
+ if (n >= file->n_lines)
return FALSE;
iter->user_data = GINT_TO_POINTER (n);
return FALSE;
iter->user_data = GINT_TO_POINTER (n);
{
PsppireTextFile *file = PSPPIRE_TEXT_FILE (tree_model);
g_assert (iter == NULL);
{
PsppireTextFile *file = PSPPIRE_TEXT_FILE (tree_model);
g_assert (iter == NULL);
}
static GtkTreeModelFlags
}
static GtkTreeModelFlags
g_return_val_if_fail (file, FALSE);
g_return_val_if_fail (file, FALSE);
- if (n >= file->line_cnt)
+ if (n >= file->n_lines)
{
iter->stamp = -1;
iter->user_data = NULL;
{
iter->stamp = -1;
iter->user_data = NULL;
gint n = GPOINTER_TO_INT (iter->user_data);
gint n = GPOINTER_TO_INT (iter->user_data);
- g_return_if_fail (n < file->line_cnt);
+ g_return_if_fail (n < file->n_lines);
{
PsppireTextFile *tf = PSPPIRE_TEXT_FILE (object);
{
PsppireTextFile *tf = PSPPIRE_TEXT_FILE (object);
- for (int i = 0; i < tf->line_cnt; i++)
+ for (int i = 0; i < tf->n_lines; i++)
g_free (tf->lines[i].string);
g_free (tf->encoding);
g_free (tf->lines[i].string);
g_free (tf->encoding);
/* The first several lines of the file. These copies which are UTF8 encoded,
regardless of the file encoding. */
struct substring lines[MAX_PREVIEW_LINES];
/* The first several lines of the file. These copies which are UTF8 encoded,
regardless of the file encoding. */
struct substring lines[MAX_PREVIEW_LINES];
gulong total_lines; /* Number of lines in file. */
gboolean total_is_exact; /* Is total_lines exact (or an estimate)? */
gulong total_lines; /* Number of lines in file. */
gboolean total_is_exact; /* Is total_lines exact (or an estimate)? */
PsppireDict *dict = NULL;
g_object_get (var_sheet, "data-model", &dict, NULL);
PsppireDict *dict = NULL;
g_object_get (var_sheet, "data-model", &dict, NULL);
- int n_rows = psppire_dict_get_var_cnt (dict);
+ int n_rows = psppire_dict_get_n_vars (dict);
if (row > n_rows)
return;
if (row > n_rows)
return;
if (!check_caseproto (mc, proto, casereader_get_proto (reader),
"casereader"))
return;
if (!check_caseproto (mc, proto, casereader_get_proto (reader),
"casereader"))
return;
- else if (casereader_get_case_cnt (reader) != n_rows)
+ else if (casereader_get_n_cases (reader) != n_rows)
- if (casereader_get_case_cnt (reader) == CASENUMBER_MAX
+ if (casereader_get_n_cases (reader) == CASENUMBER_MAX
&& casereader_count_cases (reader) == n_rows)
mc_error (mc, "datasheet casereader has unknown case count");
else
mc_error (mc, "casereader row count (%lu) does not match "
"expected (%zu)",
&& casereader_count_cases (reader) == n_rows)
mc_error (mc, "datasheet casereader has unknown case count");
else
mc_error (mc, "casereader row count (%lu) does not match "
"expected (%zu)",
- (unsigned long int) casereader_get_case_cnt (reader),
+ (unsigned long int) casereader_get_n_cases (reader),
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int ins_perm_cnt;
+ unsigned int ins_n_perms;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (ins_perm_cnt = 0;
- ins_perm_cnt == 0 || next_permutation (insertions, cnt);
- ins_perm_cnt++)
+ for (ins_n_perms = 0;
+ ins_n_perms == 0 || next_permutation (insertions, cnt);
+ ins_n_perms++)
- unsigned int del_perm_cnt;
+ unsigned int del_n_perms;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
- for (del_perm_cnt = 0;
- del_perm_cnt == 0 || next_permutation (deletions, cnt);
- del_perm_cnt++)
+ for (del_n_perms = 0;
+ del_n_perms == 0 || next_permutation (deletions, cnt);
+ del_n_perms++)
test_insert_delete (insertions, deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
- check (del_perm_cnt == factorial (cnt));
+ check (del_n_perms == factorial (cnt));
- check (ins_perm_cnt == factorial (cnt));
+ check (ins_n_perms == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
test_insert_delete (values, values, cnt);
test_insert_delete (values, values, cnt);
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (insertions, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (insertions, cnt);
+ n_permutations++)
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
{
int *values, *changed_values;
struct element *elements;
{
int *values, *changed_values;
struct element *elements;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
{
for (i = 0; i < cnt; i++)
{
{
for (i = 0; i < cnt; i++)
{
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (values);
free (changed_values);
free (values);
free (changed_values);
94906266, 134217728, 189812532, 268435456, 379625063, 536870912,
759250125, 1073741824, 1518500250, 2147483648, 3037000500,
};
94906266, 134217728, 189812532, 268435456, 379625063, 536870912,
759250125, 1073741824, 1518500250, 2147483648, 3037000500,
};
- size_t threshold_cnt = sizeof thresholds / sizeof *thresholds;
+ size_t n_thresholds = sizeof thresholds / sizeof *thresholds;
- for (i = 0; i < threshold_cnt; i++)
+ for (i = 0; i < n_thresholds; i++)
if (thresholds[i] > n)
break;
return i - 1;
if (thresholds[i] > n)
break;
return i - 1;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int ins_perm_cnt;
+ unsigned int ins_n_perms;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (ins_perm_cnt = 0;
- ins_perm_cnt == 0 || next_permutation (insertions, cnt);
- ins_perm_cnt++)
+ for (ins_n_perms = 0;
+ ins_n_perms == 0 || next_permutation (insertions, cnt);
+ ins_n_perms++)
- unsigned int del_perm_cnt;
+ unsigned int del_n_perms;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
- for (del_perm_cnt = 0;
- del_perm_cnt == 0 || next_permutation (deletions, cnt);
- del_perm_cnt++)
+ for (del_n_perms = 0;
+ del_n_perms == 0 || next_permutation (deletions, cnt);
+ del_n_perms++)
test_insert_delete (insertions, deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
- check (del_perm_cnt == factorial (cnt));
+ check (del_n_perms == factorial (cnt));
- check (ins_perm_cnt == factorial (cnt));
+ check (ins_n_perms == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
test_insert_delete (values, values, cnt);
test_insert_delete (values, values, cnt);
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (insertions, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (insertions, cnt);
+ n_permutations++)
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (inc_pat = 0; inc_pat < (1u << max_elems); inc_pat++)
{
struct bt bt;
for (inc_pat = 0; inc_pat < (1u << max_elems); inc_pat++)
{
struct bt bt;
int i;
/* Insert the values in the pattern into BT. */
int i;
/* Insert the values in the pattern into BT. */
for (i = 0; i < max_elems; i++)
if (inc_pat & (1u << i))
{
for (i = 0; i < max_elems; i++)
if (inc_pat & (1u << i))
{
- values[elem_cnt] = elements[elem_cnt].data = i;
- check (bt_insert (&bt, &elements[elem_cnt].node) == NULL);
- elem_cnt++;
+ values[n_elems] = elements[n_elems].data = i;
+ check (bt_insert (&bt, &elements[n_elems].node) == NULL);
+ n_elems++;
- check_bt (&bt, values, elem_cnt);
+ check_bt (&bt, values, n_elems);
/* Try find_ge and find_le for each possible element value. */
for (i = -1; i <= max_elems; i++)
/* Try find_ge and find_le for each possible element value. */
for (i = -1; i <= max_elems; i++)
- for (j = 0; j < elem_cnt; j++)
+ for (j = 0; j < n_elems; j++)
{
if (ge == NULL && values[j] >= i)
ge = &elements[j].node;
{
if (ge == NULL && values[j] >= i)
ge = &elements[j].node;
{
int *values, *changed_values;
struct element *elements;
{
int *values, *changed_values;
struct element *elements;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
{
for (i = 0; i < cnt; i++)
{
{
for (i = 0; i < cnt; i++)
{
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (values);
free (changed_values);
free (values);
free (changed_values);
expected_perms (int *values, size_t cnt)
{
size_t i, j;
expected_perms (int *values, size_t cnt)
{
size_t i, j;
- perm_cnt = factorial (cnt);
+ n_perms = factorial (cnt);
for (i = 0; i < cnt; i = j)
{
for (j = i + 1; j < cnt; j++)
if (values[i] != values[j])
break;
for (i = 0; i < cnt; i = j)
{
for (j = i + 1; j < cnt; j++)
if (values[i] != values[j])
break;
- perm_cnt /= factorial (j - i);
+ n_perms /= factorial (j - i);
}
/* Tests whether PARTS is a K-part integer composition of N.
}
/* Tests whether PARTS is a K-part integer composition of N.
struct heap *h;
struct element *elements;
int *values;
struct heap *h;
struct element *elements;
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
int i;
values = xnmalloc (cnt, sizeof *values);
values[i] = i;
h = heap_create (compare_elements, &aux_data);
values[i] = i;
h = heap_create (compare_elements, &aux_data);
- permutation_cnt = 0;
- while (permutation_cnt == 0 || next_permutation (values, cnt))
+ n_permutations = 0;
+ while (n_permutations == 0 || next_permutation (values, cnt))
heap_delete (h, heap_minimum (h));
}
check (heap_is_empty (h));
heap_delete (h, heap_minimum (h));
}
check (heap_is_empty (h));
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
heap_destroy (h);
free (values);
free (elements);
heap_destroy (h);
free (values);
free (elements);
for (cnt = 1; cnt <= max_elems; cnt++)
{
for (cnt = 1; cnt <= max_elems; cnt++)
{
- unsigned int composition_cnt;
+ unsigned int n_compositions;
int *values;
int *sorted_values;
struct element *elements;
int *values;
int *sorted_values;
struct element *elements;
sorted_values = xnmalloc (cnt, sizeof *sorted_values);
elements = xnmalloc (cnt, sizeof *elements);
sorted_values = xnmalloc (cnt, sizeof *sorted_values);
elements = xnmalloc (cnt, sizeof *elements);
- unique_cnt = 0;
- composition_cnt = 0;
- while (next_composition (cnt, &unique_cnt, dups))
+ n_uniques = 0;
+ n_compositions = 0;
+ while (next_composition (cnt, &n_uniques, dups))
{
struct heap *h;
int i, j, k;
{
struct heap *h;
int i, j, k;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
- for (i = 0; i < unique_cnt; i++)
+ for (i = 0; i < n_uniques; i++)
for (j = 0; j < dups[i]; j++)
{
values[k] = i;
for (j = 0; j < dups[i]; j++)
{
values[k] = i;
check (k == cnt);
h = heap_create (compare_elements, &aux_data);
check (k == cnt);
h = heap_create (compare_elements, &aux_data);
- permutation_cnt = 0;
- while (permutation_cnt == 0 || next_permutation (values, cnt))
+ n_permutations = 0;
+ while (n_permutations == 0 || next_permutation (values, cnt))
heap_delete (h, heap_minimum (h));
}
check (heap_is_empty (h));
heap_delete (h, heap_minimum (h));
}
check (heap_is_empty (h));
- check (permutation_cnt == expected_perms (values, cnt));
+ check (n_permutations == expected_perms (values, cnt));
- check (composition_cnt == 1 << (cnt - 1));
+ check (n_compositions == 1 << (cnt - 1));
free (dups);
free (values);
free (dups);
free (values);
struct heap *h;
struct element *elements;
int *insert, *delete;
struct heap *h;
struct element *elements;
int *insert, *delete;
- unsigned int insert_perm_cnt;
+ unsigned int insert_n_perms;
int i;
insert = xnmalloc (cnt, sizeof *insert);
int i;
insert = xnmalloc (cnt, sizeof *insert);
}
h = heap_create (compare_elements, &aux_data);
}
h = heap_create (compare_elements, &aux_data);
- insert_perm_cnt = 0;
- while (insert_perm_cnt == 0 || next_permutation (insert, cnt))
+ insert_n_perms = 0;
+ while (insert_n_perms == 0 || next_permutation (insert, cnt))
- unsigned int delete_perm_cnt = 0;
+ unsigned int delete_n_perms = 0;
- while (delete_perm_cnt == 0 || next_permutation (delete, cnt))
+ while (delete_n_perms == 0 || next_permutation (delete, cnt))
check (heap_node_to_element (heap_minimum (h))->x == new_min);
}
check (heap_is_empty (h));
check (heap_node_to_element (heap_minimum (h))->x == new_min);
}
check (heap_is_empty (h));
- check (delete_perm_cnt == factorial (cnt));
- insert_perm_cnt++;
+ check (delete_n_perms == factorial (cnt));
+ insert_n_perms++;
- check (insert_perm_cnt == factorial (cnt));
+ check (insert_n_perms == factorial (cnt));
heap_destroy (h);
free (insert);
free (delete);
heap_destroy (h);
free (insert);
free (delete);
struct heap *h;
struct element *elements;
int *insert, *delete;
struct heap *h;
struct element *elements;
int *insert, *delete;
- unsigned int insert_perm_cnt;
+ unsigned int insert_n_perms;
int i;
insert = xnmalloc (cnt, sizeof *insert);
int i;
insert = xnmalloc (cnt, sizeof *insert);
insert[i] = i;
h = heap_create (compare_elements, &aux_data);
insert[i] = i;
h = heap_create (compare_elements, &aux_data);
- insert_perm_cnt = 0;
- while (insert_perm_cnt == 0 || next_permutation (insert, cnt))
+ insert_n_perms = 0;
+ while (insert_n_perms == 0 || next_permutation (insert, cnt))
{
for (i = 0; i < cnt; i++)
elements[i].x = insert[i];
{
for (i = 0; i < cnt; i++)
elements[i].x = insert[i];
check (heap_node_to_element (heap_minimum (h))->x == new_min);
}
check (heap_is_empty (h));
check (heap_node_to_element (heap_minimum (h))->x == new_min);
}
check (heap_is_empty (h));
- check (insert_perm_cnt == factorial (cnt));
+ check (insert_n_perms == factorial (cnt));
heap_destroy (h);
free (insert);
free (delete);
heap_destroy (h);
free (insert);
free (delete);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int ins_perm_cnt;
+ unsigned int ins_n_perms;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (ins_perm_cnt = 0;
- ins_perm_cnt == 0 || next_permutation (insertions, cnt);
- ins_perm_cnt++)
+ for (ins_n_perms = 0;
+ ins_n_perms == 0 || next_permutation (insertions, cnt);
+ ins_n_perms++)
- unsigned int del_perm_cnt;
+ unsigned int del_n_perms;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
- for (del_perm_cnt = 0;
- del_perm_cnt == 0 || next_permutation (deletions, cnt);
- del_perm_cnt++)
+ for (del_n_perms = 0;
+ del_n_perms == 0 || next_permutation (deletions, cnt);
+ del_n_perms++)
test_insert_delete (insertions, deletions, cnt, hash);
test_insert_delete (insertions, deletions, cnt, hash);
- check (del_perm_cnt == factorial (cnt));
+ check (del_n_perms == factorial (cnt));
- check (ins_perm_cnt == factorial (cnt));
+ check (ins_n_perms == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
test_insert_delete (values, values, cnt, hash);
test_insert_delete (values, values, cnt, hash);
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (insertions, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (insertions, cnt);
+ n_permutations++)
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt, hash);
}
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt, hash);
}
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
{
int *values, *changed_values;
struct element *elements;
{
int *values, *changed_values;
struct element *elements;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
{
for (i = 0; i < cnt; i++)
{
{
for (i = 0; i < cnt; i++)
{
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (values);
free (changed_values);
free (values);
free (changed_values);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int ins_perm_cnt;
+ unsigned int ins_n_perms;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (ins_perm_cnt = 0;
- ins_perm_cnt == 0 || next_permutation (insertions, cnt);
- ins_perm_cnt++)
+ for (ins_n_perms = 0;
+ ins_n_perms == 0 || next_permutation (insertions, cnt);
+ ins_n_perms++)
- unsigned int del_perm_cnt;
+ unsigned int del_n_perms;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
- for (del_perm_cnt = 0;
- del_perm_cnt == 0 || next_permutation (deletions, cnt);
- del_perm_cnt++)
+ for (del_n_perms = 0;
+ del_n_perms == 0 || next_permutation (deletions, cnt);
+ del_n_perms++)
test_insert_delete (insertions, deletions, cnt, hash, 1);
test_insert_delete (insertions, deletions, cnt, hash, 1);
- check (del_perm_cnt == factorial (cnt));
+ check (del_n_perms == factorial (cnt));
- check (ins_perm_cnt == factorial (cnt));
+ check (ins_n_perms == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
test_insert_delete (values, values, cnt, hash, cnt / 2);
test_insert_delete (values, values, cnt, hash, cnt / 2);
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (insertions, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (insertions, cnt);
+ n_permutations++)
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt, hash, cnt);
}
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt, hash, cnt);
}
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
int *values, *changed_values;
struct hmapx_node **nodes;
struct element *elements;
int *values, *changed_values;
struct hmapx_node **nodes;
struct element *elements;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
{
for (i = 0; i < cnt; i++)
{
{
for (i = 0; i < cnt; i++)
{
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (values);
free (changed_values);
free (values);
free (changed_values);
struct hmapx_node **nodes;
struct element *elements;
struct element replacement;
struct hmapx_node **nodes;
struct element *elements;
struct element replacement;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
{
for (i = 0; i < cnt; i++)
{
{
for (i = 0; i < cnt; i++)
{
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (values);
free (changed_values);
free (values);
free (changed_values);
expected_perms (int *values, size_t cnt)
{
size_t i, j;
expected_perms (int *values, size_t cnt)
{
size_t i, j;
- perm_cnt = factorial (cnt);
+ n_perms = factorial (cnt);
for (i = 0; i < cnt; i = j)
{
for (j = i + 1; j < cnt; j++)
if (values[i] != values[j])
break;
for (i = 0; i < cnt; i = j)
{
for (j = i + 1; j < cnt; j++)
if (values[i] != values[j])
break;
- perm_cnt /= factorial (j - i);
+ n_perms /= factorial (j - i);
}
/* Tests ll_min and ll_max. */
}
/* Tests ll_min and ll_max. */
int *values;
int *new_values = xnmalloc (cnt, sizeof *values);
int *values;
int *new_values = xnmalloc (cnt, sizeof *values);
allocate_ascending (cnt, &list, &elems, &elemp, &values);
allocate_ascending (cnt, &list, &elems, &elemp, &values);
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
{
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
{
&& ll_to_element (max)->x == max_int);
}
}
&& ll_to_element (max)->x == max_int);
}
}
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
check_list_contents (&list, values, cnt);
free_elements (cnt, elems, elemp, values);
check_list_contents (&list, values, cnt);
free_elements (cnt, elems, elemp, values);
int *old_values = xnmalloc (cnt, sizeof *values);
int *new_values = xnmalloc (cnt, sizeof *values);
int *old_values = xnmalloc (cnt, sizeof *values);
int *new_values = xnmalloc (cnt, sizeof *values);
allocate_ascending (cnt, &list, &elems, NULL, &values);
allocate_ascending (cnt, &list, &elems, NULL, &values);
extract_values (&list, old_values, cnt);
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
extract_values (&list, old_values, cnt);
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
sizeof *new_values,
compare_ints, NULL) > 0);
memcpy (old_values, new_values, (cnt) * sizeof *old_values);
sizeof *new_values,
compare_ints, NULL) > 0);
memcpy (old_values, new_values, (cnt) * sizeof *old_values);
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
check_list_contents (&list, values, cnt);
check_list_contents (&list, values, cnt);
ll_reverse (ll_head (&list), ll_null (&list));
extract_values (&list, old_values, cnt);
while (ll_prev_permutation (ll_head (&list), ll_null (&list),
ll_reverse (ll_head (&list), ll_null (&list));
extract_values (&list, old_values, cnt);
while (ll_prev_permutation (ll_head (&list), ll_null (&list),
sizeof *new_values,
compare_ints, NULL) < 0);
memcpy (old_values, new_values, (cnt) * sizeof *old_values);
sizeof *new_values,
compare_ints, NULL) < 0);
memcpy (old_values, new_values, (cnt) * sizeof *old_values);
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
ll_reverse (ll_head (&list), ll_null (&list));
check_list_contents (&list, values, cnt);
ll_reverse (ll_head (&list), ll_null (&list));
check_list_contents (&list, values, cnt);
int *old_values = xnmalloc (max_elems, sizeof *values);
int *new_values = xnmalloc (max_elems, sizeof *values);
int *old_values = xnmalloc (max_elems, sizeof *values);
int *new_values = xnmalloc (max_elems, sizeof *values);
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int left = cnt;
int value = 0;
int left = cnt;
int value = 0;
extract_values (&list, old_values, cnt);
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
extract_values (&list, old_values, cnt);
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
sizeof *new_values,
compare_ints, NULL) > 0);
memcpy (old_values, new_values, cnt * sizeof *old_values);
sizeof *new_values,
compare_ints, NULL) > 0);
memcpy (old_values, new_values, cnt * sizeof *old_values);
- check (permutation_cnt == expected_perms (values, cnt));
+ check (n_permutations == expected_perms (values, cnt));
check_list_contents (&list, values, cnt);
check_list_contents (&list, values, cnt);
ll_reverse (ll_head (&list), ll_null (&list));
extract_values (&list, old_values, cnt);
while (ll_prev_permutation (ll_head (&list), ll_null (&list),
ll_reverse (ll_head (&list), ll_null (&list));
extract_values (&list, old_values, cnt);
while (ll_prev_permutation (ll_head (&list), ll_null (&list),
old_values, cnt,
sizeof *new_values,
compare_ints, NULL) < 0);
old_values, cnt,
sizeof *new_values,
compare_ints, NULL) < 0);
}
ll_reverse (ll_head (&list), ll_null (&list));
}
ll_reverse (ll_head (&list), ll_null (&list));
- check (permutation_cnt == expected_perms (values, cnt));
+ check (n_permutations == expected_perms (values, cnt));
check_list_contents (&list, values, cnt);
free_elements (cnt, elems, NULL, values);
check_list_contents (&list, values, cnt);
free_elements (cnt, elems, NULL, values);
const int max_elems = 8;
const int max_filler = 3;
const int max_elems = 8;
const int max_filler = 3;
- int merge_cnt, pattern, pfx, gap, sfx, order;
+ int n_merges, pattern, pfx, gap, sfx, order;
- for (merge_cnt = 0; merge_cnt < max_elems; merge_cnt++)
- for (pattern = 0; pattern <= (1 << merge_cnt); pattern++)
+ for (n_merges = 0; n_merges < max_elems; n_merges++)
+ for (pattern = 0; pattern <= (1 << n_merges); pattern++)
for (pfx = 0; pfx < max_filler; pfx++)
for (gap = 0; gap < max_filler; gap++)
for (sfx = 0; sfx < max_filler; sfx++)
for (pfx = 0; pfx < max_filler; pfx++)
for (gap = 0; gap < max_filler; gap++)
for (sfx = 0; sfx < max_filler; sfx++)
struct ll **elemp;
int *values;
struct ll **elemp;
int *values;
- int list_cnt = pfx + merge_cnt + gap + sfx;
+ int n_lists = pfx + n_merges + gap + sfx;
int a0, a1, b0, b1;
int i, j;
int a0, a1, b0, b1;
int i, j;
- allocate_elements (list_cnt, &list,
+ allocate_elements (n_lists, &list,
&elems, &elemp, &values);
j = 0;
for (i = 0; i < pfx; i++)
elems[j++]->x = 100 + i;
a0 = j;
&elems, &elemp, &values);
j = 0;
for (i = 0; i < pfx; i++)
elems[j++]->x = 100 + i;
a0 = j;
- for (i = 0; i < merge_cnt; i++)
+ for (i = 0; i < n_merges; i++)
if (pattern & (1u << i))
elems[j++]->x = i;
a1 = j;
for (i = 0; i < gap; i++)
elems[j++]->x = 200 + i;
b0 = j;
if (pattern & (1u << i))
elems[j++]->x = i;
a1 = j;
for (i = 0; i < gap; i++)
elems[j++]->x = 200 + i;
b0 = j;
- for (i = 0; i < merge_cnt; i++)
+ for (i = 0; i < n_merges; i++)
if (!(pattern & (1u << i)))
elems[j++]->x = i;
b1 = j;
for (i = 0; i < sfx; i++)
elems[j++]->x = 300 + i;
if (!(pattern & (1u << i)))
elems[j++]->x = i;
b1 = j;
for (i = 0; i < sfx; i++)
elems[j++]->x = 300 + i;
j = 0;
for (i = 0; i < pfx; i++)
values[j++] = 100 + i;
if (order == 0)
j = 0;
for (i = 0; i < pfx; i++)
values[j++] = 100 + i;
if (order == 0)
- for (i = 0; i < merge_cnt; i++)
+ for (i = 0; i < n_merges; i++)
values[j++] = i;
for (i = 0; i < gap; i++)
values[j++] = 200 + i;
if (order == 1)
values[j++] = i;
for (i = 0; i < gap; i++)
values[j++] = 200 + i;
if (order == 1)
- for (i = 0; i < merge_cnt; i++)
+ for (i = 0; i < n_merges; i++)
values[j++] = i;
for (i = 0; i < sfx; i++)
values[j++] = 300 + i;
values[j++] = i;
for (i = 0; i < sfx; i++)
values[j++] = 300 + i;
if (order == 0)
ll_merge (elemp[a0], elemp[a1], elemp[b0], elemp[b1],
if (order == 0)
ll_merge (elemp[a0], elemp[a1], elemp[b0], elemp[b1],
ll_merge (elemp[b0], elemp[b1], elemp[a0], elemp[a1],
compare_elements, &aux_data);
ll_merge (elemp[b0], elemp[b1], elemp[a0], elemp[a1],
compare_elements, &aux_data);
- check_list_contents (&list, values, list_cnt);
+ check_list_contents (&list, values, n_lists);
- free_elements (list_cnt, elems, elemp, values);
+ free_elements (n_lists, elems, elemp, values);
struct element **perm_elems;
int *perm_values;
struct element **perm_elems;
int *perm_values;
allocate_ascending (cnt, &list, &elems, NULL, &values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
allocate_ascending (cnt, &list, &elems, NULL, &values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
{
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
{
check_list_contents (&perm_list, values, cnt);
check (ll_is_sorted (ll_head (&perm_list), ll_null (&perm_list),
compare_elements, &aux_data));
check_list_contents (&perm_list, values, cnt);
check (ll_is_sorted (ll_head (&perm_list), ll_null (&perm_list),
compare_elements, &aux_data));
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
free_elements (cnt, elems, NULL, values);
free_elements (cnt, perm_elems, NULL, perm_values);
free_elements (cnt, elems, NULL, values);
free_elements (cnt, perm_elems, NULL, perm_values);
struct element **perm_elems;
int *perm_values;
struct element **perm_elems;
int *perm_values;
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements_y, &aux_data))
{
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements_y, &aux_data))
{
check_list_contents (&perm_list, values, cnt);
check (ll_is_sorted (ll_head (&perm_list), ll_null (&perm_list),
compare_elements_x_y, &aux_data));
check_list_contents (&perm_list, values, cnt);
check (ll_is_sorted (ll_head (&perm_list), ll_null (&perm_list),
compare_elements_x_y, &aux_data));
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
free_elements (cnt, elems, NULL, values);
free_elements (cnt, perm_elems, NULL, perm_values);
free_elements (cnt, elems, NULL, values);
free_elements (cnt, perm_elems, NULL, perm_values);
struct element **perm_elems;
int *perm_values;
struct element **perm_elems;
int *perm_values;
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
for (i = 0; i < cnt; i++)
{
elems[i]->x = values[i] = j;
for (i = 0; i < cnt; i++)
{
elems[i]->x = values[i] = j;
if (inc_pat & (1 << i))
j++;
}
if (inc_pat & (1 << i))
j++;
}
- unique_values = xnmalloc (unique_cnt, sizeof *unique_values);
- for (i = 0; i < unique_cnt; i++)
+ unique_values = xnmalloc (n_uniques, sizeof *unique_values);
+ for (i = 0; i < n_uniques; i++)
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
{
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements, &aux_data))
{
}
ll_sort_unique (ll_head (&perm_list), ll_null (&perm_list), NULL,
compare_elements, &aux_data);
}
ll_sort_unique (ll_head (&perm_list), ll_null (&perm_list), NULL,
compare_elements, &aux_data);
- check_list_contents (&perm_list, unique_values, unique_cnt);
+ check_list_contents (&perm_list, unique_values, n_uniques);
check (ll_is_sorted (ll_head (&perm_list), ll_null (&perm_list),
compare_elements_x_y, &aux_data));
check (ll_is_sorted (ll_head (&perm_list), ll_null (&perm_list),
compare_elements_x_y, &aux_data));
- check (perm_cnt == expected_perms (values, cnt));
+ check (n_perms == expected_perms (values, cnt));
free_elements (cnt, elems, NULL, values);
free_elements (cnt, perm_elems, NULL, perm_values);
free_elements (cnt, elems, NULL, values);
free_elements (cnt, perm_elems, NULL, perm_values);
struct element **perm_elems;
int *perm_values;
struct element **perm_elems;
int *perm_values;
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements_y, &aux_data))
{
while (ll_next_permutation (ll_head (&list), ll_null (&list),
compare_elements_y, &aux_data))
{
}
check (ll_is_sorted (ll_head (&perm_list), ll_null (&perm_list),
compare_elements_x_y, &aux_data));
}
check (ll_is_sorted (ll_head (&perm_list), ll_null (&perm_list),
compare_elements_x_y, &aux_data));
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
free_elements (cnt, elems, NULL, values);
free_elements (cnt, perm_elems, NULL, perm_values);
free_elements (cnt, elems, NULL, values);
free_elements (cnt, perm_elems, NULL, perm_values);
expected_perms (int *values, size_t cnt)
{
size_t i, j;
expected_perms (int *values, size_t cnt)
{
size_t i, j;
- perm_cnt = factorial (cnt);
+ n_perms = factorial (cnt);
for (i = 0; i < cnt; i = j)
{
for (j = i + 1; j < cnt; j++)
if (values[i] != values[j])
break;
for (i = 0; i < cnt; i = j)
{
for (j = i + 1; j < cnt; j++)
if (values[i] != values[j])
break;
- perm_cnt /= factorial (j - i);
+ n_perms /= factorial (j - i);
}
/* Tests llx_min and llx_max. */
}
/* Tests llx_min and llx_max. */
int *values;
int *new_values = xnmalloc (cnt, sizeof *values);
int *values;
int *new_values = xnmalloc (cnt, sizeof *values);
allocate_ascending (cnt, &list, &elems, &elemp, &values);
allocate_ascending (cnt, &list, &elems, &elemp, &values);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
{
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
{
check (max != elemp[r1] && max_elem->x == max_int);
}
}
check (max != elemp[r1] && max_elem->x == max_int);
}
}
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
check_list_contents (&list, values, cnt);
free_elements (cnt, &list, elems, elemp, values);
check_list_contents (&list, values, cnt);
free_elements (cnt, &list, elems, elemp, values);
int *old_values = xnmalloc (cnt, sizeof *values);
int *new_values = xnmalloc (cnt, sizeof *values);
int *old_values = xnmalloc (cnt, sizeof *values);
int *new_values = xnmalloc (cnt, sizeof *values);
allocate_ascending (cnt, &list, &elems, NULL, &values);
allocate_ascending (cnt, &list, &elems, NULL, &values);
extract_values (&list, old_values, cnt);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
extract_values (&list, old_values, cnt);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
sizeof *new_values,
compare_ints, NULL) > 0);
memcpy (old_values, new_values, (cnt) * sizeof *old_values);
sizeof *new_values,
compare_ints, NULL) > 0);
memcpy (old_values, new_values, (cnt) * sizeof *old_values);
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
check_list_contents (&list, values, cnt);
check_list_contents (&list, values, cnt);
llx_reverse (llx_head (&list), llx_null (&list));
extract_values (&list, old_values, cnt);
while (llx_prev_permutation (llx_head (&list), llx_null (&list),
llx_reverse (llx_head (&list), llx_null (&list));
extract_values (&list, old_values, cnt);
while (llx_prev_permutation (llx_head (&list), llx_null (&list),
sizeof *new_values,
compare_ints, NULL) < 0);
memcpy (old_values, new_values, (cnt) * sizeof *old_values);
sizeof *new_values,
compare_ints, NULL) < 0);
memcpy (old_values, new_values, (cnt) * sizeof *old_values);
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
llx_reverse (llx_head (&list), llx_null (&list));
check_list_contents (&list, values, cnt);
llx_reverse (llx_head (&list), llx_null (&list));
check_list_contents (&list, values, cnt);
int *old_values = xnmalloc (max_elems, sizeof *values);
int *new_values = xnmalloc (max_elems, sizeof *values);
int *old_values = xnmalloc (max_elems, sizeof *values);
int *new_values = xnmalloc (max_elems, sizeof *values);
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int left = cnt;
int value = 0;
int left = cnt;
int value = 0;
extract_values (&list, old_values, cnt);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
extract_values (&list, old_values, cnt);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
sizeof *new_values,
compare_ints, NULL) > 0);
memcpy (old_values, new_values, cnt * sizeof *old_values);
sizeof *new_values,
compare_ints, NULL) > 0);
memcpy (old_values, new_values, cnt * sizeof *old_values);
- check (permutation_cnt == expected_perms (values, cnt));
+ check (n_permutations == expected_perms (values, cnt));
check_list_contents (&list, values, cnt);
check_list_contents (&list, values, cnt);
llx_reverse (llx_head (&list), llx_null (&list));
extract_values (&list, old_values, cnt);
while (llx_prev_permutation (llx_head (&list), llx_null (&list),
llx_reverse (llx_head (&list), llx_null (&list));
extract_values (&list, old_values, cnt);
while (llx_prev_permutation (llx_head (&list), llx_null (&list),
old_values, cnt,
sizeof *new_values,
compare_ints, NULL) < 0);
old_values, cnt,
sizeof *new_values,
compare_ints, NULL) < 0);
}
llx_reverse (llx_head (&list), llx_null (&list));
}
llx_reverse (llx_head (&list), llx_null (&list));
- check (permutation_cnt == expected_perms (values, cnt));
+ check (n_permutations == expected_perms (values, cnt));
check_list_contents (&list, values, cnt);
free_elements (cnt, &list, elems, elemp, values);
check_list_contents (&list, values, cnt);
free_elements (cnt, &list, elems, elemp, values);
const int max_elems = 8;
const int max_fillxer = 3;
const int max_elems = 8;
const int max_fillxer = 3;
- int merge_cnt, pattern, pfx, gap, sfx, order;
+ int n_merges, pattern, pfx, gap, sfx, order;
- for (merge_cnt = 0; merge_cnt < max_elems; merge_cnt++)
- for (pattern = 0; pattern <= (1 << merge_cnt); pattern++)
+ for (n_merges = 0; n_merges < max_elems; n_merges++)
+ for (pattern = 0; pattern <= (1 << n_merges); pattern++)
for (pfx = 0; pfx < max_fillxer; pfx++)
for (gap = 0; gap < max_fillxer; gap++)
for (sfx = 0; sfx < max_fillxer; sfx++)
for (pfx = 0; pfx < max_fillxer; pfx++)
for (gap = 0; gap < max_fillxer; gap++)
for (sfx = 0; sfx < max_fillxer; sfx++)
struct llx **elemp;
int *values;
struct llx **elemp;
int *values;
- int list_cnt = pfx + merge_cnt + gap + sfx;
+ int n_lists = pfx + n_merges + gap + sfx;
int a0, a1, b0, b1;
int i, j;
int a0, a1, b0, b1;
int i, j;
- allocate_elements (list_cnt, &list,
+ allocate_elements (n_lists, &list,
&elems, &elemp, &values);
j = 0;
for (i = 0; i < pfx; i++)
elems[j++]->x = 100 + i;
a0 = j;
&elems, &elemp, &values);
j = 0;
for (i = 0; i < pfx; i++)
elems[j++]->x = 100 + i;
a0 = j;
- for (i = 0; i < merge_cnt; i++)
+ for (i = 0; i < n_merges; i++)
if (pattern & (1u << i))
elems[j++]->x = i;
a1 = j;
for (i = 0; i < gap; i++)
elems[j++]->x = 200 + i;
b0 = j;
if (pattern & (1u << i))
elems[j++]->x = i;
a1 = j;
for (i = 0; i < gap; i++)
elems[j++]->x = 200 + i;
b0 = j;
- for (i = 0; i < merge_cnt; i++)
+ for (i = 0; i < n_merges; i++)
if (!(pattern & (1u << i)))
elems[j++]->x = i;
b1 = j;
for (i = 0; i < sfx; i++)
elems[j++]->x = 300 + i;
if (!(pattern & (1u << i)))
elems[j++]->x = i;
b1 = j;
for (i = 0; i < sfx; i++)
elems[j++]->x = 300 + i;
j = 0;
for (i = 0; i < pfx; i++)
values[j++] = 100 + i;
if (order == 0)
j = 0;
for (i = 0; i < pfx; i++)
values[j++] = 100 + i;
if (order == 0)
- for (i = 0; i < merge_cnt; i++)
+ for (i = 0; i < n_merges; i++)
values[j++] = i;
for (i = 0; i < gap; i++)
values[j++] = 200 + i;
if (order == 1)
values[j++] = i;
for (i = 0; i < gap; i++)
values[j++] = 200 + i;
if (order == 1)
- for (i = 0; i < merge_cnt; i++)
+ for (i = 0; i < n_merges; i++)
values[j++] = i;
for (i = 0; i < sfx; i++)
values[j++] = 300 + i;
values[j++] = i;
for (i = 0; i < sfx; i++)
values[j++] = 300 + i;
if (order == 0)
llx_merge (elemp[a0], elemp[a1], elemp[b0], elemp[b1],
if (order == 0)
llx_merge (elemp[a0], elemp[a1], elemp[b0], elemp[b1],
llx_merge (elemp[b0], elemp[b1], elemp[a0], elemp[a1],
compare_elements, &aux_data);
llx_merge (elemp[b0], elemp[b1], elemp[a0], elemp[a1],
compare_elements, &aux_data);
- check_list_contents (&list, values, list_cnt);
+ check_list_contents (&list, values, n_lists);
- free_elements (list_cnt, &list, elems, elemp, values);
+ free_elements (n_lists, &list, elems, elemp, values);
struct element **perm_elems;
int *perm_values;
struct element **perm_elems;
int *perm_values;
allocate_ascending (cnt, &list, &elems, NULL, &values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
allocate_ascending (cnt, &list, &elems, NULL, &values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
{
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
{
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
struct element **perm_elems;
int *perm_values;
struct element **perm_elems;
int *perm_values;
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements_y, &aux_data))
{
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements_y, &aux_data))
{
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
struct element **perm_elems;
int *perm_values;
struct element **perm_elems;
int *perm_values;
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
for (i = 0; i < cnt; i++)
{
elems[i]->x = values[i] = j;
for (i = 0; i < cnt; i++)
{
elems[i]->x = values[i] = j;
if (inc_pat & (1 << i))
j++;
}
if (inc_pat & (1 << i))
j++;
}
- unique_values = xnmalloc (unique_cnt, sizeof *unique_values);
- for (i = 0; i < unique_cnt; i++)
+ unique_values = xnmalloc (n_uniques, sizeof *unique_values);
+ for (i = 0; i < n_uniques; i++)
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
{
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements, &aux_data))
{
llx_sort_unique (llx_head (&perm_list), llx_null (&perm_list), NULL,
compare_elements, &aux_data,
&llx_malloc_mgr);
llx_sort_unique (llx_head (&perm_list), llx_null (&perm_list), NULL,
compare_elements, &aux_data,
&llx_malloc_mgr);
- check_list_contents (&perm_list, unique_values, unique_cnt);
+ check_list_contents (&perm_list, unique_values, n_uniques);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
- check (perm_cnt == expected_perms (values, cnt));
+ check (n_perms == expected_perms (values, cnt));
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
struct element **perm_elems;
int *perm_values;
struct element **perm_elems;
int *perm_values;
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
int i, j;
allocate_elements (cnt, &list, &elems, NULL, &values);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements_y, &aux_data))
{
while (llx_next_permutation (llx_head (&list), llx_null (&list),
compare_elements_y, &aux_data))
{
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
- check (perm_cnt == factorial (cnt));
+ check (n_perms == factorial (cnt));
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
ELEMENTS[]. */
static void
check_range_map (struct range_map *rm,
ELEMENTS[]. */
static void
check_range_map (struct range_map *rm,
- struct expected_element elements[], size_t elem_cnt)
+ struct expected_element elements[], size_t n_elems)
{
struct expected_element *sorted;
struct range_map_node *node;
size_t i;
{
struct expected_element *sorted;
struct range_map_node *node;
size_t i;
- sorted = xnmalloc (elem_cnt, sizeof *sorted);
- memcpy (sorted, elements, elem_cnt * sizeof *elements);
- qsort (sorted, elem_cnt, sizeof *sorted, compare_expected_element);
+ sorted = xnmalloc (n_elems, sizeof *sorted);
+ memcpy (sorted, elements, n_elems * sizeof *elements);
+ qsort (sorted, n_elems, sizeof *sorted, compare_expected_element);
- check (range_map_is_empty (rm) == (elem_cnt == 0));
+ check (range_map_is_empty (rm) == (n_elems == 0));
- for (i = 0; i < elem_cnt; i++)
+ for (i = 0; i < n_elems; i++)
{
struct expected_element *e = &sorted[i];
unsigned long int position;
{
struct expected_element *e = &sorted[i];
unsigned long int position;
range_map_lookup doesn't find any there. */
if (e->start > 0 && (i == 0 || e[-1].end < e->start))
check (range_map_lookup (rm, e->start - 1) == NULL);
range_map_lookup doesn't find any there. */
if (e->start > 0 && (i == 0 || e[-1].end < e->start))
check (range_map_lookup (rm, e->start - 1) == NULL);
- if (i == elem_cnt - 1 || e->end < e[1].start)
+ if (i == n_elems - 1 || e->end < e[1].start)
check (range_map_lookup (rm, e->end) == NULL);
}
check (range_map_lookup (rm, e->end) == NULL);
}
struct expected_element *e = &sorted[i];
check (range_map_node_to_element (node)->x == e->x);
}
struct expected_element *e = &sorted[i];
check (range_map_node_to_element (node)->x == e->x);
}
for (cnt = 1; cnt <= max_range; cnt++)
{
for (cnt = 1; cnt <= max_range; cnt++)
{
- unsigned int composition_cnt;
+ unsigned int n_compositions;
struct expected_element *expected;
int *widths;
struct expected_element *expected;
int *widths;
int *order;
struct element *elements;
int *order;
struct element *elements;
order = xnmalloc (cnt, sizeof *order);
elements = xnmalloc (cnt, sizeof *elements);
order = xnmalloc (cnt, sizeof *order);
elements = xnmalloc (cnt, sizeof *elements);
- elem_cnt = 0;
- composition_cnt = 0;
- while (next_composition (cnt, &elem_cnt, widths))
+ n_elems = 0;
+ n_compositions = 0;
+ while (next_composition (cnt, &n_elems, widths))
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
- for (i = 0; i < elem_cnt; i++)
+ for (i = 0; i < n_elems; i++)
- permutation_cnt = 0;
- while (permutation_cnt == 0 || next_permutation (order, elem_cnt))
+ n_permutations = 0;
+ while (n_permutations == 0 || next_permutation (order, n_elems))
- /* Inserts the elem_cnt elements with the given
+ /* Inserts the n_elems elements with the given
widths[] into T in the order given by order[]. */
range_map_init (&rm);
widths[] into T in the order given by order[]. */
range_map_init (&rm);
- for (i = 0; i < elem_cnt; i++)
+ for (i = 0; i < n_elems; i++)
{
unsigned long int start, end;
int idx;
{
unsigned long int start, end;
int idx;
expected[i].end = end;
check_range_map (&rm, expected, i + 1);
}
expected[i].end = end;
check_range_map (&rm, expected, i + 1);
}
- check (permutation_cnt == factorial (elem_cnt));
+ check (n_permutations == factorial (n_elems));
- check (composition_cnt == 1 << (cnt - 1));
+ check (n_compositions == 1 << (cnt - 1));
free (expected);
free (widths);
free (expected);
free (widths);
for (cnt = 1; cnt <= max_range; cnt++)
{
for (cnt = 1; cnt <= max_range; cnt++)
{
- unsigned int composition_cnt;
+ unsigned int n_compositions;
struct expected_element *expected;
int *widths;
struct expected_element *expected;
int *widths;
int *order;
struct element *elements;
int *order;
struct element *elements;
order = xnmalloc (cnt, sizeof *order);
elements = xnmalloc (cnt, sizeof *elements);
order = xnmalloc (cnt, sizeof *order);
elements = xnmalloc (cnt, sizeof *elements);
- elem_cnt = 0;
- composition_cnt = 0;
- while (next_composition (cnt, &elem_cnt, widths))
+ n_elems = 0;
+ n_compositions = 0;
+ while (next_composition (cnt, &n_elems, widths))
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
- for (i = 0; i < elem_cnt; i++)
+ for (i = 0; i < n_elems; i++)
- permutation_cnt = 0;
- while (permutation_cnt == 0 || next_permutation (order, elem_cnt))
+ n_permutations = 0;
+ while (n_permutations == 0 || next_permutation (order, n_elems))
{
struct range_map rm;
unsigned long int start;
{
struct range_map rm;
unsigned long int start;
/* Insert all the elements. */
range_map_init (&rm);
start = 0;
/* Insert all the elements. */
range_map_init (&rm);
start = 0;
- for (i = 0; i < elem_cnt; i++)
+ for (i = 0; i < n_elems; i++)
{
int width = widths[i] > gap ? widths[i] - gap : widths[i];
unsigned long int end = start + width;
{
int width = widths[i] > gap ? widths[i] - gap : widths[i];
unsigned long int end = start + width;
if (order[j] == i)
{
expected[j].x = i;
if (order[j] == i)
{
expected[j].x = i;
- check_range_map (&rm, expected, elem_cnt);
+ check_range_map (&rm, expected, n_elems);
/* Delete the elements in the specified order. */
/* Delete the elements in the specified order. */
- for (i = 0; i < elem_cnt; i++)
+ for (i = 0; i < n_elems; i++)
{
range_map_delete (&rm, &elements[order[i]].node);
{
range_map_delete (&rm, &elements[order[i]].node);
- check_range_map (&rm, expected + i + 1, elem_cnt - i - 1);
+ check_range_map (&rm, expected + i + 1, n_elems - i - 1);
- check (permutation_cnt == factorial (elem_cnt));
+ check (n_permutations == factorial (n_elems));
- check (composition_cnt == 1 << (cnt - 1));
+ check (n_compositions == 1 << (cnt - 1));
free (expected);
free (widths);
free (expected);
free (widths);
1, 2, 4, 16, 64, 4096, 262144, 16777216,
3, 5, 17, 67, 4099, 262147, 16777259,
};
1, 2, 4, 16, 64, 4096, 262144, 16777216,
3, 5, 17, 67, 4099, 262147, 16777259,
};
- const size_t stride_cnt = sizeof strides / sizeof *strides;
+ const size_t n_strides = sizeof strides / sizeof *strides;
static const unsigned long offsets[] =
{
static const unsigned long offsets[] =
{
1024ul * 1024 * 512 + 23,
ULONG_MAX - 59,
};
1024ul * 1024 * 512 + 23,
ULONG_MAX - 59,
};
- const size_t offset_cnt = sizeof offsets / sizeof *offsets;
+ const size_t n_offsets = sizeof offsets / sizeof *offsets;
int cnt = 100;
unsigned long *insertions, *deletions;
int cnt = 100;
unsigned long *insertions, *deletions;
insertions = xnmalloc (cnt, sizeof *insertions);
deletions = xnmalloc (cnt, sizeof *deletions);
insertions = xnmalloc (cnt, sizeof *insertions);
deletions = xnmalloc (cnt, sizeof *deletions);
- for (stride = strides; stride < strides + stride_cnt; stride++)
+ for (stride = strides; stride < strides + n_strides; stride++)
{
printf ("%lu\n", *stride);
{
printf ("%lu\n", *stride);
- for (offset = offsets; offset < offsets + offset_cnt; offset++)
+ for (offset = offsets; offset < offsets + n_offsets; offset++)
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int ins_perm_cnt;
+ unsigned int ins_n_perms;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i | random_value (i, basis);
for (i = 0; i < cnt; i++)
insertions[i] = i | random_value (i, basis);
- for (ins_perm_cnt = 0;
- ins_perm_cnt == 0 || next_permutation (insertions, cnt);
- ins_perm_cnt++)
+ for (ins_n_perms = 0;
+ ins_n_perms == 0 || next_permutation (insertions, cnt);
+ ins_n_perms++)
- unsigned int del_perm_cnt;
+ unsigned int del_n_perms;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i | random_value (i, basis);
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i | random_value (i, basis);
- for (del_perm_cnt = 0;
- del_perm_cnt == 0 || next_permutation (deletions, cnt);
- del_perm_cnt++)
+ for (del_n_perms = 0;
+ del_n_perms == 0 || next_permutation (deletions, cnt);
+ del_n_perms++)
test_insert_delete (insertions, deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
- check (del_perm_cnt == factorial (cnt));
+ check (del_n_perms == factorial (cnt));
- check (ins_perm_cnt == factorial (cnt));
+ check (ins_n_perms == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i | random_value (i, 1);
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i | random_value (i, 1);
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
test_insert_delete (values, values, cnt);
test_insert_delete (values, values, cnt);
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i | random_value (i, 2);
for (i = 0; i < cnt; i++)
insertions[i] = i | random_value (i, 2);
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (insertions, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (insertions, cnt);
+ n_permutations++)
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int ins_perm_cnt;
+ unsigned int ins_n_perms;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (ins_perm_cnt = 0;
- ins_perm_cnt == 0 || next_permutation (insertions, cnt);
- ins_perm_cnt++)
+ for (ins_n_perms = 0;
+ ins_n_perms == 0 || next_permutation (insertions, cnt);
+ ins_n_perms++)
- unsigned int del_perm_cnt;
+ unsigned int del_n_perms;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
- for (del_perm_cnt = 0;
- del_perm_cnt == 0 || next_permutation (deletions, cnt);
- del_perm_cnt++)
+ for (del_n_perms = 0;
+ del_n_perms == 0 || next_permutation (deletions, cnt);
+ del_n_perms++)
test_insert_delete (insertions, deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
- check (del_perm_cnt == factorial (cnt));
+ check (del_n_perms == factorial (cnt));
- check (ins_perm_cnt == factorial (cnt));
+ check (ins_n_perms == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
test_insert_delete (values, values, cnt);
test_insert_delete (values, values, cnt);
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (insertions, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (insertions, cnt);
+ n_permutations++)
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int ins_perm_cnt;
+ unsigned int ins_n_perms;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i | random_value (i, basis);
for (i = 0; i < cnt; i++)
insertions[i] = i | random_value (i, basis);
- for (ins_perm_cnt = 0;
- ins_perm_cnt == 0 || next_permutation (insertions, cnt);
- ins_perm_cnt++)
+ for (ins_n_perms = 0;
+ ins_n_perms == 0 || next_permutation (insertions, cnt);
+ ins_n_perms++)
- unsigned int del_perm_cnt;
+ unsigned int del_n_perms;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i | random_value (i, basis);
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i | random_value (i, basis);
- for (del_perm_cnt = 0;
- del_perm_cnt == 0 || next_permutation (deletions, cnt);
- del_perm_cnt++)
+ for (del_n_perms = 0;
+ del_n_perms == 0 || next_permutation (deletions, cnt);
+ del_n_perms++)
test_insert_delete (insertions, deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
- check (del_perm_cnt == factorial (cnt));
+ check (del_n_perms == factorial (cnt));
- check (ins_perm_cnt == factorial (cnt));
+ check (ins_n_perms == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i | random_value (i, 1);
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i | random_value (i, 1);
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
test_insert_delete (values, values, cnt);
test_insert_delete (values, values, cnt);
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i | random_value (i, 2);
for (i = 0; i < cnt; i++)
insertions[i] = i | random_value (i, 2);
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (insertions, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (insertions, cnt);
+ n_permutations++)
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int ins_perm_cnt;
+ unsigned int ins_n_perms;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (ins_perm_cnt = 0;
- ins_perm_cnt == 0 || next_permutation (insertions, cnt);
- ins_perm_cnt++)
+ for (ins_n_perms = 0;
+ ins_n_perms == 0 || next_permutation (insertions, cnt);
+ ins_n_perms++)
- unsigned int del_perm_cnt;
+ unsigned int del_n_perms;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
int i;
for (i = 0; i < cnt; i++)
deletions[i] = i;
- for (del_perm_cnt = 0;
- del_perm_cnt == 0 || next_permutation (deletions, cnt);
- del_perm_cnt++)
+ for (del_n_perms = 0;
+ del_n_perms == 0 || next_permutation (deletions, cnt);
+ del_n_perms++)
test_insert_delete (insertions, deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
- check (del_perm_cnt == factorial (cnt));
+ check (del_n_perms == factorial (cnt));
- check (ins_perm_cnt == factorial (cnt));
+ check (ins_n_perms == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *values;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
int i;
values = xnmalloc (cnt, sizeof *values);
for (i = 0; i < cnt; i++)
values[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (values, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (values, cnt);
+ n_permutations++)
test_insert_delete (values, values, cnt);
test_insert_delete (values, values, cnt);
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
for (cnt = 0; cnt <= max_elems; cnt++)
{
int *insertions, *deletions;
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
int i;
insertions = xnmalloc (cnt, sizeof *insertions);
for (i = 0; i < cnt; i++)
insertions[i] = i;
for (i = 0; i < cnt; i++)
insertions[i] = i;
- for (permutation_cnt = 0;
- permutation_cnt == 0 || next_permutation (insertions, cnt);
- permutation_cnt++)
+ for (n_permutations = 0;
+ n_permutations == 0 || next_permutation (insertions, cnt);
+ n_permutations++)
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
{
memcpy (deletions, insertions, sizeof *insertions * cnt);
reverse (deletions, cnt);
test_insert_delete (insertions, deletions, cnt);
}
- check (permutation_cnt == factorial (cnt));
+ check (n_permutations == factorial (cnt));
free (insertions);
free (deletions);
free (insertions);
free (deletions);
BLOCKS[]. */
static void
check_tower (struct tower *t,
BLOCKS[]. */
static void
check_tower (struct tower *t,
- struct expected_block blocks[], size_t block_cnt)
+ struct expected_block blocks[], size_t n_blocks)
{
int total_height;
struct tower_node *node;
size_t i;
{
int total_height;
struct tower_node *node;
size_t i;
- check (tower_count (t) == block_cnt);
- check (tower_is_empty (t) == (block_cnt == 0));
+ check (tower_count (t) == n_blocks);
+ check (tower_is_empty (t) == (n_blocks == 0));
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
{
unsigned long int level;
for (level = total_height;
{
unsigned long int level;
for (level = total_height;
check (tower_node_get_size (node) == blocks[i].size);
check (tower_node_to_block (node)->x == blocks[i].x);
}
check (tower_node_get_size (node) == blocks[i].size);
check (tower_node_to_block (node)->x == blocks[i].x);
}
- check (i == block_cnt);
- for (node = tower_last (t), i = block_cnt - 1;
+ for (node = tower_last (t), i = n_blocks - 1;
node != NULL;
node = tower_prev (t, node), i--)
{
node != NULL;
node = tower_prev (t, node), i--)
{
for (cnt = 1; cnt <= max_height; cnt++)
{
for (cnt = 1; cnt <= max_height; cnt++)
{
- unsigned int composition_cnt;
+ unsigned int n_compositions;
struct expected_block *expected;
int *sizes;
struct expected_block *expected;
int *sizes;
int *order;
struct block *blocks;
int *order;
struct block *blocks;
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
- block_cnt = 0;
- composition_cnt = 0;
- while (next_composition (cnt, &block_cnt, sizes))
+ n_blocks = 0;
+ n_compositions = 0;
+ while (next_composition (cnt, &n_blocks, sizes))
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
- permutation_cnt = 0;
- while (permutation_cnt == 0 || next_permutation (order, block_cnt))
+ n_permutations = 0;
+ while (n_permutations == 0 || next_permutation (order, n_blocks))
- /* Inserts the block_cnt blocks with the given
+ /* Inserts the n_blocks blocks with the given
sizes[] into T in the order given by order[]. */
tower_init (&t);
sizes[] into T in the order given by order[]. */
tower_init (&t);
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
{
struct block *under;
int idx;
{
struct block *under;
int idx;
}
/* Check that the result is what we expect. */
}
/* Check that the result is what we expect. */
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
{
expected[i].size = sizes[i];
expected[i].x = i;
}
{
expected[i].size = sizes[i];
expected[i].x = i;
}
- check_tower (&t, expected, block_cnt);
+ check_tower (&t, expected, n_blocks);
- check (permutation_cnt == factorial (block_cnt));
+ check (n_permutations == factorial (n_blocks));
- check (composition_cnt == 1 << (cnt - 1));
+ check (n_compositions == 1 << (cnt - 1));
free (expected);
free (sizes);
free (expected);
free (sizes);
for (cnt = 1; cnt <= max_height; cnt++)
{
for (cnt = 1; cnt <= max_height; cnt++)
{
- unsigned int composition_cnt;
+ unsigned int n_compositions;
struct expected_block *expected;
int *sizes;
struct expected_block *expected;
int *sizes;
int *order;
struct block *blocks;
int *order;
struct block *blocks;
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
- block_cnt = 0;
- composition_cnt = 0;
- while (next_composition (cnt, &block_cnt, sizes))
+ n_blocks = 0;
+ n_compositions = 0;
+ while (next_composition (cnt, &n_blocks, sizes))
- unsigned int permutation_cnt;
+ unsigned int n_permutations;
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
- permutation_cnt = 0;
- while (permutation_cnt == 0 || next_permutation (order, block_cnt))
+ n_permutations = 0;
+ while (n_permutations == 0 || next_permutation (order, n_blocks))
{
struct tower t;
/* Insert blocks into tower in ascending order. */
tower_init (&t);
{
struct tower t;
/* Insert blocks into tower in ascending order. */
tower_init (&t);
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
{
blocks[i].x = i;
tower_insert (&t, sizes[i], &blocks[i].node, NULL);
expected[i].x = i;
expected[i].size = sizes[i];
}
{
blocks[i].x = i;
tower_insert (&t, sizes[i], &blocks[i].node, NULL);
expected[i].x = i;
expected[i].size = sizes[i];
}
- check_tower (&t, expected, block_cnt);
+ check_tower (&t, expected, n_blocks);
/* Delete blocks from tower in the order of
order[]. */
/* Delete blocks from tower in the order of
order[]. */
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
{
int idx = order[i];
int j;
tower_delete (&t, &blocks[idx].node);
for (j = 0; ; j++)
{
{
int idx = order[i];
int j;
tower_delete (&t, &blocks[idx].node);
for (j = 0; ; j++)
{
- assert (j < block_cnt - i);
+ assert (j < n_blocks - i);
if (expected[j].x == idx)
{
memmove (&expected[j], &expected[j + 1],
if (expected[j].x == idx)
{
memmove (&expected[j], &expected[j + 1],
- sizeof *expected * (block_cnt - i - j - 1));
+ sizeof *expected * (n_blocks - i - j - 1));
- check_tower (&t, expected, block_cnt - i - 1);
+ check_tower (&t, expected, n_blocks - i - 1);
- check (permutation_cnt == factorial (block_cnt));
+ check (n_permutations == factorial (n_blocks));
- check (composition_cnt == 1 << (cnt - 1));
+ check (n_compositions == 1 << (cnt - 1));
free (expected);
free (sizes);
free (expected);
free (sizes);
for (cnt = 1; cnt <= max_height; cnt++)
{
for (cnt = 1; cnt <= max_height; cnt++)
{
- unsigned int composition_cnt;
+ unsigned int n_compositions;
struct expected_block *expected;
int *sizes, *new_sizes;
struct expected_block *expected;
int *sizes, *new_sizes;
int *order;
struct block *blocks;
int *order;
struct block *blocks;
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
- block_cnt = 0;
- composition_cnt = 0;
- while (next_composition (cnt, &block_cnt, sizes))
+ n_blocks = 0;
+ n_compositions = 0;
+ while (next_composition (cnt, &n_blocks, sizes))
{
int i;
unsigned int resizes = 0;
{
int i;
unsigned int resizes = 0;
- for (resizes = 0, first_k_composition (cnt, block_cnt, new_sizes);
+ for (resizes = 0, first_k_composition (cnt, n_blocks, new_sizes);
- || next_k_composition (cnt, block_cnt, new_sizes));
+ || next_k_composition (cnt, n_blocks, new_sizes));
resizes++)
{
struct tower t;
/* Insert blocks into tower in ascending order. */
tower_init (&t);
resizes++)
{
struct tower t;
/* Insert blocks into tower in ascending order. */
tower_init (&t);
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
{
blocks[i].x = i;
tower_insert (&t, sizes[i], &blocks[i].node, NULL);
expected[i].x = i;
expected[i].size = sizes[i];
}
{
blocks[i].x = i;
tower_insert (&t, sizes[i], &blocks[i].node, NULL);
expected[i].x = i;
expected[i].size = sizes[i];
}
- check_tower (&t, expected, block_cnt);
+ check_tower (&t, expected, n_blocks);
/* Resize all the blocks. */
/* Resize all the blocks. */
- for (i = 0; i < block_cnt; i++)
+ for (i = 0; i < n_blocks; i++)
{
if (expected[i].size != new_sizes[i] || rand () % 2)
tower_resize (&t, &blocks[i].node, new_sizes[i]);
expected[i].size = new_sizes[i];
}
{
if (expected[i].size != new_sizes[i] || rand () % 2)
tower_resize (&t, &blocks[i].node, new_sizes[i]);
expected[i].size = new_sizes[i];
}
- check_tower (&t, expected, block_cnt);
+ check_tower (&t, expected, n_blocks);
- check (resizes == binomial_cofficient (cnt - 1, block_cnt - 1));
+ check (resizes == binomial_cofficient (cnt - 1, n_blocks - 1));
- check (composition_cnt == 1 << (cnt - 1));
+ check (n_compositions == 1 << (cnt - 1));
free (expected);
free (new_sizes);
free (expected);
free (new_sizes);
for (cnt = 1; cnt <= max_height; cnt++)
{
for (cnt = 1; cnt <= max_height; cnt++)
{
- unsigned int composition_cnt;
+ unsigned int n_compositions;
struct expected_block *expected;
int *sizes, *new_sizes;
struct expected_block *expected;
int *sizes, *new_sizes;
int *order;
struct block *blocks;
int *order;
struct block *blocks;
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
- block_cnt = 0;
- composition_cnt = 0;
- while (next_composition (cnt, &block_cnt, sizes))
+ n_blocks = 0;
+ n_compositions = 0;
+ while (next_composition (cnt, &n_blocks, sizes))
- for (i = 0; i < block_cnt; i++)
- for (j = i; j <= block_cnt; j++)
+ for (i = 0; i < n_blocks; i++)
+ for (j = i; j <= n_blocks; j++)
{
struct tower src, dst;
int k;
{
struct tower src, dst;
int k;
tower_init (&dst);
/* Insert blocks into SRC and DST in ascending order. */
tower_init (&dst);
/* Insert blocks into SRC and DST in ascending order. */
- for (k = 0; k < block_cnt; k++)
+ for (k = 0; k < n_blocks; k++)
{
blocks[k].x = k;
tower_insert (&src, sizes[k], &blocks[k].node, NULL);
expected[k].x = k;
expected[k].size = sizes[k];
}
{
blocks[k].x = k;
tower_insert (&src, sizes[k], &blocks[k].node, NULL);
expected[k].x = k;
expected[k].size = sizes[k];
}
- check_tower (&src, expected, block_cnt);
+ check_tower (&src, expected, n_blocks);
/* Splice blocks I...J into DST. */
tower_splice (&dst, NULL, &src, &blocks[i].node,
/* Splice blocks I...J into DST. */
tower_splice (&dst, NULL, &src, &blocks[i].node,
- j < block_cnt ? &blocks[j].node : NULL);
+ j < n_blocks ? &blocks[j].node : NULL);
check_tower (&dst, &expected[i], j - i);
memmove (&expected[i], &expected[j],
check_tower (&dst, &expected[i], j - i);
memmove (&expected[i], &expected[j],
- sizeof *expected * (block_cnt - j));
- check_tower (&src, expected, block_cnt - (j - i));
+ sizeof *expected * (n_blocks - j));
+ check_tower (&src, expected, n_blocks - (j - i));
- check (composition_cnt == 1 << (cnt - 1));
+ check (n_compositions == 1 << (cnt - 1));
free (expected);
free (new_sizes);
free (expected);
free (new_sizes);
for (cnt = 1; cnt <= max_height; cnt++)
{
for (cnt = 1; cnt <= max_height; cnt++)
{
- unsigned int composition_cnt;
+ unsigned int n_compositions;
struct expected_block *expected;
int *sizes, *new_sizes;
struct expected_block *expected;
int *sizes, *new_sizes;
int *order;
struct block *blocks;
int *order;
struct block *blocks;
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
order = xnmalloc (cnt, sizeof *order);
blocks = xnmalloc (cnt, sizeof *blocks);
- block_cnt = 0;
- composition_cnt = 0;
- while (next_composition (cnt, &block_cnt, sizes))
+ n_blocks = 0;
+ n_compositions = 0;
+ while (next_composition (cnt, &n_blocks, sizes))
- for (i = 0; i < block_cnt; i++)
- for (j = i; j <= block_cnt; j++)
+ for (i = 0; i < n_blocks; i++)
+ for (j = i; j <= n_blocks; j++)
{
struct tower src, dst;
int k;
{
struct tower src, dst;
int k;
tower_init (&dst);
/* Insert blocks into SRC and DST in ascending order. */
tower_init (&dst);
/* Insert blocks into SRC and DST in ascending order. */
- for (k = 0; k < block_cnt; k++)
+ for (k = 0; k < n_blocks; k++)
{
blocks[k].x = k;
tower_insert (k >= i && k < j ? &src : &dst,
{
blocks[k].x = k;
tower_insert (k >= i && k < j ? &src : &dst,
}
/* Splice SRC into DST. */
}
/* Splice SRC into DST. */
- tower_splice (&dst, j < block_cnt ? &blocks[j].node : NULL,
+ tower_splice (&dst, j < n_blocks ? &blocks[j].node : NULL,
&src, i != j ? &blocks[i].node : NULL, NULL);
&src, i != j ? &blocks[i].node : NULL, NULL);
- check_tower (&dst, expected, block_cnt);
+ check_tower (&dst, expected, n_blocks);
- check (composition_cnt == 1 << (cnt - 1));
+ check (n_compositions == 1 << (cnt - 1));
free (expected);
free (new_sizes);
free (expected);
free (new_sizes);
goto error;
dict_reorder_vars (dict, keep_vars, n_keep_vars);
dict_delete_consecutive_vars (dict, n_keep_vars,
goto error;
dict_reorder_vars (dict, keep_vars, n_keep_vars);
dict_delete_consecutive_vars (dict, n_keep_vars,
- dict_get_var_cnt (dict) - n_keep_vars);
+ dict_get_n_vars (dict) - n_keep_vars);
static void
read_value_label_record (struct sfm_reader *r)
{
static void
read_value_label_record (struct sfm_reader *r)
{
- int label_cnt, var_cnt;
int i;
printf ("%08llx: value labels record\n", (long long int) ftello (r->file));
/* Read number of labels. */
int i;
printf ("%08llx: value labels record\n", (long long int) ftello (r->file));
/* Read number of labels. */
- label_cnt = read_int (r);
- for (i = 0; i < label_cnt; i++)
+ n_labels = read_int (r);
+ for (i = 0; i < n_labels; i++)
{
char raw_value[8];
unsigned char label_len;
{
char raw_value[8];
unsigned char label_len;
/* Read number of variables associated with value label from type 4
record. */
printf ("\t%08llx: apply to variables", (long long int) ftello (r->file));
/* Read number of variables associated with value label from type 4
record. */
printf ("\t%08llx: apply to variables", (long long int) ftello (r->file));
- var_cnt = read_int (r);
- for (i = 0; i < var_cnt; i++)
+ n_vars = read_int (r);
+ for (i = 0; i < n_vars; i++)
printf (" #%d", read_int (r));
putchar ('\n');
}
printf (" #%d", read_int (r));
putchar ('\n');
}
too. */
static inline bool
read_bytes_internal (struct sfm_reader *r, bool eof_is_ok,
too. */
static inline bool
read_bytes_internal (struct sfm_reader *r, bool eof_is_ok,
- void *buf, size_t byte_cnt)
+ void *buf, size_t n_bytes)
- size_t bytes_read = fread (buf, 1, byte_cnt, r->file);
- if (bytes_read == byte_cnt)
+ size_t bytes_read = fread (buf, 1, n_bytes, r->file);
+ if (bytes_read == n_bytes)
return true;
else if (ferror (r->file))
sys_error (r, "System error: %s.", strerror (errno));
return true;
else if (ferror (r->file))
sys_error (r, "System error: %s.", strerror (errno));
/* Reads BYTE_CNT into BUF.
Aborts upon I/O error or if end-of-file is encountered. */
static void
/* Reads BYTE_CNT into BUF.
Aborts upon I/O error or if end-of-file is encountered. */
static void
-read_bytes (struct sfm_reader *r, void *buf, size_t byte_cnt)
+read_bytes (struct sfm_reader *r, void *buf, size_t n_bytes)
- read_bytes_internal (r, false, buf, byte_cnt);
+ read_bytes_internal (r, false, buf, n_bytes);
}
/* Reads BYTE_CNT bytes into BUF.
}
/* Reads BYTE_CNT bytes into BUF.
Returns false if an immediate end-of-file is encountered.
Aborts if an I/O error or a partial read occurs. */
static bool
Returns false if an immediate end-of-file is encountered.
Aborts if an I/O error or a partial read occurs. */
static bool
-try_read_bytes (struct sfm_reader *r, void *buf, size_t byte_cnt)
+try_read_bytes (struct sfm_reader *r, void *buf, size_t n_bytes)
- return read_bytes_internal (r, true, buf, byte_cnt);
+ return read_bytes_internal (r, true, buf, n_bytes);
}
/* Reads a 32-bit signed integer from R and returns its value in
}
/* Reads a 32-bit signed integer from R and returns its value in