Implemented support for very long strings a la spss v13/v14
[pspp] / src / data / data-out.c
index 7dfcc7853908f2347f6ec6aa4b187957f773863f..b7ee5314d93c095993429de721d187b72d4f439e 100644 (file)
    02110-1301, USA. */
 
 #include <config.h>
-#include "message.h"
+#include <libpspp/message.h>
 #include <ctype.h>
 #include <math.h>
 #include <float.h>
 #include <stdlib.h>
 #include <time.h>
 #include "calendar.h"
-#include "message.h"
+#include <libpspp/message.h>
 #include "format.h"
-#include "magic.h"
-#include "misc.h"
-#include "misc.h"
+#include <libpspp/magic.h>
+#include <libpspp/misc.h>
+#include <libpspp/misc.h>
 #include "settings.h"
-#include "str.h"
+#include <libpspp/str.h>
 #include "variable.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
-
-#include "debug-print.h"
 \f
 /* Public functions. */
 
@@ -397,7 +395,7 @@ convert_Z (char *dst, const struct fmt_spec *fp, double number)
 static int
 convert_A (char *dst, const struct fmt_spec *fp, const char *string)
 {
-  memcpy (dst, string, fp->w);
+  copy_demangle(dst, fp->w, string, fp->w);
   return 1;
 }
 
@@ -1065,6 +1063,7 @@ try_F (char *dst, const struct fmt_spec *fp, double number)
                  avoids wasting too much time formatting more
                  decimal places on the first try. */
               int result = format_and_round (dst, number, fp, fp->d + 2);
+
               if (result >= 0)
                 return result;
 
@@ -1145,7 +1144,7 @@ format_and_round (char *dst, double number, const struct fmt_spec *fp,
          digits of the fraction.
          Right-justify the integer part and sign. */
       dst[0] = ' ';
-      memcpy (dst + 1, buf, fp->w);
+      memcpy (dst + 1, buf, fp->w - 1);
       return 1;
     }