Fix clipboard export of non-ascii strings.
[pspp-builds.git] / src / libpspp / float-format.c
index 79ba94469fc9fa085f2318d5f48d596f9c6b752f..0450dbeacc1d2573f35230b611a93db12b6ea7bd 100644 (file)
 #include <ctype.h>
 #include <inttypes.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <libpspp/assertion.h>
 #include <libpspp/integer-format.h>
-#include <libpspp/str.h>
 
 #include "error.h"
 #include <byteswap.h>
@@ -187,6 +187,24 @@ float_identify (double expected_value, const void *number, size_t length,
       }
   return match_cnt;
 }
+
+/* Returns the double value that is just greater than -DBL_MAX,
+   which in PSPP syntax files is called LOWEST and used as the
+   low end of numeric ranges that are supposed to be unbounded on
+   the low end, as in the missing value set created by,
+   e.g. MISSING VALUES X(LOWEST THRU 5).  (-DBL_MAX is used for
+   SYSMIS so it is not available for LOWEST.) */
+double
+float_get_lowest (void)
+{
+  struct fp fp;
+  double x;
+
+  fp.class = LOWEST;
+  fp.sign = POSITIVE;
+  assemble_number (FLOAT_NATIVE_DOUBLE, &fp, &x);
+  return x;
+}
 \f
 /* Returns CNT bits in X starting from the given bit OFS. */
 static inline uint64_t
@@ -677,7 +695,7 @@ assemble_number (enum float_format type, struct fp *fp, void *number)
       break;
 
     case FLOAT_Z_SHORT:
-      put_uint64 (native_to_be32 (assemble_z (fp, 7, 24)), number);
+      put_uint32 (native_to_be32 (assemble_z (fp, 7, 24)), number);
       break;
     case FLOAT_Z_LONG:
       put_uint64 (native_to_be64 (assemble_z (fp, 7, 56)), number);