return CMD_CASCADING_FAILURE;
handle = fh_from_id (lex_tokcstr (lexer));
if (handle == NULL)
- return CMD_CASCADING_FAILURE;
+ {
+ lex_next_error (lexer, 0, 0, _("No file handle named %s."),
+ lex_tokcstr (lexer));
+ return CMD_CASCADING_FAILURE;
+ }
+ lex_get (lexer);
fh_unname (handle);
+ fh_unref (handle);
return CMD_SUCCESS;
}
20 | FILE HANDLE y/NAME='x.txt'/MODE=FIXED.
| ^~~~~"
])
-AT_CLEANUP
\ No newline at end of file
+AT_CLEANUP
+
+AT_SETUP([CLOSE FILE HANDLE])
+AT_DATA([wiggle.txt], [dnl
+1
+2
+5
+109
+])
+AT_DATA([wobble.txt], [dnl
+7
+8
+9
+])
+AT_DATA([file-handle.sps], [dnl
+FILE HANDLE myhandle /NAME='wiggle.txt'.
+DATA LIST LIST FILE=myhandle /x *.
+LIST.
+
+CLOSE FILE HANDLE myhandle.
+
+FILE HANDLE myhandle /NAME='wobble.txt'.
+DATA LIST LIST FILE=myhandle /x *.
+LIST.
+])
+AT_CHECK([pspp -O format=csv file-handle.sps], [0], [dnl
+Table: Reading free-form data from myhandle.
+Variable,Format
+x,F8.0
+
+Table: Data List
+x
+1.00
+2.00
+5.00
+109.00
+
+Table: Reading free-form data from myhandle.
+Variable,Format
+x,F8.0
+
+Table: Data List
+x
+7.00
+8.00
+9.00
+])
+AT_CLEANUP
+
+AT_SETUP([CLOSE FILE HANDLE syntax errors])
+AT_DATA([wiggle.txt], [dnl
+1
+2
+5
+109
+])
+AT_DATA([file-handle.sps], [dnl
+FILE HANDLE myhandle /NAME='wiggle.txt'.
+CLOSE FILE HANDLE myhandle **.
+CLOSE FILE HANDLE myhandle.
+CLOSE FILE HANDLE myhandle.
+CLOSE FILE HANDLE **.
+])
+AT_DATA([insert.sps], [dnl
+INSERT FILE='file-handle.sps' ERROR=IGNORE.
+])
+AT_CHECK([pspp -O format=csv insert.sps], [1], [dnl
+"insert.sps:1.37-1.42: error: INSERT: Syntax error expecting CONTINUE or STOP.
+ 1 | INSERT FILE='file-handle.sps' ERROR=IGNORE.
+ | ^~~~~~"
+])
+AT_CLEANUP