projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
First step in making struct variable opaque: the boring mechanical
[pspp-builds.git]
/
src
/
data
/
value-labels.c
diff --git
a/src/data/value-labels.c
b/src/data/value-labels.c
index 92a2db48ea87e82340dfec28fb3d3d2ab486d7a6..96d839ba361e90aba270c753d8fb0de13c608eed 100644
(file)
--- a/
src/data/value-labels.c
+++ b/
src/data/value-labels.c
@@
-23,6
+23,7
@@
#include <stdlib.h>
#include <stdlib.h>
+#include <data/data-out.h>
#include <data/variable.h>
#include <libpspp/alloc.h>
#include <libpspp/compiler.h>
#include <data/variable.h>
#include <libpspp/alloc.h>
#include <libpspp/compiler.h>
@@
-189,10
+190,10
@@
create_int_val_lab (struct val_labs *vls, union value value, const char *label)
}
/* If VLS does not already contain a value label for VALUE, adds
}
/* If VLS does not already contain a value label for VALUE, adds
- LABEL for it and returns
nonzero. Otherwise, returns zero
.
+ LABEL for it and returns
true. Otherwise, returns false
.
Behavior is undefined if VLS's width is greater than
MAX_SHORT_STRING. */
Behavior is undefined if VLS's width is greater than
MAX_SHORT_STRING. */
-int
+bool
val_labs_add (struct val_labs *vls, union value value, const char *label)
{
struct int_val_lab *ivl;
val_labs_add (struct val_labs *vls, union value value, const char *label)
{
struct int_val_lab *ivl;
@@
-211,20
+212,17
@@
val_labs_add (struct val_labs *vls, union value value, const char *label)
if (*vlpp == NULL)
{
*vlpp = ivl;
if (*vlpp == NULL)
{
*vlpp = ivl;
- return 1;
- }
- else
- {
- free_int_val_lab (ivl, vls);
- return 0;
+ return true;
}
}
+ free_int_val_lab (ivl, vls);
+ return false;
}
}
-/* Sets LABEL as the value label for VALUE in VLS. Returns
zero
- if there wasn't already a value label for VALUE, or
nonzero
if
+/* Sets LABEL as the value label for VALUE in VLS. Returns
false
+ if there wasn't already a value label for VALUE, or
true
if
there was. Behavior is undefined if VLS's width is greater
than MAX_SHORT_STRING. */
there was. Behavior is undefined if VLS's width is greater
than MAX_SHORT_STRING. */
-int
+bool
val_labs_replace (struct val_labs *vls, union value value, const char *label)
{
struct int_val_lab *ivl;
val_labs_replace (struct val_labs *vls, union value value, const char *label)
{
struct int_val_lab *ivl;
@@
-236,23
+234,23
@@
val_labs_replace (struct val_labs *vls, union value value, const char *label)
if (vls->labels == NULL)
{
val_labs_add (vls, value, label);
if (vls->labels == NULL)
{
val_labs_add (vls, value, label);
- return
0
;
+ return
false
;
}
ivl = hsh_replace (vls->labels, create_int_val_lab (vls, value, label));
if (ivl == NULL)
}
ivl = hsh_replace (vls->labels, create_int_val_lab (vls, value, label));
if (ivl == NULL)
- return
0
;
+ return
false
;
else
{
free_int_val_lab (ivl, vls);
else
{
free_int_val_lab (ivl, vls);
- return
1
;
+ return
true
;
}
}
}
}
-/* Removes any value label for VALUE within VLS. Returns
nonzero
+/* Removes any value label for VALUE within VLS. Returns
true
if a value label was removed. Behavior is undefined if VLS's
width is greater than MAX_SHORT_STRING. */
if a value label was removed. Behavior is undefined if VLS's
width is greater than MAX_SHORT_STRING. */
-int
+bool
val_labs_remove (struct val_labs *vls, union value value)
{
assert (vls != NULL);
val_labs_remove (struct val_labs *vls, union value value)
{
assert (vls != NULL);
@@
-266,7
+264,7
@@
val_labs_remove (struct val_labs *vls, union value value)
return deleted;
}
else
return deleted;
}
else
- return
0
;
+ return
false
;
}
/* Searches VLS for a value label for VALUE. If successful,
}
/* Searches VLS for a value label for VALUE. If successful,
@@
-398,7
+396,7
@@
val_labs_done (struct val_labs_iterator **ip)
\f
/* Compares two value labels and returns a strcmp()-type result. */
int
\f
/* Compares two value labels and returns a strcmp()-type result. */
int
-compare_int_val_lab (const void *a_, const void *b_, void *vls_)
+compare_int_val_lab (const void *a_, const void *b_,
const
void *vls_)
{
const struct int_val_lab *a = a_;
const struct int_val_lab *b = b_;
{
const struct int_val_lab *a = a_;
const struct int_val_lab *b = b_;
@@
-412,7
+410,7
@@
compare_int_val_lab (const void *a_, const void *b_, void *vls_)
/* Hash a value label. */
unsigned
/* Hash a value label. */
unsigned
-hash_int_val_lab (const void *vl_, void *vls_)
+hash_int_val_lab (const void *vl_,
const
void *vls_)
{
const struct int_val_lab *vl = vl_;
const struct val_labs *vls = vls_;
{
const struct int_val_lab *vl = vl_;
const struct val_labs *vls = vls_;
@@
-425,7
+423,7
@@
hash_int_val_lab (const void *vl_, void *vls_)
/* Free a value label. */
void
/* Free a value label. */
void
-free_int_val_lab (void *vl_, void *vls_ UNUSED)
+free_int_val_lab (void *vl_,
const
void *vls_ UNUSED)
{
struct int_val_lab *vl = vl_;
{
struct int_val_lab *vl = vl_;
@@
-503,7
+501,7
@@
atom_to_string (const struct atom *atom)
/* A hsh_compare_func that compares A and B. */
static int
/* A hsh_compare_func that compares A and B. */
static int
-compare_atoms (const void *a_, const void *b_, void *aux UNUSED)
+compare_atoms (const void *a_, const void *b_,
const
void *aux UNUSED)
{
const struct atom *a = a_;
const struct atom *b = b_;
{
const struct atom *a = a_;
const struct atom *b = b_;
@@
-513,7
+511,7
@@
compare_atoms (const void *a_, const void *b_, void *aux UNUSED)
/* A hsh_hash_func that hashes ATOM. */
static unsigned
/* A hsh_hash_func that hashes ATOM. */
static unsigned
-hash_atom (const void *atom_, void *aux UNUSED)
+hash_atom (const void *atom_,
const
void *aux UNUSED)
{
const struct atom *atom = atom_;
{
const struct atom *atom = atom_;
@@
-522,7
+520,7
@@
hash_atom (const void *atom_, void *aux UNUSED)
/* A hsh_free_func that destroys ATOM. */
static void
/* A hsh_free_func that destroys ATOM. */
static void
-free_atom (void *atom_, void *aux UNUSED)
+free_atom (void *atom_,
const
void *aux UNUSED)
{
struct atom *atom = atom_;
{
struct atom *atom = atom_;
@@
-548,8
+546,9
@@
value_to_string (const union value *val, const struct variable *var)
if (s == NULL)
{
static char buf[MAX_STRING + 1];
if (s == NULL)
{
static char buf[MAX_STRING + 1];
- data_out (buf, &var->print, val);
- buf[var->print.w] = '\0';
+ const struct fmt_spec *print = var_get_print_format (var);
+ data_out (val, print, buf);
+ buf[print->w] = '\0';
s = buf;
}
s = buf;
}