From: Ben Pfaff Date: Mon, 23 Apr 2007 01:30:22 +0000 (+0000) Subject: Patch #5886. X-Git-Tag: v0.6.0~482 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5f633cb2139ad17ce66cb4433b3a96276ccb1a9;p=pspp-builds.git Patch #5886. (value_copy): New function. (value_set_missing): Ditto. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 73aba2ff..73177f5b 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,8 @@ +2007-04-22 Ben Pfaff + + * value.c (value_copy): New function. + (value_set_missing): Ditto. + 2007-04-22 John Darrington * Deleted existing category.h and moved cat-routines.h into diff --git a/src/data/value.c b/src/data/value.c index 20d2a33e..5e94b68c 100644 --- a/src/data/value.c +++ b/src/data/value.c @@ -53,3 +53,25 @@ hash_value (const union value *v, int width) ? hsh_hash_double (v->f) : hsh_hash_bytes (v->s, MIN (MAX_SHORT_STRING, width))); } + +/* Copies SRC to DST, given that they both contain data of the + given WIDTH. */ +void +value_copy (union value *dst, const union value *src, int width) +{ + if (width == 0) + dst->f = src->f; + else + memcpy (dst->s, src->s, width); +} + +/* Sets V to the system-missing value for data of the given + WIDTH. */ +void +value_set_missing (union value *v, int width) +{ + if (width == 0) + v->f = SYSMIS; + else + memset (v->s, ' ', width); +} diff --git a/src/data/value.h b/src/data/value.h index 97d07b46..e3e3f0de 100644 --- a/src/data/value.h +++ b/src/data/value.h @@ -50,4 +50,7 @@ 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); +void value_copy (union value *, const union value *, int width); +void value_set_missing (union value *, int width); + #endif /* !value.h */