lex_get (lexer);
}
- if (!lex_force_id (lexer)
- || !dict_id_is_valid (dict, lex_tokcstr (lexer), true))
- goto error;
name = xstrdup (lex_tokcstr (lexer));
+ if (!lex_force_id (lexer)
+ || !dict_id_is_valid (dict, name, true))
+ {
+ goto error;
+ }
lex_get (lexer);
-
if (type == DP_DELIMITED)
{
if (!parse_format_specifier (lexer, &input)
- || !fmt_check_input (&input))
- goto error;
-
+ || !fmt_check_input (&input))
+ {
+ goto error;
+ }
output = fmt_for_output_from_input (&input);
}
else
msg (SE, _("Unknown format type `%s'."), fmt_type_name);
goto error;
}
-
/* Compose input format. */
input.type = fmt_type;
input.w = lc - fc + 1;
input.d = 0;
if (!fmt_check_input (&input))
goto error;
-
/* Compose output format. */
if (w != 0)
{
else
output = fmt_for_output_from_input (&input);
}
-
v = dict_create_var (dict, name, fmt_var_width (&input));
if (v == NULL)
{
goto error;
}
var_set_both_formats (v, &output);
-
if (type == DP_DELIMITED)
data_parser_add_delimited_field (parser, &input,
var_get_case_index (v),
AT_CLEANUP
+
+AT_SETUP([GET DATA /TYPE=txt bug])
+
+
+AT_DATA([thing.txt], [dnl
+foo, title, last
+1, this, 1
+2, that, 2
+3, other, 3
+])
+
+AT_DATA([x.sps], [dnl
+GET DATA
+ /TYPE=TXT
+ /FILE="thing.txt"
+ /ARRANGEMENT=DELIMITED
+ /DELCASE=LINE
+ /FIRSTCASE=2
+ /DELIMITERS=","
+ /VARIABLES=foo F1.0
+ title A8
+ last F2.0.
+
+list.
+])
+
+AT_CHECK([pspp -O format=csv x.sps], [0], [dnl
+Table: Data List
+foo,title,last
+1,this ,1
+2,that ,2
+3,other ,3
+])
+
+AT_CLEANUP
+
+