#include <stddef.h>
#include "data/format.h"
+#include "libpspp/compiler.h"
#include "libpspp/float-format.h"
#include "libpspp/integer-format.h"
#include "libpspp/message.h"
/* Whether to show variable or value labels or the underlying value or variable
name. */
-enum settings_value_show
+enum ATTRIBUTE ((packed)) settings_value_show
{
/* Use higher-level default.
In a pivot_value, the default is taken from the pivot_table.
.underline = underline,
};
const struct pivot_value value = {
- .type = PIVOT_VALUE_TEXT,
.text = {
+ .type = PIVOT_VALUE_TEXT,
.local = CONST_CAST (char *, s),
.c = CONST_CAST (char *, s),
.id = CONST_CAST (char *, s),
{
struct pivot_value *value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
- .type = PIVOT_VALUE_TEXT,
.text = {
+ .type = PIVOT_VALUE_TEXT,
.local = text,
.c = text,
.id = text,
struct pivot_value *value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
- .type = PIVOT_VALUE_TEXT,
.text = {
+ .type = PIVOT_VALUE_TEXT,
.local = local,
.c = c,
.id = c,
struct pivot_value *value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
- .type = PIVOT_VALUE_TEXT,
.text = {
+ .type = PIVOT_VALUE_TEXT,
.local = local,
.c = c,
.id = xstrdup (c),
{
struct pivot_value *value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
- .type = PIVOT_VALUE_NUMERIC,
- .numeric = { .x = x, },
+ .numeric = {
+ .type = PIVOT_VALUE_NUMERIC,
+ .x = x
+ },
};
return value;
}
{
struct pivot_value *value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
- .type = PIVOT_VALUE_VARIABLE,
.variable = {
+ .type = PIVOT_VALUE_VARIABLE,
.var_name = xstrdup (var_get_name (variable)),
.var_label = xstrdup_if_nonempty (var_get_label (variable)),
},
\f
/* pivot_value. */
-enum pivot_value_type
+enum ATTRIBUTE ((packed)) pivot_value_type
{
PIVOT_VALUE_NUMERIC, /* A value of a numeric variable. */
PIVOT_VALUE_STRING, /* A value of a string variable. */
size_t *footnote_indexes;
size_t n_footnotes;
- enum pivot_value_type type;
union
{
+ enum pivot_value_type type;
+
/* PIVOT_VALUE_NUMERIC. */
struct
{
- double x; /* The numeric value. */
+ enum pivot_value_type type;
+ enum settings_value_show show; /* Show value or label or both? */
struct fmt_spec format; /* Format to display 'x'. */
+ bool honor_small; /* Honor value of pivot table 'small'? */
+ double x; /* The numeric value. */
char *var_name; /* May be NULL. */
char *value_label; /* May be NULL. */
- enum settings_value_show show; /* Show value or label or both? */
- bool honor_small; /* Honor value of pivot table 'small'? */
}
numeric;
/* PIVOT_VALUE_STRING. */
struct
{
- char *s; /* The string value. */
+ enum pivot_value_type type;
+ enum settings_value_show show; /* Show value or label or both? */
bool hex; /* Display in hex? */
+ char *s; /* The string value. */
char *var_name; /* May be NULL. */
char *value_label; /* May be NULL. */
- enum settings_value_show show; /* Show value or label or both? */
}
string;
/* PIVOT_VALUE_VARIABLE. */
struct
{
+ enum pivot_value_type type;
+ enum settings_value_show show; /* Show name or label or both? */
char *var_name;
char *var_label; /* May be NULL. */
- enum settings_value_show show; /* Show name or label or both? */
}
variable;
/* PIVOT_VALUE_TEXT. */
struct
{
+ enum pivot_value_type type;
+
/* 'local', 'c', and 'id' must all be nonnull, but they are allowed
to be the same pointer. */
+ bool user_provided;
char *local; /* Localized. */
char *c; /* English. */
char *id; /* Identifier. */
- bool user_provided;
}
text;
/* PIVOT_VALUE_TEMPLATE. */
struct
{
+ enum pivot_value_type type;
+
+ /* Arguments.
+
+ The odd ordering in this struct reduces the overall size
+ of struct pivot_value. */
+ unsigned int n_args;
+ struct pivot_argument *args;
+
/* Both 'local' and 'id' must be nonnull, but they are allowed to
be the same pointer. */
char *local; /* Localized. */
char *id; /* Identifier. */
- struct pivot_argument *args;
- size_t n_args;
}
template;
};
struct pivot_value *value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
.font_style = font_style,
- .type = PIVOT_VALUE_TEXT,
.text = {
+ .type = PIVOT_VALUE_TEXT,
.local = text,
.c = text,
.id = text,
= t->styles[(opt & TAB_STYLE_MASK) >> TAB_STYLE_SHIFT];
static const struct pivot_value empty_value = {
- .type = PIVOT_VALUE_TEXT,
.text = {
+ .type = PIVOT_VALUE_TEXT,
.local = (char *) "",
.c = (char *) "",
.id = (char *) "",
{
value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
- .type = PIVOT_VALUE_STRING,
- .string = { .s = xstrdup (lex_tokcstr (lexer)) },
+ .string = {
+ .type = PIVOT_VALUE_STRING,
+ .s = xstrdup (lex_tokcstr (lexer))
+ },
};
lex_get (lexer);
}
{
value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
- .type = PIVOT_VALUE_VARIABLE,
- .variable = { .var_name = xstrdup (lex_tokcstr (lexer)) },
+ .variable = {
+ .type = PIVOT_VALUE_VARIABLE,
+ .var_name = xstrdup (lex_tokcstr (lexer))
+ },
};
lex_get (lexer);
}