Remove variables assigned to but never used.
[pspp] / src / language / control / repeat.c
index 68e69a4f225853d68d9859a86f629723311c39db..72d45c2c2ff96344cfe65c3948475fd661792469 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2007, 2009-2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
 #include "language/lexer/segment.h"
 #include "language/lexer/token.h"
 #include "language/lexer/variable-parser.h"
+#include "libpspp/assertion.h"
 #include "libpspp/cast.h"
 #include "libpspp/hash-functions.h"
 #include "libpspp/hmap.h"
@@ -189,13 +190,13 @@ count_values (struct hmap *dummies)
 }
 
 static void
-do_parse_commands (struct substring s, enum lex_syntax_mode syntax_mode,
+do_parse_commands (struct substring s, enum segmenter_mode mode,
                    struct hmap *dummies,
                    struct string *outputs, size_t n_outputs)
 {
   struct segmenter segmenter;
 
-  segmenter_init (&segmenter, syntax_mode);
+  segmenter_init (&segmenter, mode);
 
   while (!ss_is_empty (s))
     {
@@ -219,7 +220,7 @@ do_parse_commands (struct substring s, enum lex_syntax_mode syntax_mode,
               n += k;
             }
 
-          do_parse_commands (ss_head (s, n), syntax_mode, dummies,
+          do_parse_commands (ss_head (s, n), mode, dummies,
                              outputs, n_outputs);
         }
       else if (type != SEG_END)
@@ -244,9 +245,10 @@ do_parse_commands (struct substring s, enum lex_syntax_mode syntax_mode,
 static bool
 parse_commands (struct lexer *lexer, struct hmap *dummies)
 {
+  enum lex_syntax_mode syntax_mode;
+  enum segmenter_mode mode;
   struct string *outputs;
   struct string input;
-  size_t input_len;
   size_t n_values;
   char *file_name;
   int line_number;
@@ -269,15 +271,22 @@ parse_commands (struct lexer *lexer, struct hmap *dummies)
   if (ds_is_empty (&input))
     ds_put_byte (&input, '\n');
   ds_put_byte (&input, '\0');
-  input_len = ds_length (&input);
 
   n_values = count_values (dummies);
   outputs = xmalloc (n_values * sizeof *outputs);
   for (i = 0; i < n_values; i++)
     ds_init_empty (&outputs[i]);
 
-  do_parse_commands (ds_ss (&input), lex_get_syntax_mode (lexer),
-                     dummies, outputs, n_values);
+  syntax_mode = lex_get_syntax_mode (lexer);
+  if (syntax_mode == LEX_SYNTAX_AUTO)
+    mode = SEG_MODE_AUTO;
+  else if (syntax_mode == LEX_SYNTAX_INTERACTIVE)
+    mode = SEG_MODE_INTERACTIVE;
+  else if (syntax_mode == LEX_SYNTAX_BATCH)
+    mode = SEG_MODE_BATCH;
+  else
+    NOT_REACHED ();
+  do_parse_commands (ds_ss (&input), mode, dummies, outputs, n_values);
 
   ds_destroy (&input);
 
@@ -302,6 +311,7 @@ parse_commands (struct lexer *lexer, struct hmap *dummies)
       lex_include (lexer, reader);
     }
   free (file_name);
+  free (outputs);
 
   return ok;
 }
@@ -411,7 +421,6 @@ parse_strings (struct lexer *lexer, struct dummy_var *dv)
     {
       if (!lex_force_string (lexer))
        {
-         msg (SE, _("String expected."));
          return false;
        }