lexer: New function lex_force_int_range().
[pspp] / src / language / data-io / data-list.c
index 90d060eaab66721a8462fcb81baa351494177441..f689c99711d0626143f2026fc230d468d75beed0 100644 (file)
@@ -120,7 +120,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds)
        {
          lex_match (lexer, T_EQUALS);
          lex_match (lexer, T_LPAREN);
-         if (!lex_force_int (lexer))
+         if (!lex_force_int_range (lexer, "RECORDS", 0, INT_MAX))
            goto error;
           data_parser_set_records (parser, lex_integer (lexer));
          lex_get (lexer);
@@ -129,7 +129,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds)
       else if (lex_match_id (lexer, "SKIP"))
        {
          lex_match (lexer, T_EQUALS);
-         if (!lex_force_int (lexer))
+         if (!lex_force_int_range (lexer, "SKIP", 0, INT_MAX))
            goto error;
           data_parser_set_skip (parser, lex_integer (lexer));
          lex_get (lexer);
@@ -229,7 +229,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds)
                   data_parser_set_quotes (parser, ss_cstr ("'\""));
                   data_parser_set_soft_delimiters (parser,
                                                    ss_cstr (CC_SPACES));
-                  const char decimal = settings_get_decimal_char (FMT_F);
+                  const char decimal = settings_get_fmt_settings ()->decimal;
                   data_parser_set_hard_delimiters (parser,
                                                    ss_buffer (",", (decimal == '.') ? 1 : 0));
                 }
@@ -293,7 +293,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds)
       add_transformation (ds, data_list_trns_proc, data_list_trns_free, trns);
     }
   else
-    data_parser_make_active_file (parser, ds, reader, dict);
+    data_parser_make_active_file (parser, ds, reader, dict, NULL, NULL);
 
   fh_unref (fh);
   free (encoding);
@@ -303,7 +303,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds)
  error:
   data_parser_destroy (parser);
   if (!in_input_program ())
-    dict_destroy (dict);
+    dict_unref (dict);
   fh_unref (fh);
   free (encoding);
   return CMD_CASCADING_FAILURE;
@@ -355,7 +355,8 @@ parse_fixed (struct lexer *lexer, struct dictionary *dict,
             if (v != NULL)
               {
                 /* Success. */
-                struct fmt_spec output = fmt_for_output_from_input (f);
+                struct fmt_spec output = fmt_for_output_from_input (
+                  f, settings_get_fmt_settings ());
                 var_set_both_formats (v, &output);
               }
             else
@@ -459,7 +460,8 @@ parse_free (struct lexer *lexer, struct dictionary *dict,
           if (input.type == FMT_N)
             input.type = FMT_F;
 
-         output = fmt_for_output_from_input (&input);
+         output = fmt_for_output_from_input (&input,
+                                              settings_get_fmt_settings ());
        }
       else
        {