Change license from GPLv2+ to GPLv3+.
[pspp-builds.git] / src / data / value.c
index 2de3adbae440e32e54e856984056718c5ec0cccb..e9411c8cefa976ff4a4c46d94db837e9eefffb23 100644 (file)
@@ -1,21 +1,18 @@
-/* PSPP - computes sample statistics.
+/* PSPP - a program for statistical analysis.
    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
-   Written by Ben Pfaff <blp@gnu.org>.
 
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
    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., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA. */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
 #include "value.h"
@@ -38,7 +35,7 @@ value_dup (const union value *val, int width)
    Only the short string portion of longer strings are
    compared. */
 int
-compare_values (const union value *a, const union value *b, int width) 
+compare_values (const union value *a, const union value *b, int width)
 {
   return (width == 0
           ? (a->f < b->f ? -1 : a->f > b->f)
@@ -47,10 +44,32 @@ compare_values (const union value *a, const union value *b, int width)
 
 /* Create a hash of V, which has the given WIDTH.
    Only the short string portion of a longer string is hashed. */
-unsigned 
+unsigned
 hash_value (const union value *v, int width)
 {
   return (width == 0
           ? 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);
+}