Abstract the documents within a dictionary a little better. Thanks to
[pspp-builds.git] / src / language / data-io / get.c
index 425e8c512031b8645ad6f7d4d80043b7081a5e11..32b3764ea6f98829c6fe19585dea4e0ea6e52afe 100644 (file)
@@ -746,7 +746,7 @@ struct mtf_file
     struct mtf_file *next_min; /* Next in the chain of minimums. */
     
     int type;                  /* One of MTF_*. */
-    struct variable **by;      /* List of BY variables for this file. */
+    const struct variable **by;        /* List of BY variables for this file. */
     struct file_handle *handle; /* File handle. */
     struct any_reader *reader;  /* File reader. */
     struct dictionary *dict;   /* Dictionary from system file. */
@@ -943,7 +943,7 @@ cmd_match_files (struct lexer *lexer, struct dataset *ds)
     {
       if (lex_match (lexer, T_BY))
        {
-          struct variable **by;
+          const struct variable **by;
           
          if (mtf.by_cnt)
            {
@@ -952,7 +952,7 @@ cmd_match_files (struct lexer *lexer, struct dataset *ds)
            }
              
          lex_match (lexer, '=');
-         if (!parse_variables (lexer, mtf.dict, &by, &mtf.by_cnt,
+         if (!parse_variables_const (lexer, mtf.dict, &by, &mtf.by_cnt,
                                PV_NO_DUPLICATE | PV_NO_SCRATCH))
            goto error;
 
@@ -1455,13 +1455,7 @@ mtf_merge_dictionary (struct dictionary *const m, struct mtf_file *f)
         dict_set_documents (m, d_docs);
       else
         {
-          char *new_docs;
-          size_t new_len;
-
-          new_len = strlen (m_docs) + strlen (d_docs);
-          new_docs = xmalloc (new_len + 1);
-          strcpy (new_docs, m_docs);
-          strcat (new_docs, d_docs);
+          char *new_docs = xasprintf ("%s%s", m_docs, d_docs);
           dict_set_documents (m, new_docs);
           free (new_docs);
         }