of variables, and returns the new variable.
@end deftypefun
-@deftypefun {struct variable *} dict_clone_var (struct dictionary *@var{dict}, const struct variable *@var{old_var}, const char *@var{name})
-@deftypefunx {struct variable *} dict_clone_var_assert (struct dictionary *@var{dict}, const struct variable *@var{old_var}, const char *@var{name})
+@deftypefun {struct variable *} dict_clone_var (struct dictionary *@var{dict}, const struct variable *@var{old_var})
+@deftypefunx {struct variable *} dict_clone_var_assert (struct dictionary *@var{dict}, const struct variable *@var{old_var})
Creates a new variable as a clone of @var{var}, inserts the new
-variable into @var{dict}, and returns the new variable. The new
-variable is named @var{name}. Other properties of the new variable
-are copied from @var{old_var}, except for those not copied by
-@code{var_clone} (@pxref{var_clone}).
+variable into @var{dict}, and returns the new variable. Other
+properties of the new variable are copied from @var{old_var}, except
+for those not copied by @code{var_clone} (@pxref{var_clone}).
@var{var} does not need to be a member of any dictionary.
@end deftypefun
+@deftypefun {struct variable *} dict_clone_var_as (struct dictionary *@var{dict}, const struct variable *@var{old_var}, const char *@var{name})
+@deftypefunx {struct variable *} dict_clone_var_as_assert (struct dictionary *@var{dict}, const struct variable *@var{old_var}, const char *@var{name})
+These functions are similar to @code{dict_clone_var} and
+@code{dict_clone_var_assert}, respectively, except that the new
+variable is named @var{name} instead of keeping @var{old_var}'s name.
+@end deftypefun
+
@node Dictionary Deleting Variables
@subsection Deleting Variables
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
const struct vardict_info *svdi;
struct vardict_info dvdi;
struct variable *sv = s->var[i];
- struct variable *dv = dict_clone_var_assert (d, sv, var_get_name (sv));
+ struct variable *dv = dict_clone_var_assert (d, sv);
size_t i;
for (i = 0; i < var_get_short_name_cnt (sv); i++)
return add_var (d, var_create (name, width));
}
-/* Creates and returns a new variable in D with name NAME, as a
- copy of existing variable OLD_VAR, which need not be in D or
- in any dictionary. Returns a null pointer if the given NAME
- would duplicate that of an existing variable in the
+/* Creates and returns a new variable in D, as a copy of existing variable
+ OLD_VAR, which need not be in D or in any dictionary. Returns a null
+ pointer if OLD_VAR's name would duplicate that of an existing variable in
+ the dictionary. */
+struct variable *
+dict_clone_var (struct dictionary *d, const struct variable *old_var)
+{
+ return dict_clone_var_as (d, old_var, var_get_name (old_var));
+}
+
+/* Creates and returns a new variable in D, as a copy of existing variable
+ OLD_VAR, which need not be in D or in any dictionary. Assert-fails if
+ OLD_VAR's name would duplicate that of an existing variable in the
dictionary. */
struct variable *
-dict_clone_var (struct dictionary *d, const struct variable *old_var,
- const char *name)
+dict_clone_var_assert (struct dictionary *d, const struct variable *old_var)
+{
+ return dict_clone_var_as_assert (d, old_var, var_get_name (old_var));
+}
+
+/* Creates and returns a new variable in D with name NAME, as a copy of
+ existing variable OLD_VAR, which need not be in D or in any dictionary.
+ Returns a null pointer if the given NAME would duplicate that of an existing
+ variable in the dictionary. */
+struct variable *
+dict_clone_var_as (struct dictionary *d, const struct variable *old_var,
+ const char *name)
{
return (dict_lookup_var (d, name) == NULL
- ? dict_clone_var_assert (d, old_var, name)
+ ? dict_clone_var_as_assert (d, old_var, name)
: NULL);
}
-/* Creates and returns a new variable in D with name NAME, as a
- copy of existing variable OLD_VAR, which need not be in D or
- in any dictionary. Assert-fails if the given NAME would
- duplicate that of an existing variable in the dictionary. */
+/* Creates and returns a new variable in D with name NAME, as a copy of
+ existing variable OLD_VAR, which need not be in D or in any dictionary.
+ Assert-fails if the given NAME would duplicate that of an existing variable
+ in the dictionary. */
struct variable *
-dict_clone_var_assert (struct dictionary *d, const struct variable *old_var,
- const char *name)
+dict_clone_var_as_assert (struct dictionary *d, const struct variable *old_var,
+ const char *name)
{
struct variable *new_var = var_clone (old_var);
assert (dict_lookup_var (d, name) == NULL);
/* PSPP - a program for statistical analysis.
- Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007, 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
int width);
struct variable *dict_create_var_assert (struct dictionary *, const char *,
int width);
-struct variable *dict_clone_var (struct dictionary *, const struct variable *,
- const char *);
+struct variable *dict_clone_var (struct dictionary *, const struct variable *);
struct variable *dict_clone_var_assert (struct dictionary *,
- const struct variable *, const char *);
+ const struct variable *);
+struct variable *dict_clone_var_as (struct dictionary *,
+ const struct variable *, const char *);
+struct variable *dict_clone_var_as_assert (struct dictionary *,
+ const struct variable *,
+ const char *);
/* Deleting variables. */
void dict_delete_var (struct dictionary *, struct variable *);
var_set_label (mv, var_get_label (dv));
}
else
- mv = dict_clone_var_assert (m, dv, var_get_name (dv));
+ mv = dict_clone_var_assert (m, dv);
}
return true;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
agr.break_var_cnt = subcase_get_n_fields (&agr.sort);
for (i = 0; i < agr.break_var_cnt; i++)
- dict_clone_var_assert (agr.dict, agr.break_vars[i],
- var_get_name (agr.break_vars[i]));
+ dict_clone_var_assert (agr.dict, agr.break_vars[i]);
/* BREAK must follow the options. */
break;
}
if (function->alpha_type == VAL_STRING)
- destvar = dict_clone_var (agr->dict, v->src, dest[i]);
+ destvar = dict_clone_var_as (agr->dict, v->src, dest[i]);
else
{
assert (var_is_numeric (v->src)
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
clip_dict = dict_create ();
dict_set_encoding (clip_dict, dict_get_encoding (ds->dict->dict));
for (i = col0; i <= coli; i++)
- {
- const struct variable *old = dict_get_var (ds->dict->dict, i);
- dict_clone_var_assert (clip_dict, old, var_get_name (old));
- }
+ dict_clone_var_assert (clip_dict, dict_get_var (ds->dict->dict, i));
/* Construct clip data. */
map = case_map_by_name (ds->dict->dict, clip_dict);
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009 Free Software Foundation
+ Copyright (C) 2008, 2009, 2010 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
if (!dict_make_unique_var_name (dict, var_get_name (modified_var),
&number, name))
NOT_REACHED ();
- dict_clone_var_assert (dict, modified_var, name);
+ dict_clone_var_as_assert (dict, modified_var, name);
}
}
fmt_guesser_destroy (fg);