X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvalue.h;h=97d07b4632ed972e009b94a965ec9900e1eb9b14;hb=93b4335785430ab6de290b7978e2d506106a8ba5;hp=1c2a19cdb8977d3bbf911bd1d7289978a25bced8;hpb=dcf9b154cbcaa35c3d8459a201b77eec8bcb30bd;p=pspp-builds.git diff --git a/src/data/value.h b/src/data/value.h index 1c2a19cd..97d07b46 100644 --- a/src/data/value.h +++ b/src/data/value.h @@ -1,6 +1,5 @@ /* PSPP - computes sample statistics. Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. - Written by Ben Pfaff . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -21,58 +20,34 @@ #define value_h 1 #include - +#include +#include "minmax.h" #include /* Values. */ -/* Max length of a short string value, generally 8 chars. */ -#define MAX_SHORT_STRING ((SIZEOF_DOUBLE)>=8 ? ((SIZEOF_DOUBLE)+1)/2*2 : 8) -#define MIN_LONG_STRING (MAX_SHORT_STRING+1) - -/* Max string length. */ -#define MAX_STRING 255 - -/* FYI: It is a bad situation if sizeof(flt64) < MAX_SHORT_STRING: - then short string missing values can be truncated in system files - because there's only room for as many characters as can fit in a - flt64. */ -#if MAX_SHORT_STRING > SHORT_NAME_LEN -#error MAX_SHORT_STRING must be less than or equal to SHORT_NAME_LEN. -#endif +/* "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 -/* Describes one value, which is either a floating-point number or a - short string. */ +/* A numeric or short string value. + Multiple consecutive values represent a long string. */ union value { - /* A numeric value. */ double f; - - /* A short-string value. */ char s[MAX_SHORT_STRING]; - - /* Used by evaluate_expression() to return a string result. - As currently implemented, it's a pointer to a dynamic - buffer in the appropriate expression. - - Also used by the AGGREGATE procedure in handling string - values. */ - char *c; }; -/* Maximum number of `union value's in a single number or string - value. */ -#define MAX_ELEMS_PER_VALUE (MAX_STRING / sizeof (union value) + 1) - -int compare_values (const union value *a, const union value *b, int width); - -unsigned hash_value(const union value *v, int width); - - +union value *value_dup (const union value *, int width); +int compare_values (const union value *, const union value *, int width); +unsigned hash_value (const union value *, int width); #endif /* !value.h */