X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvar.h;h=a1059a20828a04c76d14184825a037643942e195;hb=bbe7ad1a7454599693c188fe1eaf8f5d6e154206;hp=63296b9f4b35c6554e3c244c12d9c934a05b2110;hpb=4a4c003e2b2c01274b305e907fc63ba33d8481ae;p=pspp diff --git a/src/var.h b/src/var.h index 63296b9f4b..a1059a2082 100644 --- a/src/var.h +++ b/src/var.h @@ -14,8 +14,8 @@ 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., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #if !var_h #define var_h 1 @@ -23,11 +23,10 @@ #include #include "config.h" -#include "bool.h" -#include "format.h" -#include "val.h" - +#include +#include "format.h" +#include "missing-values.h" /* Script variables. */ @@ -35,46 +34,26 @@ enum { NUMERIC, /* A numeric variable. */ - ALPHA /* A string variable. (STRING is pre-empted by lexer.h) */ - }; - -/* Types of missing values. Order is significant, see - mis-val.c:parse_numeric(), sfm-read.c, sfm-write.c, - sysfile-info.c:cmd_sysfile_info(), mis-val.c:copy_missing_values(), - pfm-read.c:read_variables(), pfm-write.c:write_variables(), - apply-dict.c:cmd_apply_dictionary(), and more (?). */ -enum - { - MISSING_NONE, /* No user-missing values. */ - MISSING_1, /* One user-missing value. */ - MISSING_2, /* Two user-missing values. */ - MISSING_3, /* Three user-missing values. */ - MISSING_RANGE, /* [a,b]. */ - MISSING_LOW, /* (-inf,a]. */ - MISSING_HIGH, /* (a,+inf]. */ - MISSING_RANGE_1, /* [a,b], c. */ - MISSING_LOW_1, /* (-inf,a], b. */ - MISSING_HIGH_1, /* (a,+inf), b. */ - MISSING_COUNT + ALPHA /* A string variable. + (STRING is pre-empted by lexer.h.) */ }; - /* A variable's dictionary entry. */ struct variable { - char name[SHORT_NAME_LEN + 1]; /* As a string. */ - char *longname; /* Pointer to entry in dictionary's table */ - int index; /* Index into its dictionary's var[]. */ + /* Basic information. */ + char name[LONG_NAME_LEN + 1]; /* Variable name. Mixed case. */ int type; /* NUMERIC or ALPHA. */ - int width; /* Size of string variables in chars. */ int fv, nv; /* Index into `value's, number of values. */ unsigned init : 1; /* 1=VFM must init and possibly reinit. */ unsigned reinit : 1; /* Cases are: 1=reinitialized; 0=left. */ + /* Data for use by containing dictionary. */ + int index; /* Dictionary index. */ + /* Missing values. */ - int miss_type; /* One of the MISSING_* constants. */ - union value missing[3]; /* User-missing value. */ + struct missing_values miss; /* Missing values. */ /* Display formats. */ struct fmt_spec print; /* Default format for PRINT. */ @@ -84,40 +63,38 @@ struct variable struct val_labs *val_labs; /* Value labels. */ char *label; /* Variable label. */ - - /* GUI display parameters */ + /* GUI display parameters. */ enum measure measure; /* Nominal ordinal or continuous */ int display_width; /* Width of data editor column */ enum alignment alignment; /* Alignment of data in gui */ + /* Short name, used only for system and portable file input + and output. Upper case only. There is no index for short + names. Short names are not necessarily unique. Any + variable may have no short name, indicated by an empty + string. */ + char short_name[SHORT_NAME_LEN + 1]; + /* Per-command info. */ void *aux; void (*aux_dtor) (struct variable *); }; - -/* A tuple containing short names and longnames */ -struct name_table_entry -{ - char *longname; - char *name; -}; - +/* Variable names. */ bool var_is_valid_name (const char *, bool issue_error); int compare_var_names (const void *, const void *, void *); unsigned hash_var_name (const void *, void *); -/* Destroy and free up an nte */ -void free_nte(struct name_table_entry *nte); - - -unsigned hash_long_name (const void *e_, void *aux UNUSED) ; -int compare_long_names(const void *a_, const void *b_, void *aux); - +/* Short names. */ +void var_set_short_name (struct variable *, const char *); +void var_set_short_name_suffix (struct variable *, const char *, int suffix); +void var_clear_short_name (struct variable *); +/* Pointers to `struct variable', by name. */ int compare_var_ptr_names (const void *, const void *, void *); unsigned hash_var_ptr_name (const void *, void *); +/* Variable auxiliary data. */ void *var_attach_aux (struct variable *, void *aux, void (*aux_dtor) (struct variable *)); void var_clear_aux (struct variable *); @@ -139,12 +116,11 @@ const char *dict_class_to_name (enum dict_class dict_class); struct vector { int idx; /* Index for dict_get_vector(). */ - char name[SHORT_NAME_LEN + 1]; /* Name. */ + char name[LONG_NAME_LEN + 1]; /* Name. */ struct variable **var; /* Vector of variables. */ int cnt; /* Number of variables. */ }; - void discard_variables (void); /* This is the active file dictionary. */ @@ -179,18 +155,8 @@ extern int FILTER_before_TEMPORARY; void cancel_temporary (void); -/* Functions. */ - struct ccase; void dump_split_vars (const struct ccase *); -typedef int (* is_missing_func )(const union value *, const struct variable *); - -int is_num_user_missing (double, const struct variable *); -int is_str_user_missing (const unsigned char[], const struct variable *); -int is_missing (const union value *, const struct variable *); -int is_system_missing (const union value *, const struct variable *); -int is_user_missing (const union value *, const struct variable *); -void copy_missing_values (struct variable *dest, const struct variable *src); /* Transformations. */ @@ -229,7 +195,8 @@ size_t var_set_get_cnt (const struct var_set *vs); struct variable *var_set_get_var (const struct var_set *vs, size_t idx); struct variable *var_set_lookup_var (const struct var_set *vs, const char *name); -int var_set_lookup_var_idx (const struct var_set *vs, const char *name); +bool var_set_lookup_var_idx (const struct var_set *vs, const char *name, + size_t *idx); void var_set_destroy (struct var_set *vs); /* Variable parsers. */ @@ -249,12 +216,12 @@ enum struct variable *parse_variable (void); struct variable *parse_dict_variable (const struct dictionary *); -int parse_variables (const struct dictionary *, struct variable ***, int *, +int parse_variables (const struct dictionary *, struct variable ***, size_t *, int opts); -int parse_var_set_vars (const struct var_set *, struct variable ***, int *, +int parse_var_set_vars (const struct var_set *, struct variable ***, size_t *, int opts); -int parse_DATA_LIST_vars (char ***names, int *cnt, int opts); -int parse_mixed_vars (char ***names, int *cnt, int opts); +int parse_DATA_LIST_vars (char ***names, size_t *cnt, int opts); +int parse_mixed_vars (char ***names, size_t *cnt, int opts);