Fix buffer overflow reported by John Darrington.
[pspp] / src / language / dictionary / rename-variables.c
index 1c20c6a643519f12a9e684de1185a07c94969f9c..0e0df1eca4e197406464de6f061ce587204fa924 100644 (file)
    02110-1301, USA. */
 
 #include <config.h>
+
 #include <stdlib.h>
-#include "message.h"
-#include "alloc.h"
-#include "command.h"
-#include "dictionary.h"
-#include "message.h"
-#include "hash.h"
-#include "lexer.h"
-#include "str.h"
-#include "variable.h"
+
+#include <data/dictionary.h>
+#include <data/procedure.h>
+#include <data/variable.h>
+#include <language/command.h>
+#include <language/lexer/lexer.h>
+#include <language/lexer/variable-parser.h>
+#include <libpspp/alloc.h>
+#include <libpspp/hash.h>
+#include <libpspp/message.h>
+#include <libpspp/str.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -35,7 +38,7 @@
 /* The code for this function is very similar to the code for the
    RENAME subcommand of MODIFY VARS. */
 int
-cmd_rename_variables (void)
+cmd_rename_variables (struct dataset *ds)
 {
   struct variable **rename_vars = NULL;
   char **rename_new_names = NULL;
@@ -44,12 +47,9 @@ cmd_rename_variables (void)
 
   int status = CMD_CASCADING_FAILURE;
 
-  if (temporary != 0)
-    {
-      msg (SE, _("RENAME VARS may not be used after TEMPORARY.  "
-                 "Temporary transformations will be made permanent."));
-      cancel_temporary (); 
-    }
+  if (proc_make_temporary_transformations_permanent (ds))
+    msg (SE, _("RENAME VARS may not be used after TEMPORARY.  "
+               "Temporary transformations will be made permanent."));
 
   do
     {
@@ -61,7 +61,7 @@ cmd_rename_variables (void)
          msg (SE, _("`(' expected."));
          goto lossage;
        }
-      if (!parse_variables (default_dict, &rename_vars, &rename_cnt,
+      if (!parse_variables (dataset_dict (ds), &rename_vars, &rename_cnt,
                            PV_APPEND | PV_NO_DUPLICATE))
        goto lossage;
       if (!lex_match ('='))
@@ -93,7 +93,7 @@ cmd_rename_variables (void)
     }
   while (token != '.');
 
-  if (!dict_rename_vars (default_dict,
+  if (!dict_rename_vars (dataset_dict (ds),
                          rename_vars, rename_new_names, rename_cnt,
                          &err_name)) 
     {