[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch 18/19] fairly experimental changes based on what seemed to make s
From: |
blp |
Subject: |
[patch 18/19] fairly experimental changes based on what seemed to make sense |
Date: |
Tue, 05 Jun 2007 23:27:45 -0700 |
User-agent: |
quilt/0.45-1 |
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.
Index: merge/src/data/file-handle-def.c
===================================================================
--- merge.orig/src/data/file-handle-def.c 2007-06-05 18:01:02.000000000
-0700
+++ merge/src/data/file-handle-def.c 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/data/format.c
===================================================================
--- merge.orig/src/data/format.c 2007-06-05 18:01:02.000000000 -0700
+++ merge/src/data/format.c 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/data/format.h
===================================================================
--- merge.orig/src/data/format.h 2007-06-05 18:01:02.000000000 -0700
+++ merge/src/data/format.h 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/data/missing-values.c
===================================================================
--- merge.orig/src/data/missing-values.c 2007-06-05 18:01:02.000000000
-0700
+++ merge/src/data/missing-values.c 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/data/val-type.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ merge/src/data/val-type.h 2007-06-05 22:07:08.000000000 -0700
@@ -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 */
Index: merge/src/data/value-labels.c
===================================================================
--- merge.orig/src/data/value-labels.c 2007-06-05 18:01:02.000000000 -0700
+++ merge/src/data/value-labels.c 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/data/value.h
===================================================================
--- merge.orig/src/data/value.h 2007-06-05 21:46:58.000000000 -0700
+++ merge/src/data/value.h 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/data/variable.c
===================================================================
--- merge.orig/src/data/variable.c 2007-06-05 21:46:58.000000000 -0700
+++ merge/src/data/variable.c 2007-06-05 22:07:08.000000000 -0700
@@ -45,7 +45,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 @@
have its values stored here. */
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
@@ -115,16 +101,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;
@@ -272,11 +257,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;
}
@@ -334,10 +319,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. */
@@ -347,11 +332,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);
@@ -371,12 +357,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;
@@ -391,7 +377,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
@@ -399,7 +385,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: merge/src/data/variable.h
===================================================================
--- merge.orig/src/data/variable.h 2007-06-05 18:01:02.000000000 -0700
+++ merge/src/data/variable.h 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/data/vector.c
===================================================================
--- merge.orig/src/data/vector.c 2007-06-05 18:01:02.000000000 -0700
+++ merge/src/data/vector.c 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/data/vector.h
===================================================================
--- merge.orig/src/data/vector.h 2007-06-05 18:01:02.000000000 -0700
+++ merge/src/data/vector.h 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/language/data-io/data-list.c
===================================================================
--- merge.orig/src/language/data-io/data-list.c 2007-06-05 21:59:39.000000000
-0700
+++ merge/src/language/data-io/data-list.c 2007-06-05 22:07:08.000000000
-0700
@@ -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: merge/src/language/data-io/file-handle.q
===================================================================
--- merge.orig/src/language/data-io/file-handle.q 2007-06-05
18:01:02.000000000 -0700
+++ merge/src/language/data-io/file-handle.q 2007-06-05 22:07:08.000000000
-0700
@@ -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: merge/src/language/data-io/get.c
===================================================================
--- merge.orig/src/language/data-io/get.c 2007-06-05 22:02:53.000000000
-0700
+++ merge/src/language/data-io/get.c 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/language/data-io/list.q
===================================================================
--- merge.orig/src/language/data-io/list.q 2007-06-05 21:59:39.000000000
-0700
+++ merge/src/language/data-io/list.q 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/language/dictionary/formats.c
===================================================================
--- merge.orig/src/language/dictionary/formats.c 2007-06-05
18:01:02.000000000 -0700
+++ merge/src/language/dictionary/formats.c 2007-06-05 22:07:08.000000000
-0700
@@ -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: merge/src/language/dictionary/modify-variables.c
===================================================================
--- merge.orig/src/language/dictionary/modify-variables.c 2007-06-05
21:59:39.000000000 -0700
+++ merge/src/language/dictionary/modify-variables.c 2007-06-05
22:07:08.000000000 -0700
@@ -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: merge/src/language/dictionary/vector.c
===================================================================
--- merge.orig/src/language/dictionary/vector.c 2007-06-05 18:01:02.000000000
-0700
+++ merge/src/language/dictionary/vector.c 2007-06-05 22:07:08.000000000
-0700
@@ -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: merge/src/language/expressions/evaluate.c
===================================================================
--- merge.orig/src/language/expressions/evaluate.c 2007-06-05
21:59:39.000000000 -0700
+++ merge/src/language/expressions/evaluate.c 2007-06-05 22:07:08.000000000
-0700
@@ -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: merge/src/language/expressions/parse.c
===================================================================
--- merge.orig/src/language/expressions/parse.c 2007-06-05 18:01:02.000000000
-0700
+++ merge/src/language/expressions/parse.c 2007-06-05 22:07:08.000000000
-0700
@@ -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: merge/src/language/lexer/lexer.c
===================================================================
--- merge.orig/src/language/lexer/lexer.c 2007-06-05 18:01:02.000000000
-0700
+++ merge/src/language/lexer/lexer.c 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/language/lexer/variable-parser.c
===================================================================
--- merge.orig/src/language/lexer/variable-parser.c 2007-06-05
21:59:39.000000000 -0700
+++ merge/src/language/lexer/variable-parser.c 2007-06-05 22:07:08.000000000
-0700
@@ -406,8 +406,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);
@@ -475,7 +475,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++;
@@ -665,7 +665,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: merge/src/language/stats/aggregate.c
===================================================================
--- merge.orig/src/language/stats/aggregate.c 2007-06-05 21:59:39.000000000
-0700
+++ merge/src/language/stats/aggregate.c 2007-06-05 22:14:00.000000000
-0700
@@ -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: merge/src/language/stats/descriptives.c
===================================================================
--- merge.orig/src/language/stats/descriptives.c 2007-06-05
21:59:39.000000000 -0700
+++ merge/src/language/stats/descriptives.c 2007-06-05 22:07:08.000000000
-0700
@@ -125,7 +125,7 @@
struct dsc_var
{
const 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: merge/src/language/stats/frequencies.q
===================================================================
--- merge.orig/src/language/stats/frequencies.q 2007-06-05 21:59:39.000000000
-0700
+++ merge/src/language/stats/frequencies.q 2007-06-05 22:07:08.000000000
-0700
@@ -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: merge/src/language/stats/regression.q
===================================================================
--- merge.orig/src/language/stats/regression.q 2007-06-05 21:59:39.000000000
-0700
+++ merge/src/language/stats/regression.q 2007-06-05 22:07:08.000000000
-0700
@@ -641,16 +641,16 @@
}
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);
}
}
@@ -660,7 +660,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: merge/src/language/stats/t-test.q
===================================================================
--- merge.orig/src/language/stats/t-test.q 2007-06-05 21:59:39.000000000
-0700
+++ merge/src/language/stats/t-test.q 2007-06-05 22:07:08.000000000 -0700
@@ -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;
@@ -569,9 +569,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: merge/src/language/xforms/compute.c
===================================================================
--- merge.orig/src/language/xforms/compute.c 2007-06-05 18:01:02.000000000
-0700
+++ merge/src/language/xforms/compute.c 2007-06-05 22:07:08.000000000 -0700
@@ -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: merge/src/language/xforms/recode.c
===================================================================
--- merge.orig/src/language/xforms/recode.c 2007-06-05 18:01:02.000000000
-0700
+++ merge/src/language/xforms/recode.c 2007-06-05 22:07:08.000000000 -0700
@@ -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. */
const 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. "
@@ -262,9 +262,9 @@
add_mapping (trns, &map_allocated, &in);
set_map_out_num (&trns->mappings[trns->map_cnt - 1].out, 0.0);
- 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."));
@@ -289,11 +289,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);
@@ -452,7 +452,7 @@
{
const 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 "
@@ -471,8 +471,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;
}
}
@@ -484,7 +484,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;
@@ -642,12 +642,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: merge/src/ui/gui/var-type-dialog.c
===================================================================
--- merge.orig/src/ui/gui/var-type-dialog.c 2007-06-05 18:01:02.000000000
-0700
+++ merge/src/ui/gui/var-type-dialog.c 2007-06-05 22:07:08.000000000 -0700
@@ -792,14 +792,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: merge/src/math/interaction.c
===================================================================
--- merge.orig/src/math/interaction.c 2007-06-05 22:07:30.000000000 -0700
+++ merge/src/math/interaction.c 2007-06-05 22:07:53.000000000 -0700
@@ -29,6 +29,7 @@
N_1, N_2, ..., N_K categories, then the interaction will have
N_1 * N_2 * N_3 *...* N_K - 1 entries.
*/
+#include <config.h>
#include <assert.h>
#include <libpspp/alloc.h>
#include <gsl/gsl_math.h>
Index: merge/src/ui/gui/compute-dialog.c
===================================================================
--- merge.orig/src/ui/gui/compute-dialog.c 2007-06-05 22:09:46.000000000
-0700
+++ merge/src/ui/gui/compute-dialog.c 2007-06-05 22:10:03.000000000 -0700
@@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-
+#include <config.h>
#include <gtk/gtk.h>
#include "compute-dialog.h"
#include "helper.h"
--
- [patch 05/19] sparse array of cases, (continued)
- [patch 05/19] sparse array of cases, blp, 2007/06/06
- [patch 12/19] make aux_data static in libpspp tests, blp, 2007/06/06
- [patch 19/19] i18n changes to Smake, configure.ac, blp, 2007/06/06
- [patch 08/19] case_ordering implementation, blp, 2007/06/06
- [patch 11/19] fix assertion in binary_search, blp, 2007/06/06
- [patch 18/19] fairly experimental changes based on what seemed to make sense,
blp <=
- [patch 10/19] new function value_cnt_from_width, blp, 2007/06/06
- [patch 02/19] new function get_workspace_cases, blp, 2007/06/06
- [patch 06/19] sliding window of cases, blp, 2007/06/06
- [patch 04/19] temporary file for array of cases, blp, 2007/06/06
- [patch 09/19] casegrouper implementation, blp, 2007/06/06