message: Intern file names in msg_location to make them cheaper to copy.
[pspp] / src / language / data-io / data-parser.c
index 6de88b170de8400fdd37215dedc4d736bcc17754..09af7542bb5750510f402b6ce3ee90bb6e833c01 100644 (file)
@@ -29,6 +29,7 @@
 #include "data/file-handle-def.h"
 #include "data/settings.h"
 #include "language/data-io/data-reader.h"
+#include "libpspp/intern.h"
 #include "libpspp/message.h"
 #include "libpspp/str.h"
 #include "output/pivot-table.h"
@@ -496,21 +497,23 @@ parse_error (const struct dfm_reader *reader, const struct field *field,
              int first_column, int last_column, char *error)
 {
   int line_number = dfm_get_line_number (reader);
-  const struct msg_location location = {
-    .file_name = CONST_CAST (char *, dfm_get_file_name (reader)),
+  struct msg_location *location = xmalloc (sizeof *location);
+  *location = (struct msg_location) {
+    .file_name = intern_new (dfm_get_file_name (reader)),
     .first_line = line_number,
     .last_line = line_number + 1,
     .first_column = first_column,
     .last_column = last_column,
   };
-  struct msg m = {
+  struct msg *m = xmalloc (sizeof *m);
+  *m = (struct msg) {
     .category = MSG_C_DATA,
     .severity = MSG_S_WARNING,
-    .location = CONST_CAST (struct msg_location *, &location),
+    .location = location,
     .text = xasprintf (_("Data for variable %s is not valid as format %s: %s"),
                        field->name, fmt_name (field->format.type), error),
   };
-  msg_emit (&m);
+  msg_emit (m);
 
   free (error);
 }