goto error;
struct spreadsheet *spreadsheet = NULL;
- if ( 0 == strncasecmp (tok, "GNM", 3))
+ if (0 == strncasecmp (tok, "GNM", 3))
spreadsheet = gnumeric_probe (filename, true);
- else if ( 0 == strncasecmp (tok, "ODS", 3))
+ else if (0 == strncasecmp (tok, "ODS", 3))
spreadsheet = ods_probe (filename, true);
if (spreadsheet == NULL)
lex_get (lexer);
- while (lex_match (lexer, T_SLASH) )
+ while (lex_match (lexer, T_SLASH))
{
- if ( lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
+ if (lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
{
lex_match (lexer, T_EQUALS);
- if (lex_force_int (lexer))
+ if (lex_force_int_range (lexer, "ASSUMEDSTRWIDTH", 1, 32767))
{
psql.str_width = lex_integer (lexer);
lex_get (lexer);
}
}
- else if ( lex_match_id (lexer, "BSIZE"))
+ else if (lex_match_id (lexer, "BSIZE"))
{
lex_match (lexer, T_EQUALS);
- if (lex_force_int (lexer))
+ if (lex_force_int_range (lexer, "BSIZE", 1, INT_MAX))
{
psql.bsize = lex_integer (lexer);
lex_get (lexer);
}
}
- else if ( lex_match_id (lexer, "UNENCRYPTED"))
+ else if (lex_match_id (lexer, "UNENCRYPTED"))
{
psql.allow_clear = true;
}
else if (lex_match_id (lexer, "SQL"))
{
lex_match (lexer, T_EQUALS);
- if ( ! lex_force_string (lexer) )
+ if (! lex_force_string (lexer))
goto error;
ds_put_substring (&psql.sql, lex_tokss (lexer));
struct dictionary *dict = NULL;
struct casereader *reader = psql_open_reader (&psql, &dict);
- if ( reader )
+ if (reader)
{
dataset_set_dict (ds, dict);
dataset_set_source (ds, reader);
lex_get (lexer);
- while (lex_match (lexer, T_SLASH) )
+ while (lex_match (lexer, T_SLASH))
{
- if ( lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
+ if (lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
{
lex_match (lexer, T_EQUALS);
- if (lex_force_int (lexer))
+ if (lex_force_int_range (lexer, "ASSUMEDSTRWIDTH", 1, 32767))
{
opts->asw = lex_integer (lexer);
lex_get (lexer);
lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "NAME"))
{
- if ( ! lex_force_string (lexer) )
+ if (! lex_force_string (lexer))
goto error;
opts->sheet_name = ss_xstrdup (lex_tokss (lexer));
}
else if (lex_match_id (lexer, "INDEX"))
{
- if (!lex_force_int (lexer))
+ if (!lex_force_int_range (lexer, "INDEX", 1, INT_MAX))
goto error;
-
opts->sheet_index = lex_integer (lexer);
- if (opts->sheet_index <= 0)
- {
- msg (SE, _("The sheet index must be greater than or equal to 1"));
- goto error;
- }
lex_get (lexer);
}
else
}
else if (lex_match_id (lexer, "RANGE"))
{
- if ( ! lex_force_string (lexer) )
+ if (! lex_force_string (lexer))
goto error;
opts->cell_range = ss_xstrdup (lex_tokss (lexer));
{
lex_match (lexer, T_EQUALS);
- if ( lex_match_id (lexer, "ON"))
+ if (lex_match_id (lexer, "ON"))
{
opts->read_names = true;
}
if (fh == NULL)
goto error;
- parser = data_parser_create (dict);
+ parser = data_parser_create ();
has_type = false;
data_parser_set_type (parser, DP_DELIMITED);
data_parser_set_span (parser, false);
DP_DELIMITED, &has_type);
else
{
- lex_error_expecting (lexer, "FIXED", "DELIMITED", NULL_SENTINEL);
+ lex_error_expecting (lexer, "FIXED", "DELIMITED");
goto error;
}
if (!ok)
else if (lex_match_id (lexer, "FIRSTCASE"))
{
lex_match (lexer, T_EQUALS);
- if (!lex_force_int (lexer))
+ if (!lex_force_int_range (lexer, "FIRSTCASE", 1, INT_MAX))
goto error;
- if (lex_integer (lexer) < 1)
- {
- msg (SE, _("Value of %s must be 1 or greater."), "FIRSTCASE");
- goto error;
- }
data_parser_set_skip (parser, lex_integer (lexer) - 1);
lex_get (lexer);
}
}
else
{
- lex_error_expecting (lexer, "LINE", "VARIABLES", NULL_SENTINEL);
+ lex_error_expecting (lexer, "LINE", "VARIABLES");
goto error;
}
}
if (!set_type (parser, "FIXCASE", DP_FIXED, &has_type))
goto error;
lex_match (lexer, T_EQUALS);
- if (!lex_force_int (lexer))
+ if (!lex_force_int_range (lexer, "FIXCASE", 1, INT_MAX))
goto error;
- if (lex_integer (lexer) < 1)
- {
- msg (SE, _("Value of %s must be 1 or greater."), "FIXCASE");
- goto error;
- }
data_parser_set_records (parser, lex_integer (lexer));
lex_get (lexer);
}
break;
else
{
- lex_error_expecting (lexer, "VARIABLES", NULL_SENTINEL);
+ lex_error_expecting (lexer, "VARIABLES");
goto error;
}
}
while (type == DP_FIXED && lex_match (lexer, T_SLASH))
{
- if (!lex_force_int (lexer))
+ if (!lex_force_int_range (lexer, NULL, record,
+ data_parser_get_records (parser)))
goto error;
- if (lex_integer (lexer) < record)
- {
- msg (SE, _("The record number specified, %ld, is at or "
- "before the previous record, %d. Data "
- "fields must be listed in order of "
- "increasing record number."),
- lex_integer (lexer), record);
- goto error;
- }
- if (lex_integer (lexer) > data_parser_get_records (parser))
- {
- msg (SE, _("The record number specified, %ld, exceeds "
- "the number of records per case specified "
- "on FIXCASE, %d."),
- lex_integer (lexer), data_parser_get_records (parser));
- goto error;
- }
record = lex_integer (lexer);
lex_get (lexer);
}
- name = xstrdup (lex_tokcstr (lexer));
+ const char * tstr = lex_tokcstr (lexer);
+ if (tstr == NULL)
+ {
+ lex_error (lexer, NULL);
+ goto error;
+ }
+ name = xstrdup (tstr);
if (!lex_force_id (lexer)
|| !dict_id_is_valid (dict, name, true))
{
{
goto error;
}
- output = fmt_for_output_from_input (&input);
+ output = fmt_for_output_from_input (&input,
+ settings_get_fmt_settings ());
}
else
{
char fmt_type_name[FMT_TYPE_LEN_MAX + 1];
enum fmt_type fmt_type;
- int w, d;
+ uint16_t w;
+ uint8_t d;
if (!parse_column_range (lexer, 0, &fc, &lc, NULL))
goto error;
goto error;
}
else
- output = fmt_for_output_from_input (&input);
+ output = fmt_for_output_from_input (&input,
+ settings_get_fmt_settings ());
}
v = dict_create_var (dict, name, fmt_var_width (&input));
if (v == NULL)
if (reader == NULL)
goto error;
- 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);
return CMD_SUCCESS;
error:
data_parser_destroy (parser);
- dict_destroy (dict);
+ dict_unref (dict);
fh_unref (fh);
free (name);
free (encoding);