by a number of narrower string variables. @xref{Very Long String
Record}, for details.
+A system file should contain at least one variable and thus at least
+one variable record, but system files have been observed in the wild
+without any variables (thus, no data either).
+
@example
int32 rec_type;
int32 type;
int retval;
int i;
- if (r->error)
+ if (r->error || !r->sfm_var_cnt)
return NULL;
c = case_create (r->proto);
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006-2007, 2010-15 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
#include "language/lexer/lexer.h"
#include "libpspp/compiler.h"
#include "libpspp/misc.h"
+#include "libpspp/message.h"
#include "libpspp/str.h"
#include "gl/xalloc.h"
if (reader == NULL)
goto error;
+ if (dict_get_var_cnt (dict) == 0)
+ {
+ msg (SE, _("%s: Data file dictionary has no variables."),
+ fh_get_name (fh));
+ goto error;
+ }
+
stage = case_map_stage_create (dict);
while (lex_token (lexer) != T_ENDCMD)
])
AT_CHECK([pspp -O format=csv pc+-file.sps], [1], [dnl
error: `pc+-file.sav' near offset 0x1b0: Record 1 has length 192 (expected 224).
+
+pc+-file.sps:1: error: GET: `pc+-file.sav': Data file dictionary has no variables.
])
AT_CLEANUP
\f
AT_BANNER([system file reader - negative])
+AT_SETUP([no variables])
+AT_KEYWORDS([sack synthetic system file negative])
+AT_DATA([sys-file.sack], [dnl
+dnl File header.
+"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
+2; dnl Layout code
+0; dnl Nominal case size (empty)
+0; dnl Not compressed
+0; dnl Not weighted
+0; dnl 0 cases.
+100.0; dnl Bias.
+"01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
+i8 0 *3;
+
+dnl Character encoding record.
+7; 20; 1; 12; "windows-1252";
+
+dnl Dictionary termination record.
+999; 0;
+])
+for variant in be le; do
+ AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
+ AT_DATA([sys-file.sps], [dnl
+GET FILE='sys-file.sav'.
+])
+ AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
+sys-file.sps:1: error: GET: `sys-file.sav': Data file dictionary has no variables.
+])
+
+ dnl At one point pspp-convert would hang forever if there were no variables,
+ dnl so check against regression.
+ AT_CHECK([pspp-convert sys-file.sav sys-file.txt])
+ AT_CHECK([cat sys-file.txt], [0], [
+])
+done
+AT_CLEANUP
+
AT_SETUP([unspecified character encoding])
AT_KEYWORDS([sack synthetic system file positive])
AT_DATA([sys-file.sack], [dnl