[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src ui/gui/var-type-dialog.c language/xfor... [simpler-p
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp/src ui/gui/var-type-dialog.c language/xfor... [simpler-proc] |
Date: |
Thu, 31 May 2007 18:15:04 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Branch: simpler-proc
Changes by: Ben Pfaff <blp> 07/05/31 18:15:02
Modified files:
src/ui/gui : var-type-dialog.c
src/language/xforms: recode.c compute.c
src/language/stats: t-test.q regression.q frequencies.q
descriptives.c aggregate.c
src/language/lexer: variable-parser.c lexer.c
src/language/expressions: parse.c evaluate.c
src/language/dictionary: vector.c modify-variables.c formats.c
src/language/data-io: list.q get.c file-handle.q data-list.c
src/data : vector.h vector.c variable.h variable.c value.h
value-labels.c missing-values.c format.h
format.c file-handle-def.c
Added files:
src/data : val-type.h
Log message:
Some fairly experimental changes based on what seemed to make sense
while writing the manual:
- Rename LONG_NAME_LEN to VAR_NAME_LEN. Short names are
exceptional, so we might as well just call "long" names
variable names.
- Separate the concept of a value's type and width, a union
value, and a variable's type.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/var-type-dialog.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.15&r2=1.15.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/xforms/recode.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.19&r2=1.19.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/xforms/compute.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.14&r2=1.14.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/t-test.q?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.20.2.2&r2=1.20.2.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/regression.q?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.45.2.2&r2=1.45.2.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/frequencies.q?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.29.2.2&r2=1.29.2.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/descriptives.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.22.2.2&r2=1.22.2.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/aggregate.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.30.2.2&r2=1.30.2.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/lexer/variable-parser.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.15.2.1&r2=1.15.2.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/lexer/lexer.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.19&r2=1.19.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/expressions/parse.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.24&r2=1.24.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/expressions/evaluate.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.18.2.1&r2=1.18.2.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/dictionary/vector.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.13&r2=1.13.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/dictionary/modify-variables.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.16.2.1&r2=1.16.2.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/dictionary/formats.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.16&r2=1.16.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/list.q?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.24.2.2&r2=1.24.2.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/get.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.29.2.3&r2=1.29.2.4
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/file-handle.q?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.13&r2=1.13.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/data-list.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.30.2.3&r2=1.30.2.4
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/vector.h?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.2&r2=1.2.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/vector.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.2&r2=1.2.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/variable.h?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.20&r2=1.20.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/variable.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.21.2.1&r2=1.21.2.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/value.h?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.7.2.2&r2=1.7.2.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/value-labels.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.15&r2=1.15.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/missing-values.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.9&r2=1.9.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/format.h?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.13&r2=1.13.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/format.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.19&r2=1.19.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/file-handle-def.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.8&r2=1.8.2.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/val-type.h?cvsroot=pspp&only_with_tag=simpler-proc&rev=1.1.2.1
Patches:
Index: ui/gui/var-type-dialog.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/var-type-dialog.c,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -u -b -r1.15 -r1.15.2.1
--- ui/gui/var-type-dialog.c 27 Jan 2007 00:56:29 -0000 1.15
+++ ui/gui/var-type-dialog.c 31 May 2007 18:14:57 -0000 1.15.2.1
@@ -791,14 +791,14 @@
gint decimals = atoi (gtk_entry_get_text
(GTK_ENTRY (dialog->entry_decimals)));
- gint new_type = VAR_NUMERIC;
+ gint new_type = VAL_NUMERIC;
gint new_width = 0;
bool result = false;
struct fmt_spec spec;
switch (dialog->active_button)
{
case BUTTON_STRING:
- new_type = VAR_STRING;
+ new_type = VAL_STRING;
new_width = width;
result = make_output_format_try (&spec, FMT_A, width, 0);
break;
Index: language/xforms/recode.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/xforms/recode.c,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -b -r1.19 -r1.19.2.1
--- language/xforms/recode.c 2 Feb 2007 00:52:38 -0000 1.19
+++ language/xforms/recode.c 31 May 2007 18:14:57 -0000 1.19.2.1
@@ -93,8 +93,8 @@
struct pool *pool;
/* Variable types, for convenience. */
- enum var_type src_type; /* src_vars[*]->type. */
- enum var_type dst_type; /* dst_vars[*]->type. */
+ enum val_type src_type; /* src_vars[*] type. */
+ enum val_type dst_type; /* dst_vars[*] type. */
/* Variables. */
struct variable **src_vars; /* Source variables. */
@@ -115,7 +115,7 @@
size_t *map_allocated, const struct map_in *);
static bool parse_map_in (struct lexer *lexer, struct map_in *, struct pool *,
- enum var_type src_type, size_t max_src_width);
+ enum val_type src_type, size_t max_src_width);
static void set_map_in_generic (struct map_in *, enum map_in_type);
static void set_map_in_num (struct map_in *, enum map_in_type, double, double);
static void set_map_in_str (struct map_in *, struct pool *,
@@ -156,7 +156,7 @@
/* Ensure that all the output strings are at least as wide
as the widest destination variable. */
- if (trns->dst_type == VAR_STRING)
+ if (trns->dst_type == VAL_STRING)
enlarge_dst_widths (trns);
/* Create destination variables, if needed.
@@ -218,7 +218,7 @@
return false;
do
{
- enum var_type dst_type;
+ enum val_type dst_type;
if (!lex_match_id (lexer, "CONVERT"))
{
@@ -242,7 +242,7 @@
if (!parse_map_out (lexer, trns->pool, &out))
return false;
- dst_type = var_type_from_width (out.width);
+ dst_type = val_type_from_width (out.width);
if (have_dst_type && dst_type != trns->dst_type)
{
msg (SE, _("Inconsistent target variable types. "
@@ -261,9 +261,9 @@
set_map_in_generic (&in, MAP_CONVERT);
add_mapping (trns, &map_allocated, &in);
- dst_type = VAR_NUMERIC;
- if (trns->src_type != VAR_STRING
- || (have_dst_type && trns->dst_type != VAR_NUMERIC))
+ dst_type = VAL_NUMERIC;
+ if (trns->src_type != VAL_STRING
+ || (have_dst_type && trns->dst_type != VAL_NUMERIC))
{
msg (SE, _("CONVERT requires string input values and "
"numeric output values."));
@@ -288,11 +288,11 @@
false on parse error. */
static bool
parse_map_in (struct lexer *lexer, struct map_in *in, struct pool *pool,
- enum var_type src_type, size_t max_src_width)
+ enum val_type src_type, size_t max_src_width)
{
if (lex_match_id (lexer, "ELSE"))
set_map_in_generic (in, MAP_ELSE);
- else if (src_type == VAR_NUMERIC)
+ else if (src_type == VAL_NUMERIC)
{
if (lex_match_id (lexer, "MISSING"))
set_map_in_generic (in, MAP_MISSING);
@@ -445,7 +445,7 @@
{
struct variable *v;
v = trns->dst_vars[i] = dict_lookup_var (dict, trns->dst_names[i]);
- if (v == NULL && trns->dst_type == VAR_STRING)
+ if (v == NULL && trns->dst_type == VAL_STRING)
{
msg (SE, _("There is no variable named "
"%s. (All string variables specified "
@@ -464,8 +464,8 @@
{
msg (SE, _("INTO is required with %s input values "
"and %s output values."),
- trns->src_type == VAR_NUMERIC ? _("numeric") : _("string"),
- trns->dst_type == VAR_NUMERIC ? _("numeric") : _("string"));
+ trns->src_type == VAL_NUMERIC ? _("numeric") : _("string"),
+ trns->dst_type == VAL_NUMERIC ? _("numeric") : _("string"));
return false;
}
}
@@ -477,7 +477,7 @@
{
msg (SE, _("Type mismatch. Cannot store %s data in "
"%s variable %s."),
- trns->dst_type == VAR_STRING ? _("string") : _("numeric"),
+ trns->dst_type == VAL_STRING ? _("string") : _("numeric"),
var_is_alpha (v) ? _("string") : _("numeric"),
var_get_name (v));
return false;
@@ -635,12 +635,12 @@
const struct map_out *out;
- if (trns->src_type == VAR_NUMERIC)
+ if (trns->src_type == VAL_NUMERIC)
out = find_src_numeric (trns, src_data->f, src_var);
else
out = find_src_string (trns, src_data->s, var_get_width (src_var));
- if (trns->dst_type == VAR_NUMERIC)
+ if (trns->dst_type == VAL_NUMERIC)
{
if (out != NULL)
dst_data->f = !out->copy_input ? out->value.f : src_data->f;
Index: language/xforms/compute.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/xforms/compute.c,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -b -r1.14 -r1.14.2.1
--- language/xforms/compute.c 15 Dec 2006 00:16:03 -0000 1.14
+++ language/xforms/compute.c 31 May 2007 18:14:57 -0000 1.14.2.1
@@ -259,7 +259,7 @@
static trns_proc_func *
get_proc_func (const struct lvalue *lvalue)
{
- bool is_numeric = lvalue_get_type (lvalue) == VAR_NUMERIC;
+ bool is_numeric = lvalue_get_type (lvalue) == VAL_NUMERIC;
bool is_vector = lvalue_is_vector (lvalue);
return (is_numeric
@@ -273,7 +273,7 @@
parse_rvalue (struct lexer *lexer,
const struct lvalue *lvalue, struct dataset *ds)
{
- bool is_numeric = lvalue_get_type (lvalue) == VAR_NUMERIC;
+ bool is_numeric = lvalue_get_type (lvalue) == VAL_NUMERIC;
return expr_parse (lexer, ds, is_numeric ? EXPR_NUMBER : EXPR_STRING);
}
Index: language/stats/t-test.q
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/stats/t-test.q,v
retrieving revision 1.20.2.2
retrieving revision 1.20.2.3
diff -u -b -r1.20.2.2 -r1.20.2.3
--- language/stats/t-test.q 4 May 2007 03:48:48 -0000 1.20.2.2
+++ language/stats/t-test.q 31 May 2007 18:14:57 -0000 1.20.2.3
@@ -151,7 +151,7 @@
static struct pair *pairs=0;
-static int parse_value (struct lexer *lexer, union value * v, enum var_type);
+static int parse_value (struct lexer *lexer, union value * v, enum val_type);
/* Structures and Functions for the Statistics Summary Box */
struct ssbox;
@@ -570,9 +570,9 @@
/* Parses the current token (numeric or string, depending on type)
value v and returns success. */
static int
-parse_value (struct lexer *lexer, union value * v, enum var_type type)
+parse_value (struct lexer *lexer, union value * v, enum val_type type)
{
- if (type == VAR_NUMERIC)
+ if (type == VAL_NUMERIC)
{
if (!lex_force_num (lexer))
return 0;
Index: language/stats/regression.q
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/stats/regression.q,v
retrieving revision 1.45.2.2
retrieving revision 1.45.2.3
diff -u -b -r1.45.2.2 -r1.45.2.3
--- language/stats/regression.q 4 May 2007 03:48:48 -0000 1.45.2.2
+++ language/stats/regression.q 31 May 2007 18:14:58 -0000 1.45.2.3
@@ -630,15 +630,15 @@
}
static void
-reg_get_name (const struct dictionary *dict, char name[LONG_NAME_LEN], const
char prefix[LONG_NAME_LEN])
+reg_get_name (const struct dictionary *dict, char name[VAR_NAME_LEN], const
char prefix[VAR_NAME_LEN])
{
int i = 1;
- snprintf (name, LONG_NAME_LEN, "%s%d", prefix, i);
+ snprintf (name, VAR_NAME_LEN, "%s%d", prefix, i);
while (!try_name (dict, name))
{
i++;
- snprintf (name, LONG_NAME_LEN, "%s%d", prefix, i);
+ snprintf (name, VAR_NAME_LEN, "%s%d", prefix, i);
}
}
@@ -648,7 +648,7 @@
{
struct dictionary *dict = dataset_dict (ds);
static int trns_index = 1;
- char name[LONG_NAME_LEN];
+ char name[VAR_NAME_LEN];
struct variable *new_var;
struct reg_trns *t = NULL;
Index: language/stats/frequencies.q
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/stats/frequencies.q,v
retrieving revision 1.29.2.2
retrieving revision 1.29.2.3
diff -u -b -r1.29.2.2 -r1.29.2.3
--- language/stats/frequencies.q 4 May 2007 03:48:48 -0000 1.29.2.2
+++ language/stats/frequencies.q 31 May 2007 18:14:58 -0000 1.29.2.3
@@ -687,12 +687,12 @@
}
/* Returns the comparison function that should be used for
- sorting a frequency table by FRQ_SORT using VAR_TYPE
- variables. */
+ sorting a frequency table by FRQ_SORT using VAL_TYPE
+ values. */
static hsh_compare_func *
-get_freq_comparator (int frq_sort, enum var_type var_type)
+get_freq_comparator (int frq_sort, enum val_type val_type)
{
- bool is_numeric = var_type == VAR_NUMERIC;
+ bool is_numeric = val_type == VAL_NUMERIC;
switch (frq_sort)
{
case FRQ_AVALUE:
Index: language/stats/descriptives.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/stats/descriptives.c,v
retrieving revision 1.22.2.2
retrieving revision 1.22.2.3
diff -u -b -r1.22.2.2 -r1.22.2.3
--- language/stats/descriptives.c 4 May 2007 03:48:48 -0000 1.22.2.2
+++ language/stats/descriptives.c 31 May 2007 18:14:58 -0000 1.22.2.3
@@ -125,7 +125,7 @@
struct dsc_var
{
struct variable *v; /* Variable to calculate on. */
- char z_name[LONG_NAME_LEN + 1]; /* Name for z-score variable. */
+ char z_name[VAR_NAME_LEN + 1]; /* Name for z-score variable. */
double valid, missing; /* Valid, missing counts. */
struct moments *moments; /* Moments. */
double min, max; /* Maximum and mimimum values. */
@@ -497,7 +497,7 @@
generate_z_varname (const struct dictionary *dict, struct dsc_proc *dsc, char
*z_name,
const char *var_name, int *z_cnt)
{
- char name[LONG_NAME_LEN + 1];
+ char name[VAR_NAME_LEN + 1];
/* Try a name based on the original variable name. */
name[0] = 'Z';
Index: language/stats/aggregate.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/stats/aggregate.c,v
retrieving revision 1.30.2.2
retrieving revision 1.30.2.3
diff -u -b -r1.30.2.2 -r1.30.2.3
--- language/stats/aggregate.c 4 May 2007 03:48:48 -0000 1.30.2.2
+++ language/stats/aggregate.c 31 May 2007 18:14:58 -0000 1.30.2.3
@@ -94,7 +94,7 @@
{
const char *name; /* Aggregation function name. */
size_t n_args; /* Number of arguments. */
- enum var_type alpha_type; /* When given ALPHA arguments, output type. */
+ enum val_type alpha_type; /* When given ALPHA arguments, output type. */
struct fmt_spec format; /* Format spec if alpha_type != ALPHA. */
};
@@ -105,25 +105,25 @@
{"SUM", 0, -1, {FMT_F, 8, 2}},
{"MEAN", 0, -1, {FMT_F, 8, 2}},
{"SD", 0, -1, {FMT_F, 8, 2}},
- {"MAX", 0, VAR_STRING, {-1, -1, -1}},
- {"MIN", 0, VAR_STRING, {-1, -1, -1}},
- {"PGT", 1, VAR_NUMERIC, {FMT_F, 5, 1}},
- {"PLT", 1, VAR_NUMERIC, {FMT_F, 5, 1}},
- {"PIN", 2, VAR_NUMERIC, {FMT_F, 5, 1}},
- {"POUT", 2, VAR_NUMERIC, {FMT_F, 5, 1}},
- {"FGT", 1, VAR_NUMERIC, {FMT_F, 5, 3}},
- {"FLT", 1, VAR_NUMERIC, {FMT_F, 5, 3}},
- {"FIN", 2, VAR_NUMERIC, {FMT_F, 5, 3}},
- {"FOUT", 2, VAR_NUMERIC, {FMT_F, 5, 3}},
- {"N", 0, VAR_NUMERIC, {FMT_F, 7, 0}},
- {"NU", 0, VAR_NUMERIC, {FMT_F, 7, 0}},
- {"NMISS", 0, VAR_NUMERIC, {FMT_F, 7, 0}},
- {"NUMISS", 0, VAR_NUMERIC, {FMT_F, 7, 0}},
- {"FIRST", 0, VAR_STRING, {-1, -1, -1}},
- {"LAST", 0, VAR_STRING, {-1, -1, -1}},
+ {"MAX", 0, VAL_STRING, {-1, -1, -1}},
+ {"MIN", 0, VAL_STRING, {-1, -1, -1}},
+ {"PGT", 1, VAL_NUMERIC, {FMT_F, 5, 1}},
+ {"PLT", 1, VAL_NUMERIC, {FMT_F, 5, 1}},
+ {"PIN", 2, VAL_NUMERIC, {FMT_F, 5, 1}},
+ {"POUT", 2, VAL_NUMERIC, {FMT_F, 5, 1}},
+ {"FGT", 1, VAL_NUMERIC, {FMT_F, 5, 3}},
+ {"FLT", 1, VAL_NUMERIC, {FMT_F, 5, 3}},
+ {"FIN", 2, VAL_NUMERIC, {FMT_F, 5, 3}},
+ {"FOUT", 2, VAL_NUMERIC, {FMT_F, 5, 3}},
+ {"N", 0, VAL_NUMERIC, {FMT_F, 7, 0}},
+ {"NU", 0, VAL_NUMERIC, {FMT_F, 7, 0}},
+ {"NMISS", 0, VAL_NUMERIC, {FMT_F, 7, 0}},
+ {"NUMISS", 0, VAL_NUMERIC, {FMT_F, 7, 0}},
+ {"FIRST", 0, VAL_STRING, {-1, -1, -1}},
+ {"LAST", 0, VAL_STRING, {-1, -1, -1}},
{NULL, 0, -1, {-1, -1, -1}},
- {"N", 0, VAR_NUMERIC, {FMT_F, 7, 0}},
- {"NU", 0, VAR_NUMERIC, {FMT_F, 7, 0}},
+ {"N", 0, VAL_NUMERIC, {FMT_F, 7, 0}},
+ {"NU", 0, VAL_NUMERIC, {FMT_F, 7, 0}},
};
/* Missing value types. */
@@ -475,12 +475,12 @@
if (lex_token (lexer) == T_STRING)
{
arg[i].c = ds_xstrdup (lex_tokstr (lexer));
- type = VAR_STRING;
+ type = VAL_STRING;
}
else if (lex_is_number (lexer))
{
arg[i].f = lex_tokval (lexer);
- type = VAR_NUMERIC;
+ type = VAL_NUMERIC;
}
else
{
@@ -570,12 +570,12 @@
v->string = xmalloc (var_get_width (src[i]));
}
- if (function->alpha_type == VAR_STRING)
+ if (function->alpha_type == VAL_STRING)
destvar = dict_clone_var (agr->dict, v->src, dest[i]);
else
{
assert (var_is_numeric (v->src)
- || function->alpha_type == VAR_NUMERIC);
+ || function->alpha_type == VAL_NUMERIC);
destvar = dict_create_var (agr->dict, dest[i], 0);
if (destvar != NULL)
{
Index: language/lexer/variable-parser.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/lexer/variable-parser.c,v
retrieving revision 1.15.2.1
retrieving revision 1.15.2.2
diff -u -b -r1.15.2.1 -r1.15.2.2
--- language/lexer/variable-parser.c 19 Mar 2007 21:36:24 -0000 1.15.2.1
+++ language/lexer/variable-parser.c 31 May 2007 18:14:58 -0000 1.15.2.2
@@ -396,8 +396,8 @@
int d1, d2;
int n;
size_t nvar, mvar;
- char name1[LONG_NAME_LEN + 1], name2[LONG_NAME_LEN + 1];
- char root1[LONG_NAME_LEN + 1], root2[LONG_NAME_LEN + 1];
+ char name1[VAR_NAME_LEN + 1], name2[VAR_NAME_LEN + 1];
+ char root1[VAR_NAME_LEN + 1], root2[VAR_NAME_LEN + 1];
int success = 0;
assert (names != NULL);
@@ -465,7 +465,7 @@
for (n = n1; n <= n2; n++)
{
- char name[LONG_NAME_LEN + 1];
+ char name[VAR_NAME_LEN + 1];
sprintf (name, "%s%0*d", root1, d1, n);
(*names)[nvar] = xstrdup (name);
nvar++;
@@ -655,7 +655,7 @@
{
assert (vs != NULL);
assert (name != NULL);
- assert (strlen (name) <= LONG_NAME_LEN);
+ assert (strlen (name) <= VAR_NAME_LEN);
return vs->lookup_var_idx (vs, name, idx);
}
Index: language/lexer/lexer.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/lexer/lexer.c,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -b -r1.19 -r1.19.2.1
--- language/lexer/lexer.c 9 Feb 2007 05:19:08 -0000 1.19
+++ language/lexer/lexer.c 31 May 2007 18:14:59 -0000 1.19.2.1
@@ -53,7 +53,7 @@
int token; /* Current token. */
double tokval; /* T_POS_NUM, T_NEG_NUM: the token's value. */
- char tokid [LONG_NAME_LEN + 1]; /* T_ID: the identifier. */
+ char tokid [VAR_NAME_LEN + 1]; /* T_ID: the identifier. */
struct string tokstr; /* T_ID, T_STRING: token string value.
For T_ID, this is not truncated as is
Index: language/expressions/parse.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/expressions/parse.c,v
retrieving revision 1.24
retrieving revision 1.24.2.1
diff -u -b -r1.24 -r1.24.2.1
--- language/expressions/parse.c 1 Feb 2007 15:01:42 -0000 1.24
+++ language/expressions/parse.c 31 May 2007 18:14:59 -0000 1.24.2.1
@@ -357,7 +357,7 @@
msg_disable ();
if ((*node)->type == OP_format
&& fmt_check_input (&(*node)->format.f)
- && fmt_check_type_compat (&(*node)->format.f, VAR_NUMERIC))
+ && fmt_check_type_compat (&(*node)->format.f, VAL_NUMERIC))
{
msg_enable ();
if (do_coercion)
@@ -371,7 +371,7 @@
msg_disable ();
if ((*node)->type == OP_format
&& fmt_check_output (&(*node)->format.f)
- && fmt_check_type_compat (&(*node)->format.f, VAR_NUMERIC))
+ && fmt_check_type_compat (&(*node)->format.f, VAL_NUMERIC))
{
msg_enable ();
if (do_coercion)
@@ -919,7 +919,7 @@
|| !lex_match (lexer, ')'))
return NULL;
- return expr_allocate_binary (e, (vector_get_type (vector) == VAR_NUMERIC
+ return expr_allocate_binary (e, (vector_get_type (vector) == VAL_NUMERIC
? OP_VEC_ELEM_NUM : OP_VEC_ELEM_STR),
element, expr_allocate_vector (e, vector));
}
Index: language/expressions/evaluate.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/expressions/evaluate.c,v
retrieving revision 1.18.2.1
retrieving revision 1.18.2.2
diff -u -b -r1.18.2.1 -r1.18.2.2
--- language/expressions/evaluate.c 19 Mar 2007 21:36:24 -0000 1.18.2.1
+++ language/expressions/evaluate.c 31 May 2007 18:14:59 -0000 1.18.2.2
@@ -127,7 +127,7 @@
dump_postfix = 1;
else if (lex_match (lexer, '('))
{
- char name[LONG_NAME_LEN + 1];
+ char name[VAR_NAME_LEN + 1];
struct variable *v;
size_t old_value_cnt;
int width;
Index: language/dictionary/vector.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/dictionary/vector.c,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -u -b -r1.13 -r1.13.2.1
--- language/dictionary/vector.c 9 Feb 2007 05:28:21 -0000 1.13
+++ language/dictionary/vector.c 31 May 2007 18:14:59 -0000 1.13.2.1
@@ -137,7 +137,7 @@
seen_format = true;
if (!parse_format_specifier (lexer, &format)
|| !fmt_check_output (&format)
- || !fmt_check_type_compat (&format, VAR_NUMERIC))
+ || !fmt_check_type_compat (&format, VAL_NUMERIC))
goto fail;
}
else
@@ -154,16 +154,16 @@
}
/* Check that none of the variables exist and that
- their names are no more than LONG_NAME_LEN bytes
+ their names are no more than VAR_NAME_LEN bytes
long. */
for (i = 0; i < vector_cnt; i++)
{
int j;
for (j = 0; j < var_cnt; j++)
{
- char name[LONG_NAME_LEN + INT_STRLEN_BOUND (int) + 1];
+ char name[VAR_NAME_LEN + INT_STRLEN_BOUND (int) + 1];
sprintf (name, "%s%d", vectors[i], j + 1);
- if (strlen (name) > LONG_NAME_LEN)
+ if (strlen (name) > VAR_NAME_LEN)
{
msg (SE, _("%s is too long for a variable name."), name);
goto fail;
@@ -183,7 +183,7 @@
int j;
for (j = 0; j < var_cnt; j++)
{
- char name[LONG_NAME_LEN + 1];
+ char name[VAR_NAME_LEN + 1];
sprintf (name, "%s%d", vectors[i], j + 1);
vars[j] = dict_create_var_assert (dict, name, 0);
var_set_both_formats (vars[j], &format);
Index: language/dictionary/modify-variables.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/dictionary/modify-variables.c,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -u -b -r1.16.2.1 -r1.16.2.2
--- language/dictionary/modify-variables.c 19 Mar 2007 21:36:24 -0000
1.16.2.1
+++ language/dictionary/modify-variables.c 31 May 2007 18:15:00 -0000
1.16.2.2
@@ -370,7 +370,7 @@
struct var_renaming
{
struct variable *var;
- char new_name[LONG_NAME_LEN + 1];
+ char new_name[VAR_NAME_LEN + 1];
};
/* A algo_compare_func that compares new_name members in struct
Index: language/dictionary/formats.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/dictionary/formats.c,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -b -r1.16 -r1.16.2.1
--- language/dictionary/formats.c 15 Dec 2006 00:16:02 -0000 1.16
+++ language/dictionary/formats.c 31 May 2007 18:15:00 -0000 1.16.2.1
@@ -93,7 +93,7 @@
}
if (!parse_format_specifier (lexer, &f)
|| !fmt_check_output (&f)
- || !fmt_check_type_compat (&f, VAR_NUMERIC))
+ || !fmt_check_type_compat (&f, VAL_NUMERIC))
goto fail;
if (!lex_match (lexer, ')'))
Index: language/data-io/list.q
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/data-io/list.q,v
retrieving revision 1.24.2.2
retrieving revision 1.24.2.3
diff -u -b -r1.24.2.2 -r1.24.2.3
--- language/data-io/list.q 4 May 2007 03:48:47 -0000 1.24.2.2
+++ language/data-io/list.q 31 May 2007 18:15:00 -0000 1.24.2.3
@@ -508,7 +508,7 @@
}
{
- char varname[LONG_NAME_LEN + 2];
+ char varname[VAR_NAME_LEN + 2];
snprintf (varname, sizeof varname,
" %s", var_get_name (cmd.v_variables[index]));
write_varname (d, varname, leader_width);
Index: language/data-io/get.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/data-io/get.c,v
retrieving revision 1.29.2.3
retrieving revision 1.29.2.4
diff -u -b -r1.29.2.3 -r1.29.2.4
--- language/data-io/get.c 4 May 2007 03:48:47 -0000 1.29.2.3
+++ language/data-io/get.c 31 May 2007 18:15:00 -0000 1.29.2.4
@@ -727,8 +727,8 @@
bool saw_in = false;
struct casereader *active_file = NULL;
- char first_name[LONG_NAME_LEN + 1] = "";
- char last_name[LONG_NAME_LEN + 1] = "";
+ char first_name[VAR_NAME_LEN + 1] = "";
+ char last_name[VAR_NAME_LEN + 1] = "";
struct taint *taint = NULL;
Index: language/data-io/file-handle.q
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/data-io/file-handle.q,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -u -b -r1.13 -r1.13.2.1
--- language/data-io/file-handle.q 9 Feb 2007 05:19:08 -0000 1.13
+++ language/data-io/file-handle.q 31 May 2007 18:15:00 -0000 1.13.2.1
@@ -51,7 +51,7 @@
int
cmd_file_handle (struct lexer *lexer, struct dataset *ds)
{
- char handle_name[LONG_NAME_LEN + 1];
+ char handle_name[VAR_NAME_LEN + 1];
struct fh_properties properties = *fh_default_properties ();
struct cmd_file_handle cmd;
Index: language/data-io/data-list.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/data-io/data-list.c,v
retrieving revision 1.30.2.3
retrieving revision 1.30.2.4
diff -u -b -r1.30.2.3 -r1.30.2.4
--- language/data-io/data-list.c 7 May 2007 05:16:08 -0000 1.30.2.3
+++ language/data-io/data-list.c 31 May 2007 18:15:00 -0000 1.30.2.4
@@ -67,7 +67,7 @@
/* All parsers. */
struct fmt_spec input; /* Input format of this field. */
int fv; /* First value in case. */
- char name[LONG_NAME_LEN + 1]; /* Var name for error messages and tables. */
+ char name[VAR_NAME_LEN + 1]; /* Var name for error messages and tables. */
/* Fixed format only. */
int record; /* Record number (1-based). */
Index: data/vector.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/vector.h,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -b -r1.2 -r1.2.2.1
--- data/vector.h 15 Dec 2006 00:16:02 -0000 1.2
+++ data/vector.h 31 May 2007 18:15:00 -0000 1.2.2.1
@@ -32,7 +32,7 @@
void vector_destroy (struct vector *);
const char *vector_get_name (const struct vector *);
-enum var_type vector_get_type (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 *);
Index: data/vector.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/vector.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -b -r1.2 -r1.2.2.1
--- data/vector.c 15 Dec 2006 00:16:02 -0000 1.2
+++ data/vector.c 31 May 2007 18:15:00 -0000 1.2.2.1
@@ -29,7 +29,7 @@
/* Vector of variables. */
struct vector
{
- char name[LONG_NAME_LEN + 1]; /* Name. */
+ char name[VAR_NAME_LEN + 1]; /* Name. */
struct variable **vars; /* Set of variables. */
size_t var_cnt; /* Number of variables. */
};
@@ -110,7 +110,7 @@
}
/* Returns the type of the variables in VECTOR. */
-enum var_type vector_get_type (const struct vector *vector)
+enum val_type vector_get_type (const struct vector *vector)
{
return var_get_type (vector->vars[0]);
}
Index: data/variable.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/variable.h,v
retrieving revision 1.20
retrieving revision 1.20.2.1
diff -u -b -r1.20 -r1.20.2.1
--- data/variable.h 26 Jan 2007 07:35:03 -0000 1.20
+++ data/variable.h 31 May 2007 18:15:00 -0000 1.20.2.1
@@ -1,5 +1,5 @@
/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007 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
@@ -16,35 +16,26 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-#if !variable_h
-#define variable_h 1
+#ifndef DATA_VARIABLE_H
+#define DATA_VARIABLE_H 1
#include <stddef.h>
#include <stdbool.h>
#include <data/missing-values.h>
+#include <data/val-type.h>
union value;
-/* Variable type. */
-enum var_type
- {
- VAR_NUMERIC, /* A numeric variable. */
- VAR_STRING /* A string variable. */
- };
-
-bool var_type_is_valid (enum var_type);
-enum var_type var_type_from_width (int width);
-
-/* Variables. */
+/* Variables.
+ These functions should rarely be called directly: use
+ dict_create_var, dict_clone_var, or dict_delete_var
+ instead. */
struct variable *var_create (const char *name, int width);
struct variable *var_clone (const struct variable *);
void var_destroy (struct variable *);
-/* Variable names.
- Long variable names can be used in most contexts, but a few
- procedures and file formats are limited to short names. */
-#define SHORT_NAME_LEN 8
-#define LONG_NAME_LEN 64
+/* Variable names. */
+#define VAR_NAME_LEN 64 /* Maximum length of variable name, in bytes. */
const char *var_get_name (const struct variable *);
void var_set_name (struct variable *, const char *);
@@ -57,17 +48,16 @@
int compare_var_ptrs_by_name (const void *, const void *, const void *);
unsigned hash_var_ptr_by_name (const void *, const void *);
-/* Variable types and widths. */
-enum var_type var_get_type (const struct variable *);
+/* Types and widths of values associated with a variable. */
+enum val_type var_get_type (const struct variable *);
int var_get_width (const struct variable *);
void var_set_width (struct variable *, int width);
-typedef bool var_predicate_func (const struct variable *);
-
bool var_is_numeric (const struct variable *);
bool var_is_alpha (const struct variable *);
bool var_is_short_string (const struct variable *);
bool var_is_long_string (const struct variable *);
+
size_t var_get_value_cnt (const struct variable *);
/* Variables' missing values. */
@@ -144,7 +134,10 @@
void var_set_leave (struct variable *, bool leave);
bool var_must_leave (const struct variable *);
-/* Short names. */
+/* Variable short names.
+ For historical reasons, some file formats are limited to short
+ names. */
+#define SHORT_NAME_LEN 8 /* Maximum length of short name. */
const char *var_get_short_name (const struct variable *);
void var_set_short_name (struct variable *, const char *);
void var_clear_short_name (struct variable *);
@@ -177,4 +170,7 @@
enum dict_class dict_class_from_id (const char *name);
const char *dict_class_to_name (enum dict_class dict_class);
-#endif /* !variable.h */
+/* Function types. */
+typedef bool var_predicate_func (const struct variable *);
+
+#endif /* data/variable.h */
Index: data/variable.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/variable.c,v
retrieving revision 1.21.2.1
retrieving revision 1.21.2.2
diff -u -b -r1.21.2.1 -r1.21.2.2
--- data/variable.c 19 Mar 2007 21:36:24 -0000 1.21.2.1
+++ data/variable.c 31 May 2007 18:15:01 -0000 1.21.2.2
@@ -44,7 +44,7 @@
struct variable
{
/* Dictionary information. */
- char name[LONG_NAME_LEN + 1]; /* Variable name. Mixed case. */
+ char name[VAR_NAME_LEN + 1]; /* Variable name. Mixed case. */
int width; /* 0 for numeric, otherwise string width. */
struct missing_values miss; /* Missing values. */
struct fmt_spec print; /* Default format for PRINT. */
@@ -79,20 +79,6 @@
struct cat_vals *obs_vals;
};
-/* Returns true if VAR_TYPE is a valid variable type. */
-bool
-var_type_is_valid (enum var_type var_type)
-{
- return var_type == VAR_NUMERIC || var_type == VAR_STRING;
-}
-
-/* Returns the variable type for the given width. */
-enum var_type
-var_type_from_width (int width)
-{
- return width != 0 ? VAR_STRING : VAR_NUMERIC;
-}
-
/* Creates and returns a new variable with the given NAME and
WIDTH and other fields initialized to default values. The
variable is not added to a dictionary; for that, use
@@ -114,16 +100,15 @@
{
v->print = fmt_for_output (FMT_F, 8, 2);
v->alignment = ALIGN_RIGHT;
- v->display_width = 8;
v->measure = MEASURE_SCALE;
}
else
{
v->print = fmt_for_output (FMT_A, var_get_width (v), 0);
v->alignment = ALIGN_LEFT;
- v->display_width = 8;
v->measure = MEASURE_NOMINAL;
}
+ v->display_width = 8;
v->write = v->print;
v->val_labs = NULL;
v->label = NULL;
@@ -271,11 +256,11 @@
msg (SE, _("Variable name cannot be empty string."));
return false;
}
- else if (length > LONG_NAME_LEN)
+ else if (length > VAR_NAME_LEN)
{
if (issue_error)
msg (SE, _("Variable name %s exceeds %d-character limit."),
- name, (int) LONG_NAME_LEN);
+ name, (int) VAR_NAME_LEN);
return false;
}
@@ -333,10 +318,10 @@
}
/* Returns the type of variable V. */
-enum var_type
+enum val_type
var_get_type (const struct variable *v)
{
- return var_type_from_width (v->width);
+ return val_type_from_width (v->width);
}
/* Returns the width of variable V. */
@@ -346,11 +331,12 @@
return v->width;
}
-/* Sets the width of V to WIDTH. */
+/* Changes the width of V to NEW_WIDTH.
+ This function should be used cautiously. */
void
var_set_width (struct variable *v, int new_width)
{
- enum var_type new_type = var_type_from_width (new_width);
+ enum val_type new_type = val_type_from_width (new_width);
if (mv_is_resizable (&v->miss, new_width))
mv_resize (&v->miss, new_width);
@@ -370,12 +356,12 @@
if (var_get_type (v) != new_type)
{
- v->print = (new_type == VAR_NUMERIC
+ v->print = (new_type == VAL_NUMERIC
? fmt_for_output (FMT_F, 8, 2)
: fmt_for_output (FMT_A, new_width, 0));
v->write = v->print;
}
- else if (new_type == VAR_STRING)
+ else if (new_type == VAL_STRING)
{
v->print.w = v->print.type == FMT_AHEX ? new_width * 2 : new_width;
v->write.w = v->write.type == FMT_AHEX ? new_width * 2 : new_width;
@@ -390,7 +376,7 @@
bool
var_is_numeric (const struct variable *v)
{
- return var_get_type (v) == VAR_NUMERIC;
+ return var_get_type (v) == VAL_NUMERIC;
}
/* Returns true if variable V is a string variable, false
@@ -398,7 +384,7 @@
bool
var_is_alpha (const struct variable *v)
{
- return var_get_type (v) == VAR_STRING;
+ return var_get_type (v) == VAL_STRING;
}
/* Returns true if variable V is a short string variable, false
Index: data/value.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/value.h,v
retrieving revision 1.7.2.2
retrieving revision 1.7.2.3
diff -u -b -r1.7.2.2 -r1.7.2.3
--- data/value.h 22 Apr 2007 20:28:50 -0000 1.7.2.2
+++ data/value.h 31 May 2007 18:15:01 -0000 1.7.2.3
@@ -16,35 +16,17 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-#if !value_h
-#define value_h 1
+#ifndef DATA_VALUE_H
+#define DATA_VALUE_H 1
-#include <float.h>
-#include <libpspp/misc.h>
+#include <data/val-type.h>
#include "minmax.h"
-#include <config.h>
-
-/* Values. */
/* "Short" strings, which are generally those no more than 8
characters wide, can participate in more operations than
longer strings. */
#define MAX_SHORT_STRING (MAX (ROUND_UP (SIZEOF_DOUBLE, 2), 8))
#define MIN_LONG_STRING (MAX_SHORT_STRING + 1)
-#define MAX_STRING 32767
-
-/* Special values. */
-#define SYSMIS (-DBL_MAX)
-#define LOWEST second_lowest_value
-#define HIGHEST DBL_MAX
-
-/* Number of "union value"s required for a variable of the given
- WIDTH. */
-static inline size_t
-value_cnt_from_width (int width)
-{
- return width == 0 ? 1 : DIV_RND_UP (width, MAX_SHORT_STRING);
-}
/* A numeric or short string value.
Multiple consecutive values represent a long string. */
@@ -58,7 +40,16 @@
int compare_values (const union value *, const union value *, int width);
unsigned hash_value (const union value *, int width);
+static inline size_t value_cnt_from_width (int width);
void value_copy (union value *, const union value *, int width);
void value_set_missing (union value *, int width);
-#endif /* !value.h */
+/* Number of "union value"s required for a variable of the given
+ WIDTH. */
+static inline size_t
+value_cnt_from_width (int width)
+{
+ return width == 0 ? 1 : DIV_RND_UP (width, MAX_SHORT_STRING);
+}
+
+#endif /* data/value.h */
Index: data/value-labels.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/value-labels.c,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -u -b -r1.15 -r1.15.2.1
--- data/value-labels.c 16 Dec 2006 03:40:41 -0000 1.15
+++ data/value-labels.c 31 May 2007 18:15:01 -0000 1.15.2.1
@@ -90,7 +90,7 @@
bool
val_labs_can_set_width (const struct val_labs *vls, int new_width)
{
- if ( var_type_from_width (new_width) != var_type_from_width (vls->width ))
+ if ( val_type_from_width (new_width) != val_type_from_width (vls->width ))
return false;
if (vls->width == 0)
Index: data/missing-values.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/missing-values.c,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -b -r1.9 -r1.9.2.1
--- data/missing-values.c 23 Dec 2006 06:11:33 -0000 1.9
+++ data/missing-values.c 31 May 2007 18:15:01 -0000 1.9.2.1
@@ -316,7 +316,7 @@
bool
mv_is_resizable (const struct missing_values *mv, int width)
{
- if ( var_type_from_width (width) != var_type_from_width (mv->width) )
+ if ( val_type_from_width (width) != val_type_from_width (mv->width) )
return false;
if (width > MAX_SHORT_STRING && mv->type != MVT_NONE)
Index: data/format.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/format.h,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -u -b -r1.13 -r1.13.2.1
--- data/format.h 15 Dec 2006 00:16:02 -0000 1.13
+++ data/format.h 31 May 2007 18:15:01 -0000 1.13.2.1
@@ -82,7 +82,7 @@
bool fmt_check (const struct fmt_spec *, bool for_input);
bool fmt_check_input (const struct fmt_spec *);
bool fmt_check_output (const struct fmt_spec *);
-bool fmt_check_type_compat (const struct fmt_spec *, enum var_type);
+bool fmt_check_type_compat (const struct fmt_spec *, enum val_type);
bool fmt_check_width_compat (const struct fmt_spec *, int var_width);
/* Working with formats. */
Index: data/format.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/format.c,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -b -r1.19 -r1.19.2.1
--- data/format.c 15 Dec 2006 00:16:02 -0000 1.19
+++ data/format.c 31 May 2007 18:15:01 -0000 1.19.2.1
@@ -297,18 +297,18 @@
}
/* Checks that FORMAT is appropriate for a variable of the given
- TYPE and returns true if so. Otherwise returns false and
+ VAR_TYPE and returns true if so. Otherwise returns false and
emits an error message. */
bool
-fmt_check_type_compat (const struct fmt_spec *format, enum var_type var_type)
+fmt_check_type_compat (const struct fmt_spec *format, enum val_type var_type)
{
- assert (var_type_is_valid (var_type));
- if ((var_type == VAR_STRING) != (fmt_is_string (format->type) != 0))
+ assert (val_type_is_valid (var_type));
+ if ((var_type == VAL_STRING) != (fmt_is_string (format->type) != 0))
{
char str[FMT_STRING_LEN_MAX + 1];
msg (SE, _("%s variables are not compatible with %s format %s."),
- var_type == VAR_STRING ? _("String") : _("Numeric"),
- var_type == VAR_STRING ? _("numeric") : _("string"),
+ var_type == VAL_STRING ? _("String") : _("Numeric"),
+ var_type == VAL_STRING ? _("numeric") : _("string"),
fmt_to_string (format, str));
return false;
}
@@ -321,7 +321,7 @@
bool
fmt_check_width_compat (const struct fmt_spec *format, int width)
{
- if (!fmt_check_type_compat (format, var_type_from_width (width)))
+ if (!fmt_check_type_compat (format, val_type_from_width (width)))
return false;
if (fmt_var_width (format) != width)
{
Index: data/file-handle-def.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/file-handle-def.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -b -r1.8 -r1.8.2.1
--- data/file-handle-def.c 2 Feb 2007 00:57:32 -0000 1.8
+++ data/file-handle-def.c 31 May 2007 18:15:02 -0000 1.8.2.1
@@ -46,7 +46,7 @@
int open_cnt; /* 0=not open, otherwise # of openers. */
bool deleted; /* Destroy handle when open_cnt goes to 0? */
- char id[LONG_NAME_LEN + 1]; /* Identifier token; empty string if none. */
+ char id[VAR_NAME_LEN + 1]; /* Identifier token; empty string if none. */
char *name; /* User-friendly identifying name. */
const char *type; /* If open, type of file. */
char open_mode[3]; /* "[rw][se]". */
Index: data/val-type.h
===================================================================
RCS file: data/val-type.h
diff -N data/val-type.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ data/val-type.h 31 May 2007 18:15:01 -0000 1.1.2.1
@@ -0,0 +1,55 @@
+/* PSPP - computes sample statistics.
+ Copyright (C) 2007 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 the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#ifndef DATA_VAL_TYPE_H
+#define DATA_VAL_TYPE_H 1
+
+#include <float.h>
+#include <libpspp/misc.h>
+#include <stdbool.h>
+
+/* Special numeric values. */
+#define SYSMIS (-DBL_MAX) /* System-missing value. */
+#define LOWEST second_lowest_value /* Smallest nonmissing finite value. */
+#define HIGHEST DBL_MAX /* Largest finite value. */
+
+/* Maximum length of a string variable. */
+#define MAX_STRING 32767
+
+/* Value type. */
+enum val_type
+ {
+ VAL_NUMERIC, /* A numeric value. */
+ VAL_STRING /* A string value. */
+ };
+
+/* Returns true if VAL_TYPE is a valid value type. */
+static inline bool
+val_type_is_valid (enum val_type val_type)
+{
+ return val_type == VAL_NUMERIC || val_type == VAL_STRING;
+}
+
+/* Returns the value type for the given WIDTH. */
+static inline enum val_type
+val_type_from_width (int width)
+{
+ return width != 0 ? VAL_STRING : VAL_NUMERIC;
+}
+
+#endif /* data/val-type.h */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/src ui/gui/var-type-dialog.c language/xfor... [simpler-proc],
Ben Pfaff <=