Fix understanding of how long string variable missing values work.
[pspp] / tests / data / sys-file-reader.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([system file reader - positive])
18
19 AT_SETUP([variable labels and missing values])
20 AT_KEYWORDS([sack synthetic system file positive])
21 AT_DATA([sys-file.sack], [dnl
22 dnl File header.
23 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
24 2; dnl Layout code
25 28; dnl Nominal case size
26 0; dnl Not compressed
27 0; dnl Not weighted
28 1; dnl 1 case.
29 100.0; dnl Bias.
30 "01 Jan 11"; "20:53:52";
31 "PSPP synthetic test file: "; i8 244; i8 245; i8 246; i8 248; s34 "";
32 i8 0 *3;
33
34 dnl Numeric variable, no label or missing values.
35 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
36
37 dnl Numeric variable, variable label.
38 2; 0; 1; 0; 0x050800 *2; s8 "NUM2";
39 32; "Numeric variable 2's label ("; i8 249; i8 250; i8 251; ")";
40
41 dnl Numeric variable, one missing value.
42 2; 0; 0; 1; 0x050800 *2; s8 "NUM3";
43 1.0;
44
45 dnl Numeric variable, variable label and missing value.
46 2; 0; 1; 1; 0x050800 *2; s8 "NUM4";
47 30; "Another numeric variable label"; i8 0 * 2;
48 1.0;
49
50 dnl Numeric variable, two missing values.
51 2; 0; 0; 2; 0x050800 *2; s8 "NUM5"; 1.0; 2.0;
52
53 dnl Numeric variable, three missing values.
54 2; 0; 0; 3; 0x050800 *2; s8 "NUM6"; 1.0; 2.0; 3.0;
55
56 dnl Numeric variable, range of missing values.
57 2; 0; 0; -2; 0x050800 *2; s8 "NUM7"; 1.0; 3.0;
58
59 dnl Numeric variables, range of missing values plus discrete value.
60 2; 0; 0; -3; 0x050800 *2; s8 "NUM8"; 1.0; 3.0; 5.0;
61 2; 0; 0; -3; 0x050800 *2; s8 "NUM9"; 1.0; HIGHEST; -5.0;
62 2; 0; 0; -3; 0x050800 *2; "NUM"; i8 192; i8 200; i8 204; i8 209; i8 210;
63 LOWEST; 1.0; 5.0;
64
65 dnl String variable, no label or missing values.
66 2; 4; 0; 0; 0x010400 *2; s8 "STR1";
67
68 dnl String variable, variable label.
69 2; 4; 1; 0; 0x010400 *2; s8 "STR2";
70 25; "String variable 2's label"; i8 0 * 3;
71
72 dnl String variable, one missing value.
73 2; 4; 0; 1; 0x010400 *2; s8 "STR3"; s8 "MISS";
74
75 dnl String variable, variable label and missing value.
76 2; 4; 1; 1; 0x010400 *2; s8 "STR4";
77 29; "Another string variable label"; i8 0 * 3;
78 s8 "OTHR";
79
80 dnl String variable, two missing values.
81 2; 4; 0; 2; 0x010400 *2; s8 "STR5"; s8 "MISS"; s8 "OTHR";
82
83 dnl String variable, three missing values.
84 2; 4; 0; 3; 0x010400 *2; s8 "STR6"; s8 "MISS"; s8 "OTHR"; s8 "MORE";
85
86 dnl Long string variable, one missing value.
87 dnl (This is not how SPSS represents missing values for long strings--it
88 dnl uses a separate record as shown later below--but old versions of PSPP
89 dnl did use this representation so we continue supporting it for backward
90 dnl compatibility.
91 2; 11; 0; 1; 0x010b00 *2; s8 "STR7"; "first8by";
92 2; -1; 0; 0; 0; 0; s8 "";
93
94 dnl Long string variables that will have missing values added with a
95 dnl later record.
96 2; 9; 0; 0; 0x010900 *2; s8 "STR8";
97 2; -1; 0; 0; 0; 0; s8 "";
98 2; 10; 0; 0; 0x010a00 *2; s8 "STR9";
99 2; -1; 0; 0; 0; 0; s8 "";
100 2; 11; 0; 0; 0x010b00 *2; s8 "STR10";
101 2; -1; 0; 0; 0; 0; s8 "";
102
103 dnl Long string variable, value label.
104 2; 25; 1; 0; 0x011900 *2; s8 "STR11"; 14; "25-byte string"; i8 0 * 2;
105 ( 2; -1; 0; 0; 0; 0; s8 ""; ) * 2;
106 dnl Variable label fields on continuation records have been spotted in system
107 dnl files created by "SPSS Power Macintosh Release 6.1".
108 2; -1; 1; 0; 0; 0; s8 ""; 20; "dummy variable label";
109
110 dnl Machine integer info record.
111 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
112
113 dnl Machine floating-point info record.
114 7; 4; 8; 3; SYSMIS; HIGHEST; LOWEST;
115
116 dnl Long string variable missing values record.
117 7; 22; 1; COUNT (
118 dnl One missing value for STR8.
119 COUNT("STR8"); i8 1; 8; "abcdefgh";
120
121 dnl Two missing values for STR9.
122 COUNT("STR9"); i8 2; 8; "abcdefgh"; "01234567";
123
124 dnl Three missing values for STR9.
125 COUNT("STR10"); i8 3; 8; "abcdefgh"; "01234567"; "0       ";
126 );
127
128 dnl Character encoding record.
129 7; 20; 1; 12; "windows-1252";
130
131 dnl Dictionary termination record.
132 999; 0;
133
134 dnl Data.
135 1.0; 2.0; 3.0; 4.0; 5.0; 6.0; 7.0; 8.0; 9.0; 10.0;
136 s8 "abcd"; s8 "efgh"; s8 "ijkl"; s8 "mnop"; s8 "qrst"; s8 "uvwx";
137 s16 "yzABCDEFGHI"; s16 "JKLMNOPQR"; s16 "STUVWXYZ01";
138 s16 "23456789abc"; s32 "defghijklmnopqstuvwxyzABC";
139 ])
140 for variant in be le; do
141   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
142   AT_DATA([sys-file.sps], [dnl
143 GET FILE='sys-file.sav'.
144 DISPLAY FILE LABEL.
145 DISPLAY DICTIONARY.
146 LIST.
147 ])
148   AT_CHECK([pspp -o pspp.csv sys-file.sps])
149   AT_CHECK([cat pspp.csv], [0], [dnl
150 Table: File Label
151 Label,PSPP synthetic test file: ôõöø
152
153 Table: Variables
154 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
155 num1,1,,Unknown,Input,8,Right,F8.0,F8.0,
156 num2,2,Numeric variable 2's label (ùúû),Unknown,Input,8,Right,F8.0,F8.0,
157 num3,3,,Unknown,Input,8,Right,F8.0,F8.0,1
158 num4,4,Another numeric variable label,Unknown,Input,8,Right,F8.0,F8.0,1
159 num5,5,,Unknown,Input,8,Right,F8.0,F8.0,1; 2
160 num6,6,,Unknown,Input,8,Right,F8.0,F8.0,1; 2; 3
161 num7,7,,Unknown,Input,8,Right,F8.0,F8.0,1 THRU 3
162 num8,8,,Unknown,Input,8,Right,F8.0,F8.0,1 THRU 3; 5
163 num9,9,,Unknown,Input,8,Right,F8.0,F8.0,1 THRU HIGHEST; -5
164 numàèìñò,10,,Unknown,Input,8,Right,F8.0,F8.0,LOWEST THRU 1; 5
165 str1,11,,Nominal,Input,4,Left,A4,A4,
166 str2,12,String variable 2's label,Nominal,Input,4,Left,A4,A4,
167 str3,13,,Nominal,Input,4,Left,A4,A4,"""MISS"""
168 str4,14,Another string variable label,Nominal,Input,4,Left,A4,A4,"""OTHR"""
169 str5,15,,Nominal,Input,4,Left,A4,A4,"""MISS""; ""OTHR"""
170 str6,16,,Nominal,Input,4,Left,A4,A4,"""MISS""; ""OTHR""; ""MORE"""
171 str7,17,,Nominal,Input,11,Left,A11,A11,"""first8by"""
172 str8,18,,Nominal,Input,9,Left,A9,A9,"""abcdefgh"""
173 str9,19,,Nominal,Input,10,Left,A10,A10,"""abcdefgh""; ""01234567"""
174 str10,20,,Nominal,Input,11,Left,A11,A11,"""abcdefgh""; ""01234567""; ""0       """
175 str11,21,25-byte string,Nominal,Input,25,Left,A25,A25,
176
177 Table: Data List
178 num1,num2,num3,num4,num5,num6,num7,num8,num9,numàèìñò,str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11
179 1,2,3,4,5,6,7,8,9,10,abcd,efgh,ijkl,mnop,qrst,uvwx,yzABCDEFGHI,JKLMNOPQR,STUVWXYZ01,23456789abc,defghijklmnopqstuvwxyzABC
180 ])
181 done
182 AT_CLEANUP
183
184 AT_SETUP([unspecified number of variable positions])
185 AT_KEYWORDS([sack synthetic system file positive])
186 AT_DATA([sys-file.sack], [dnl
187 dnl File header.
188 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
189 2; dnl Layout code
190 -1; dnl Nominal case size (unspecified)
191 0; dnl Not compressed
192 0; dnl Not weighted
193 1; dnl 1 case.
194 100.0; dnl Bias.
195 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
196 i8 0 *3;
197
198 dnl Numeric variable, no label or missing values.
199 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
200
201 dnl Numeric variable, variable label.
202 2; 0; 1; 0; 0x050800 *2; s8 "NUM2";
203 26; "Numeric variable 2's label"; i8 0 *2;
204
205 dnl Character encoding record.
206 7; 20; 1; 12; "windows-1252";
207
208 dnl Dictionary termination record.
209 999; 0;
210
211 dnl Data.
212 1.0; 2.0;
213 ])
214 for variant in be le; do
215   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
216   AT_DATA([sys-file.sps], [dnl
217 GET FILE='sys-file.sav'.
218 DISPLAY DICTIONARY.
219 LIST.
220 ])
221   AT_CHECK([pspp -o pspp.csv sys-file.sps])
222   AT_CHECK([cat pspp.csv], [0], [dnl
223 Table: Variables
224 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format
225 num1,1,,Unknown,Input,8,Right,F8.0,F8.0
226 num2,2,Numeric variable 2's label,Unknown,Input,8,Right,F8.0,F8.0
227
228 Table: Data List
229 num1,num2
230 1,2
231 ])
232 done
233 AT_CLEANUP
234
235 AT_SETUP([wrong number of variable positions but version 13])
236 AT_KEYWORDS([sack synthetic system file positive])
237 AT_DATA([sys-file.sack], [dnl
238 dnl File header.
239 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
240 2; dnl Layout code
241 -1; dnl Nominal case size (unspecified)
242 0; dnl Not compressed
243 0; dnl Not weighted
244 1; dnl 1 case.
245 100.0; dnl Bias.
246 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
247 i8 0 *3;
248
249 dnl Numeric variable, no label or missing values.
250 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
251
252 dnl Numeric variable, variable label.
253 2; 0; 1; 0; 0x050800 *2; s8 "NUM2";
254 26; "Numeric variable 2's label"; i8 0 *2;
255
256 dnl Machine integer info record (SPSS 13).
257 7; 3; 4; 8; 13; 2; 3; -1; 1; 1; ENDIAN; 1252;
258
259 dnl Character encoding record.
260 7; 20; 1; 12; "windows-1252";
261
262 dnl Dictionary termination record.
263 999; 0;
264
265 dnl Data.
266 1.0; 2.0;
267 ])
268 for variant in be le; do
269   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
270   AT_DATA([sys-file.sps], [dnl
271 GET FILE='sys-file.sav'.
272 DISPLAY DICTIONARY.
273 LIST.
274 ])
275   AT_CHECK([pspp -o pspp.csv sys-file.sps])
276   AT_CHECK([cat pspp.csv], [0], [dnl
277 Table: Variables
278 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format
279 num1,1,,Unknown,Input,8,Right,F8.0,F8.0
280 num2,2,Numeric variable 2's label,Unknown,Input,8,Right,F8.0,F8.0
281
282 Table: Data List
283 num1,num2
284 1,2
285 ])
286 done
287 AT_CLEANUP
288
289 AT_SETUP([value labels])
290 AT_KEYWORDS([sack synthetic system file positive])
291 AT_DATA([sys-file.sack], [dnl
292 dnl File header.
293 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
294 2; dnl Layout code
295 22; dnl Nominal case size
296 0; dnl Not compressed
297 0; dnl Not weighted
298 1; dnl 1 case.
299 100.0; dnl Bias.
300 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
301 i8 0 *3;
302
303 dnl Numeric variables.
304 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
305 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
306 2; 0; 0; 0; 0x050800 *2; s8 "NUM3";
307 2; 0; 0; 0; 0x050800 *2; s8 "NUM4";
308 2; 0; 0; 0; 0x050800 *2; s8 "NUM5";
309
310 dnl String variables.
311 2; 1; 0; 0; 0x010100 *2; s8 "STR1"; dnl index 6
312 2; 2; 0; 0; 0x010200 *2; s8 "STR2"; dnl index 7
313 2; 3; 0; 0; 0x010300 *2; s8 "STR3"; dnl index 8
314 2; 4; 0; 0; 0x010400 *2; s8 "STR4"; dnl index 9
315 2; 4; 0; 0; 0x010400 *2; s8 "STR5"; dnl index 10
316 2; 6; 0; 0; 0x010600 *2; s8 "STR6"; dnl index 11
317 2; 7; 0; 0; 0x010700 *2; s8 "STR7"; dnl index 12
318 2; 8; 0; 0; 0x010800 *2; s8 "STR8"; dnl index 13
319 2; 9; 0; 0; 0x010900 *2; "STR9"; i8 230; s3 ""; dnl index 14
320 2; -1; 0; 0; 0; 0; s8 "";
321 2; 12; 0; 0; 0x010c00 *2; s8 "STR12"; dnl index 16
322 2; -1; 0; 0; 0; 0; s8 "";
323 2; 16; 0; 0; 0x011000 *2; s8 "STR16"; dnl index 18
324 2; -1; 0; 0; 0; 0; s8 "";
325 2; 17; 0; 0; 0x011100 *2; s8 "STR17"; dnl index 20
326 ( 2; -1; 0; 0; 0; 0; s8 ""; ) * 2;
327
328 dnl One value label for NUM1.
329 3; 1; 1.0; i8 17; i8 238; i8 228; i8 232; i8 237; s19 " (in Russian)"; 4; 1; 1;
330
331 dnl Two value labels for NUM2, as a single pair of type 3 and type 4 records.
332 3; 2; 1.0; i8 3; s7 "one"; 2.0; i8 3; s7 "two"; 4; 1; 2;
333
334 dnl Two value labels for NUM3, as two pairs of type 3 and type 4 records.
335 3; 1; 3.0; i8 5; s7 "three"; 4; 1; 3;
336 3; 1; 4.0; i8 4; s7 "four"; 4; 1; 3;
337
338 dnl Two common value labels for NUM4 and NUM5, plus two different ones for each.
339 3; 1; 5.0; i8 4; s7 "five"; 4; 1; 4;
340 3; 1; 6.0; i8 3; s7 "six"; 4; 1; 5;
341 3; 2; 7.0; i8 5; s7 "seven"; 8.0; i8 5; s7 "eight"; 4; 2; 4; 5;
342 3; 1; 9.0; i8 4; s7 "nine"; 4; 1; 4;
343 3; 1; 10.0; i8 3; s7 "ten"; 4; 1; 5;
344
345 dnl One value label for STR1.
346 3; 1; s8 "a"; i8 19; s23 "value label for `a'"; 4; 1; 6;
347
348 dnl Two value labels for STR2, as a single pair of type 3 and type 4 records.
349 3; 2;
350 s8 "bc"; i8 20; s23 "value label for `bc'";
351 s8 "de"; i8 20; s23 "value label for `de'";
352 4; 1; 7;
353
354 dnl Two value labels for STR3, as two pairs of type 3 and type 4 records.
355 3; 1; s8 "fgh"; i8 21; s23 "value label for `fgh'"; 4; 1; 8;
356 3; 1; s8 "ijk"; i8 21; s23 "value label for `ijk'"; 4; 1; 8;
357
358 dnl Two common value labels for STR4 and STR5, plus two different ones for each.
359 3; 1; s8 "lmno"; i8 22; s23 "value label for `lmno'"; 4; 1; 9;
360 3; 1; s8 "pqrs"; i8 22; s23 "value label for `pqrs'"; 4; 1; 10;
361 3; 2;
362 s8 "tuvw"; i8 22; s23 "value label for `tuvw'";
363 s8 "xyzA"; i8 22; s23 "value label for `xyzA'";
364 4; 2; 9; 10;
365 3; 1; s8 "BCDE"; i8 22; s23 "value label for `BCDE'"; 4; 1; 9;
366 3; 1; s8 "FGHI"; i8 22; s23 "value label for `FGHI'"; 4; 1; 10;
367
368 dnl One value label for STR6, STR7, STR8.
369 3; 1; s8 "JKLMNO"; i8 24; s31 "value label for `JKLMNO'"; 4; 1; 11;
370 3; 1; s8 "JKLMNOP"; i8 25; s31 "value label for `JKLMNOP'"; 4; 1; 12;
371 3; 1; s8 "JKLMNOPQ"; i8 26; s31 "value label for `JKLMNOPQ'"; 4; 1; 13;
372
373 dnl Machine integer info record.
374 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1251;
375
376 dnl Character encoding record.
377 7; 20; 1; 12; "windows-1251";
378
379 7; 21; 1; COUNT (
380 dnl One value label for STR9ж,
381 COUNT("STR9"; i8 230); 9; 1; COUNT("RSTUVWXYZ"); COUNT("value label for `RSTUVWXYZ'");
382
383 dnl Two value labels for STR12.
384 COUNT("STR12"); 12; 2;
385 COUNT("0123456789ab"); COUNT("value label for `0123456789ab'");
386 COUNT("cdefghijklmn"); COUNT("value label for `cdefghijklmn'");
387
388 dnl Three value labels for STR16.
389 COUNT("STR16"); 16; 3;
390 COUNT("opqrstuvwxyzABCD"); COUNT("value label for `opqrstuvwxyzABCD'");
391 COUNT("EFGHIJKLMNOPQRST"); COUNT("value label for `EFGHIJKLMNOPQRST'");
392 COUNT("UVWXYZ0123456789"); COUNT("value label for `UVWXYZ0123456789' with Cyrillic letters: `"; i8 244; i8 245; i8 246; "'");
393
394 dnl One value label for STR17.
395 COUNT("STR17"); 17; 1;
396 COUNT("abcdefghijklmnopq"); COUNT("value label for `abcdefghijklmnopq'");
397 );
398
399 dnl Dictionary termination record.
400 999; 0;
401 ])
402 for variant in be le; do
403   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
404   AT_DATA([sys-file.sps], [dnl
405 GET FILE='sys-file.sav'.
406 DISPLAY DICTIONARY.
407 ])
408   AT_CHECK([pspp -o pspp.csv sys-file.sps])
409   AT_CHECK([cat pspp.csv], [0], [dnl
410 Table: Variables
411 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
412 num1,1,Unknown,Input,8,Right,F8.0,F8.0
413 num2,2,Unknown,Input,8,Right,F8.0,F8.0
414 num3,3,Unknown,Input,8,Right,F8.0,F8.0
415 num4,4,Unknown,Input,8,Right,F8.0,F8.0
416 num5,5,Unknown,Input,8,Right,F8.0,F8.0
417 str1,6,Nominal,Input,1,Left,A1,A1
418 str2,7,Nominal,Input,2,Left,A2,A2
419 str3,8,Nominal,Input,3,Left,A3,A3
420 str4,9,Nominal,Input,4,Left,A4,A4
421 str5,10,Nominal,Input,4,Left,A4,A4
422 str6,11,Nominal,Input,6,Left,A6,A6
423 str7,12,Nominal,Input,7,Left,A7,A7
424 str8,13,Nominal,Input,8,Left,A8,A8
425 str9ж,14,Nominal,Input,9,Left,A9,A9
426 str12,15,Nominal,Input,12,Left,A12,A12
427 str16,16,Nominal,Input,16,Left,A16,A16
428 str17,17,Nominal,Input,17,Left,A17,A17
429
430 Table: Value Labels
431 Variable Value,,Label
432 num1,1,один (in Russian)
433 num2,1,one
434 ,2,two
435 num3,3,three
436 ,4,four
437 num4,5,five
438 ,7,seven
439 ,8,eight
440 ,9,nine
441 num5,6,six
442 ,7,seven
443 ,8,eight
444 ,10,ten
445 str1,a,value label for `a'
446 str2,bc,value label for `bc'
447 ,de,value label for `de'
448 str3,fgh,value label for `fgh'
449 ,ijk,value label for `ijk'
450 str4,BCDE,value label for `BCDE'
451 ,lmno,value label for `lmno'
452 ,tuvw,value label for `tuvw'
453 ,xyzA,value label for `xyzA'
454 str5,FGHI,value label for `FGHI'
455 ,pqrs,value label for `pqrs'
456 ,tuvw,value label for `tuvw'
457 ,xyzA,value label for `xyzA'
458 str6,JKLMNO,value label for `JKLMNO'
459 str7,JKLMNOP,value label for `JKLMNOP'
460 str8,JKLMNOPQ,value label for `JKLMNOPQ'
461 str9ж,RSTUVWXYZ,value label for `RSTUVWXYZ'
462 str12,0123456789ab,value label for `0123456789ab'
463 ,cdefghijklmn,value label for `cdefghijklmn'
464 str16,EFGHIJKLMNOPQRST,value label for `EFGHIJKLMNOPQRST'
465 ,UVWXYZ0123456789,value label for `UVWXYZ0123456789' with Cyrillic letters: `фхц'
466 ,opqrstuvwxyzABCD,value label for `opqrstuvwxyzABCD'
467 str17,abcdefghijklmnopq,value label for `abcdefghijklmnopq'
468 ])
469 done
470 AT_CLEANUP
471
472 AT_SETUP([documents])
473 AT_KEYWORDS([sack synthetic system file positive])
474 AT_DATA([sys-file.sack], [dnl
475 dnl File header.
476 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
477 2; dnl Layout code
478 1; dnl Nominal case size
479 0; dnl Not compressed
480 0; dnl Not weighted
481 1; dnl 1 case.
482 100.0; dnl Bias.
483 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
484 i8 0 *3;
485
486 dnl Numeric variable, no label or missing values.
487 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
488
489 dnl Machine integer info record.
490 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
491
492 dnl Document record.
493 6; 5;
494 s80 "First line of documents";
495 s80 "Second line of documents";
496 "abb"; i8 233; " appliqu"; i8 233; " attach"; i8 233; " blas"; i8 233; " caf"; i8 233; " canap"; i8 233; " clich"; i8 233; " consomm"; i8 233;
497 s25 "";
498 s80 "";
499 s80 "Last line of documents";
500
501 dnl Character encoding record.
502 7; 20; 1; 12; "windows-1252";
503
504 dnl Dictionary termination record.
505 999; 0;
506
507 dnl Data.
508 1.0;
509 ])
510 for variant in be le; do
511   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
512   AT_DATA([sys-file.sps], [dnl
513 GET FILE='sys-file.sav'.
514 DISPLAY DOCUMENTS.
515 LIST.
516 ])
517   AT_CHECK([pspp -o pspp.csv sys-file.sps])
518   AT_CHECK([cat pspp.csv], [0], [dnl
519 Table: Documents
520 "First line of documents
521 Second line of documents
522 abbé appliqué attaché blasé café canapé cliché consommé
523
524 Last line of documents"
525
526 Table: Data List
527 num1
528 1
529 ])
530 done
531 AT_CLEANUP
532
533 AT_SETUP([empty document record])
534 AT_KEYWORDS([sack synthetic system file positive])
535 AT_DATA([sys-file.sack], [dnl
536 dnl File header.
537 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
538 2; dnl Layout code
539 1; dnl Nominal case size
540 0; dnl Not compressed
541 0; dnl Not weighted
542 1; dnl 1 case.
543 100.0; dnl Bias.
544 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
545 i8 0 *3;
546
547 dnl Numeric variable, no label or missing values.
548 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
549
550 dnl Machine integer info record.
551 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
552
553 dnl Document record.
554 6; 0;
555
556 dnl Character encoding record.
557 7; 20; 1; 12; "windows-1252";
558
559 dnl Dictionary termination record.
560 999; 0;
561
562 dnl Data.
563 1.0;
564 ])
565 for variant in be le; do
566   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
567   AT_DATA([sys-file.sps], [dnl
568 GET FILE='sys-file.sav'.
569 LIST.
570 ])
571   AT_CHECK([pspp -o pspp.csv sys-file.sps])
572   AT_CHECK([cat pspp.csv], [0], [dnl
573 Table: Data List
574 num1
575 1
576 ])
577 done
578 AT_CLEANUP
579
580 AT_SETUP([multiple response sets])
581 AT_KEYWORDS([sack synthetic system file positive])
582 AT_DATA([sys-file.sack], [dnl
583 dnl File header.
584 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
585 2; dnl Layout code
586 16; dnl Nominal case size
587 0; dnl Not compressed
588 0; dnl Not weighted
589 0; dnl No cases.
590 100.0; dnl Bias.
591 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
592 i8 0 *3;
593
594 dnl $a
595 2; 0; 0; 0; 0x050800 *2; i8 0x82; i8 0xa0; s6 "";
596 2; 0; 0; 0; 0x050800 *2; s8 "B";
597 2; 0; 0; 0; 0x050800 *2; s8 "C";
598
599 dnl $b
600 2; 0; 0; 0; 0x050800 *2; s8 "D";
601 2; 0; 0; 0; 0x050800 *2; s8 "E";
602 2; 0; 0; 0; 0x050800 *2; s8 "F";
603 2; 0; 0; 0; 0x050800 *2; s8 "G";
604
605 dnl $c
606 2; 4; 0; 0; 0x010400 *2; s8 "H";
607 2; 4; 0; 0; 0x010400 *2; s8 "I";
608 2; 4; 0; 0; 0x010400 *2; s8 "J";
609
610 dnl $d
611 2; 0; 0; 0; 0x050800 *2; s8 "K";
612 2; 0; 0; 0; 0x050800 *2; s8 "L";
613 2; 0; 0; 0; 0x050800 *2; s8 "M";
614
615 dnl $e
616 2; 6; 0; 0; 0x010600 *2; s8 "N";
617 2; 6; 0; 0; 0x010600 *2; s8 "O";
618 2; 6; 0; 0; 0x010600 *2; s8 "P";
619
620 dnl Machine integer info record.
621 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 932;
622
623 7; 7; 1;
624 COUNT(
625   "$a=C 10 my mcgroup "; i8 0x82; i8 0xa0; " b c"; i8 10;
626   "$b=D2 55 0  g e f d"; i8 10; i8 10;
627   "$c=D4 "; i8 0x82; i8 0xcd; i8 0x82; i8 0xa2; " 10 mdgroup #2 h i j"; i8 10);
628
629 7; 19; 1;
630 COUNT(
631   i8 10;
632   "$d=E 1 2 34 13 third mdgroup k l m"; i8 10;
633   "$e=E 11 6 choice 0  n o p"; i8 10; i8 10; i8 10; i8 10);
634
635 dnl Character encoding record.
636 7; 20; 1; 9; "shift_jis";
637
638 dnl Dictionary termination record.
639 999; 0;
640 ])
641 for variant in be le; do
642   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
643   AT_DATA([sys-file.sps], [dnl
644 GET FILE='sys-file.sav'.
645 MRSETS /DISPLAY NAME=ALL.
646 ])
647   AT_CHECK([pspp -o pspp.csv sys-file.sps])
648   AT_CHECK([cat pspp.csv], [0], [dnl
649 Table: Multiple Response Sets
650 Name,Label,Encoding,Counted Value,Member Variables
651 $a,my mcgroup,Categories,,"あ
652 b
653 c"
654 $b,,Dichotomies,55,"g
655 e
656 f
657 d"
658 $c,mdgroup #2,Dichotomies,はい,"h
659 i
660 j"
661 $d,third mdgroup,Dichotomies,34,"k
662 l
663 m"
664 $e,,Dichotomies,choice,"n
665 o
666 p"
667 ])
668 done
669 AT_CLEANUP
670
671 dnl Also checks for handling of CR-only line ends in file label and
672 dnl extra product info.
673 AT_SETUP([extra product info])
674 AT_KEYWORDS([sack synthetic system file positive])
675 AT_DATA([sys-file.sack], [dnl
676 dnl File header.
677 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
678 2; dnl Layout code
679 4; dnl Nominal case size
680 0; dnl Not compressed
681 0; dnl Not weighted
682 0; dnl No cases.
683 100.0; dnl Bias.
684 "01 Jan 11"; "20:53:52"; "PSPP synthetic"; i8 13; s49 "test file";
685 i8 0 *3;
686
687 dnl Numeric variables.
688 2; 0; 0; 0; 0x050800 *2; s8 "A";
689 2; 0; 0; 0; 0x050800 *2; s8 "B";
690 2; 0; 0; 0; 0x050800 *2; s8 "C";
691 2; 0; 0; 0; 0x050800 *2; s8 "D";
692
693 dnl Extra product info.
694 7; 10; 1; COUNT ("Extra product info"; i8 13; "another line"; i8 13; "blah");
695
696 dnl Character encoding record.
697 7; 20; 1; 12; "windows-1252";
698
699 dnl Dictionary termination record.
700 999; 0;
701 ])
702 for variant in be; do
703   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
704   AT_DATA([sys-file.sps], [dnl
705 SYSFILE INFO FILE='sys-file.sav'.
706 ])
707   AT_CHECK([pspp -o pspp.csv sys-file.sps])
708   AT_CHECK([sed 8q pspp.csv], [0], [dnl
709 Table: File Information
710 File,sys-file.sav
711 Label,"PSPP synthetic
712 test file"
713 Created,01 Jan 11 20:53:52 by $(@%:@) SPSS DATA FILE PSPP synthetic test file
714 Product,"Extra product info
715 another line
716 blah"
717 ])
718 done
719 AT_CLEANUP
720
721 AT_SETUP([variable display parameters, without width])
722 AT_KEYWORDS([sack synthetic system file positive])
723 AT_DATA([sys-file.sack], [dnl
724 dnl File header.
725 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
726 2; dnl Layout code
727 19; dnl Nominal case size
728 0; dnl Not compressed
729 0; dnl Not weighted
730 0; dnl No cases.
731 100.0; dnl Bias.
732 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
733 i8 0 *3;
734
735 dnl Numeric variables.
736 2; 0; 0; 0; 0x050800 *2; s8 "A";
737 2; 0; 0; 0; 0x050800 *2; s8 "B";
738 2; 0; 0; 0; 0x050800 *2; s8 "C";
739 2; 0; 0; 0; 0x050800 *2; s8 "D";
740
741 dnl Short string variables.
742 2; 3; 0; 0; 0x010300 *2; s8 "H";
743 2; 3; 0; 0; 0x010300 *2; s8 "I";
744 2; 3; 0; 0; 0x010300 *2; s8 "J";
745 2; 3; 0; 0; 0x010300 *2; s8 "K";
746
747 dnl Long string variables.
748 2; 9; 0; 0; 0x010900 *2; s8 "L";
749 2; -1; 0; 0; 0; 0; s8 "";
750 2; 10; 0; 0; 0x010a00 *2; s8 "M";
751 2; -1; 0; 0; 0; 0; s8 "";
752 2; 17; 0; 0; 0x011100 *2; s8 "N";
753 ( 2; -1; 0; 0; 0; 0; s8 "" ) * 2;
754 2; 25; 0; 0; 0x011900 *2; s8 "O";
755 ( 2; -1; 0; 0; 0; 0; s8 "" ) * 3;
756
757 dnl Variable display parameters
758 7; 11; 4; 24;
759 1; 0;
760 2; 0;
761 3; 0;
762 1; 1;
763 2; 1;
764 3; 1;
765 1; 2;
766 2; 2;
767 3; 2;
768 0; 0;
769 0; 1;
770 0; 2;
771
772 dnl Character encoding record.
773 7; 20; 1; 12; "windows-1252";
774
775 dnl Dictionary termination record.
776 999; 0;
777 ])
778 for variant in be le; do
779   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
780   AT_DATA([sys-file.sps], [dnl
781 GET FILE='sys-file.sav'.
782 DISPLAY DICTIONARY.
783 ])
784   AT_CHECK([pspp -o pspp.csv sys-file.sps])
785   AT_CHECK([cat pspp.csv], [0], [dnl
786 Table: Variables
787 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
788 a,1,Nominal,Input,8,Left,F8.0,F8.0
789 b,2,Ordinal,Input,8,Left,F8.0,F8.0
790 c,3,Scale,Input,8,Left,F8.0,F8.0
791 d,4,Nominal,Input,8,Right,F8.0,F8.0
792 h,5,Ordinal,Input,3,Right,A3,A3
793 i,6,Scale,Input,3,Right,A3,A3
794 j,7,Nominal,Input,3,Center,A3,A3
795 k,8,Ordinal,Input,3,Center,A3,A3
796 l,9,Scale,Input,9,Center,A9,A9
797 m,10,Nominal,Input,10,Left,A10,A10
798 n,11,Nominal,Input,17,Right,A17,A17
799 o,12,Nominal,Input,25,Center,A25,A25
800 ])
801 done
802 AT_CLEANUP
803
804 AT_SETUP([variable display parameters, with width])
805 AT_KEYWORDS([sack synthetic system file positive])
806 AT_DATA([sys-file.sack], [dnl
807 dnl File header.
808 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
809 2; dnl Layout code
810 19; dnl Nominal case size
811 0; dnl Not compressed
812 0; dnl Not weighted
813 0; dnl No cases.
814 100.0; dnl Bias.
815 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
816 i8 0 *3;
817
818 dnl Numeric variables.
819 2; 0; 0; 0; 0x050800 *2; s8 "A";
820 2; 0; 0; 0; 0x050800 *2; s8 "B";
821 2; 0; 0; 0; 0x050800 *2; s8 "C";
822 2; 0; 0; 0; 0x050800 *2; s8 "D";
823
824 dnl Short string variables.
825 2; 3; 0; 0; 0x010300 *2; s8 "H";
826 2; 3; 0; 0; 0x010300 *2; s8 "I";
827 2; 3; 0; 0; 0x010300 *2; s8 "J";
828 2; 3; 0; 0; 0x010300 *2; s8 "K";
829
830 dnl Long string variables.
831 2; 9; 0; 0; 0x010900 *2; s8 "L";
832 2; -1; 0; 0; 0; 0; s8 "";
833 2; 10; 0; 0; 0x010a00 *2; s8 "M";
834 2; -1; 0; 0; 0; 0; s8 "";
835 2; 17; 0; 0; 0x011100 *2; s8 "N";
836 ( 2; -1; 0; 0; 0; 0; s8 "" ) * 2;
837 2; 25; 0; 0; 0x011900 *2; s8 "O";
838 ( 2; -1; 0; 0; 0; 0; s8 "" ) * 3;
839
840 dnl Variable display parameters
841 7; 11; 4; 36;
842 1; 1; 0;
843 2; 2; 0;
844 3; 3; 0;
845 1; 4; 1;
846 2; 5; 1;
847 3; 6; 1;
848 1; 7; 2;
849 2; 8; 2;
850 3; 9; 2;
851 0; 10; 0;
852 0; 11; 1;
853 0; 12; 2;
854
855 dnl Character encoding record.
856 7; 20; 1; 12; "windows-1252";
857
858 dnl Dictionary termination record.
859 999; 0;
860 ])
861 for variant in be le; do
862   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
863   AT_DATA([sys-file.sps], [dnl
864 GET FILE='sys-file.sav'.
865 DISPLAY DICTIONARY.
866 ])
867   AT_CHECK([pspp -o pspp.csv sys-file.sps])
868   AT_CHECK([cat pspp.csv], [0], [dnl
869 Table: Variables
870 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
871 a,1,Nominal,Input,1,Left,F8.0,F8.0
872 b,2,Ordinal,Input,2,Left,F8.0,F8.0
873 c,3,Scale,Input,3,Left,F8.0,F8.0
874 d,4,Nominal,Input,4,Right,F8.0,F8.0
875 h,5,Ordinal,Input,5,Right,A3,A3
876 i,6,Scale,Input,6,Right,A3,A3
877 j,7,Nominal,Input,7,Center,A3,A3
878 k,8,Ordinal,Input,8,Center,A3,A3
879 l,9,Scale,Input,9,Center,A9,A9
880 m,10,Nominal,Input,10,Left,A10,A10
881 n,11,Nominal,Input,11,Right,A17,A17
882 o,12,Nominal,Input,12,Center,A25,A25
883 ])
884 done
885 AT_CLEANUP
886
887 AT_SETUP([long variable names])
888 AT_KEYWORDS([sack synthetic system file positive])
889 AT_DATA([sys-file.sack], [dnl
890 dnl File header.
891 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
892 2; dnl Layout code
893 7; dnl Nominal case size
894 0; dnl Not compressed
895 0; dnl Not weighted
896 0; dnl No cases.
897 100.0; dnl Bias.
898 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
899 i8 0 *3;
900
901 dnl Numeric variables.
902 2; 0; 0; 0; 0x050800 *2; s8 "LONGVARI";
903 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_A";
904 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_B";
905 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_C";
906 2; 0; 0; 0; 0x050800 *2; "CO"; i8 214; "RDINA";
907 2; 0; 0; 0; 0x050800 *2; "CO"; i8 214; "RDI_A";
908 2; 0; 0; 0; 0x050800 *2; "CO"; i8 214; "RDI_B";
909
910 dnl Machine integer info record.
911 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
912
913 dnl Machine floating-point info record.
914 7; 4; 8; 3; SYSMIS; HIGHEST; LOWEST;
915
916 dnl Long variable names.
917 7; 13; 1; COUNT (
918 "LONGVARI=LongVariableName1"; i8 9;
919 "LONGVA_A=LongVariableName2"; i8 9;
920 "LONGVA_B=LongVariableName3"; i8 9;
921 "LONGVA_C=LongVariableName4"; i8 9;
922 "CO"; i8 214; "RDINA=Co"; i8 246; "rdinate_X"; i8 9;
923 "CO"; i8 214; "RDI_A=Co"; i8 246; "rdinate_Y"; i8 9;
924 "CO"; i8 214; "RDI_B=Co"; i8 246; "rdinate_Z";
925 );
926
927 dnl Character encoding record.
928 7; 20; 1; 12; "windows-1252";
929
930 dnl Dictionary termination record.
931 999; 0;
932 ])
933 for variant in be le; do
934   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
935   AT_DATA([sys-file.sps], [dnl
936 GET FILE='sys-file.sav'.
937 DISPLAY DICTIONARY.
938 ])
939   AT_CHECK([pspp -o pspp.csv sys-file.sps])
940   AT_CHECK([cat pspp.csv], [0], [dnl
941 Table: Variables
942 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
943 LongVariableName1,1,Unknown,Input,8,Right,F8.0,F8.0
944 LongVariableName2,2,Unknown,Input,8,Right,F8.0,F8.0
945 LongVariableName3,3,Unknown,Input,8,Right,F8.0,F8.0
946 LongVariableName4,4,Unknown,Input,8,Right,F8.0,F8.0
947 Coördinate_X,5,Unknown,Input,8,Right,F8.0,F8.0
948 Coördinate_Y,6,Unknown,Input,8,Right,F8.0,F8.0
949 Coördinate_Z,7,Unknown,Input,8,Right,F8.0,F8.0
950 ])
951 done
952 AT_CLEANUP
953
954 AT_SETUP([very long strings])
955 AT_KEYWORDS([sack synthetic system file positive])
956 AT_DATA([sys-file.sack], [dnl
957 dnl File header.
958 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
959 2; dnl Layout code
960 109; dnl Nominal case size
961 0; dnl Not compressed
962 0; dnl Not weighted
963 1; dnl No cases.
964 100.0; dnl Bias.
965 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
966 i8 0 *3;
967
968 dnl 256-byte string.
969 2; 255; 0; 0; 0x01FF00 *2; "S"; i8 201; s6 "Q256";
970 (2; -1; 0; 0; 0; 0; s8 "") * 31;
971 2; 4; 0; 0; 0x010400 *2; "S"; i8 201; "Q256_1";
972
973 dnl 600-byte string.
974 2; 255; 0; 0; 0x01FF00 *2; s8 "STR600";
975 (2; -1; 0; 0; 0; 0; s8 "") * 31;
976 2; 255; 0; 0; 0x01FF00 *2; s8 "STR600_1";
977 (2; -1; 0; 0; 0; 0; s8 "") * 31;
978 2; 96; 0; 0; 0x016000 *2; s8 "STR600_2";
979 (2; -1; 0; 0; 0; 0; s8 "") * 11;
980
981 dnl Machine integer info record.
982 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
983
984 dnl Very long string record.
985 7; 14; 1; COUNT (
986 "S"; i8 201; "Q256=00256"; i8 0; i8 9;
987 "STR600=00600"; i8 0; i8 9;
988 );
989
990 dnl Character encoding record.
991 7; 20; 1; 12; "windows-1252";
992
993 dnl Dictionary termination record.
994 999; 0;
995
996 dnl Data.
997 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#" * 4;
998 "abcdefgh";
999 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#" * 9;
1000 "abcdefghijklmnopqrstuvwxyzABCDEF";
1001 ])
1002 for variant in be le; do
1003   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1004   AT_DATA([sys-file.sps], [dnl
1005 GET FILE='sys-file.sav'.
1006 DISPLAY DICTIONARY.
1007 LIST.
1008 ])
1009   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1010   AT_CHECK([cat pspp.csv], [0], [dnl
1011 Table: Variables
1012 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
1013 séq256,1,Nominal,Input,32,Left,A256,A256
1014 str600,2,Nominal,Input,32,Left,A600,A600
1015
1016 Table: Data List
1017 séq256,str600
1018 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@a,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyz
1019 ])
1020 done
1021 AT_CLEANUP
1022
1023 AT_SETUP([data file and variable attributes])
1024 AT_KEYWORDS([sack synthetic system file positive])
1025 AT_DATA([sys-file.sack], [dnl
1026 dnl File header.
1027 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1028 2; dnl Layout code
1029 3; dnl Nominal case size
1030 0; dnl Not compressed
1031 0; dnl Not weighted
1032 0; dnl 1 case.
1033 100.0; dnl Bias.
1034 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1035 i8 0 *3;
1036
1037 dnl Variables.
1038 2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
1039 2; 0; 0; 0; 0x050800 *2; s8 "SECONDVA";
1040 2; 0; 0; 0; 0x050800 *2; s8 "THIRDVAR";
1041
1042 dnl Machine integer info record.
1043 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
1044
1045 dnl Long variable names.
1046 7; 13; 1; COUNT (
1047 "FIRSTVAR=FirstVariable"; i8 9;
1048 "SECONDVA=S"; i8 233; "condVariable"; i8 9;
1049 "THIRDVAR=ThirdVariable"; i8 9
1050 );
1051
1052 dnl Data file attributes record.
1053 7; 17; 1; COUNT (
1054 "Attr1('Value1'"; i8 10; "''d"; i8 233; "claration''"; i8 10; ")";
1055 "S"; i8 233; "condAttr('123'"; i8 10; "'456'"; i8 10; ")";
1056 );
1057
1058 dnl Variable attributes record.
1059 7; 18; 1; COUNT (
1060 "FirstVariable:";
1061   "ad"; i8 232; "le('23'"; i8 10; "'34'"; i8 10; ")";
1062   "bert('123'"; i8 10; ")";
1063   "$@Role('1'"; i8 10; ")";
1064 "/S"; i8 233; "condVariable:";
1065   "xyzzy('quux'"; i8 10; ")";
1066 );
1067
1068 dnl Another variable attributes record.
1069 dnl Only system files written by "Stata 14.1/-savespss- 1.77 by S.Radyakin"
1070 dnl include multiple variable attributes records.
1071 7; 18; 1; COUNT ("ThirdVariable:fizz('buzz'"; i8 10; ")";);
1072
1073 dnl Character encoding record.
1074 7; 20; 1; 12; "windows-1252";
1075
1076 dnl Dictionary termination record.
1077 999; 0;
1078 ])
1079 for variant in be le; do
1080   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1081   AT_DATA([sys-file.sps], [dnl
1082 GET FILE='sys-file.sav'.
1083 DISPLAY @ATTRIBUTES.
1084 ])
1085   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1086   AT_CHECK([cat pspp.csv], [0],
1087 [[Table: Variable and Dataset Attributes
1088 Variable and Name,,Value
1089 (dataset),Attr1[1],Value1
1090 ,Attr1[2],'déclaration'
1091 ,SécondAttr[1],123
1092 ,SécondAttr[2],456
1093 FirstVariable,$@Role,1
1094 ,adèle[1],23
1095 ,adèle[2],34
1096 ,bert,123
1097 SécondVariable,xyzzy,quux
1098 ThirdVariable,fizz,buzz
1099 ]])
1100   AT_DATA([sys-file.sps], [dnl
1101 GET FILE='sys-file.sav'.
1102 DISPLAY DICTIONARY.
1103 ])
1104   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1105   AT_CHECK([cat pspp.csv], [0],
1106 [[Table: Variables
1107 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
1108 FirstVariable,1,Unknown,Output,8,Right,F8.0,F8.0
1109 SécondVariable,2,Unknown,Input,8,Right,F8.0,F8.0
1110 ThirdVariable,3,Unknown,Input,8,Right,F8.0,F8.0
1111 ]])
1112 done
1113 AT_CLEANUP
1114
1115 AT_SETUP([variable roles])
1116 AT_KEYWORDS([sack synthetic system file positive])
1117 AT_DATA([sys-file.sack], [dnl
1118 dnl File header.
1119 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1120 2; dnl Layout code
1121 7; dnl Nominal case size
1122 0; dnl Not compressed
1123 0; dnl Not weighted
1124 0; dnl 1 case.
1125 100.0; dnl Bias.
1126 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1127 i8 0 *3;
1128
1129 dnl Variables.
1130 2; 0; 0; 0; 0x050800 *2; s8 "I";
1131 2; 0; 0; 0; 0x050800 *2; s8 "O";
1132 2; 0; 0; 0; 0x050800 *2; s8 "B";
1133 2; 0; 0; 0; 0x050800 *2; s8 "N";
1134 2; 0; 0; 0; 0x050800 *2; s8 "P";
1135 2; 0; 0; 0; 0x050800 *2; s8 "S";
1136 2; 0; 0; 0; 0x050800 *2; s8 "X";
1137
1138 dnl Machine integer info record.
1139 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
1140
1141 dnl Variable attributes record.
1142 7; 18; 1; COUNT (
1143 "I:$@Role('0'"; i8 10; ")";
1144 "/O:$@Role('1'"; i8 10; ")";
1145 "/B:$@Role('2'"; i8 10; ")";
1146 "/N:$@Role('3'"; i8 10; ")";
1147 "/P:$@Role('4'"; i8 10; ")";
1148 "/S:$@Role('5'"; i8 10; ")";
1149 "/X:$@Role('6'"; i8 10; ")";
1150 );
1151
1152 dnl Character encoding record.
1153 7; 20; 1; 12; "windows-1252";
1154
1155 dnl Dictionary termination record.
1156 999; 0;
1157 ])
1158 for variant in be le; do
1159   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1160   AT_DATA([sys-file.sps], [dnl
1161 GET FILE='sys-file.sav'.
1162 DISPLAY DICTIONARY.
1163 ])
1164   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], [dnl
1165 warning: `sys-file.sav': Invalid role for variable x.
1166 ])
1167   AT_CHECK([cat pspp.csv], [0], [dnl
1168 warning: `sys-file.sav': Invalid role for variable x.
1169
1170 Table: Variables
1171 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
1172 i,1,Unknown,Input,8,Right,F8.0,F8.0
1173 o,2,Unknown,Output,8,Right,F8.0,F8.0
1174 b,3,Unknown,Both,8,Right,F8.0,F8.0
1175 n,4,Unknown,None,8,Right,F8.0,F8.0
1176 p,5,Unknown,Partition,8,Right,F8.0,F8.0
1177 s,6,Unknown,Split,8,Right,F8.0,F8.0
1178 x,7,Unknown,Input,8,Right,F8.0,F8.0
1179 ])
1180 done
1181 AT_CLEANUP
1182
1183 AT_SETUP([compressed data])
1184 AT_KEYWORDS([sack synthetic system file positive])
1185 AT_DATA([sys-file.sack], [dnl
1186 dnl File header.
1187 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1188 2; dnl Layout code
1189 6; dnl Nominal case size
1190 1; dnl Simple compression
1191 0; dnl Not weighted
1192 -1; dnl Unspecified number of cases.
1193 100.0; dnl Bias.
1194 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1195 i8 0 *3;
1196
1197 dnl Numeric variables.
1198 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1199 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
1200
1201 dnl String variable.
1202 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
1203 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
1204 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
1205 2; -1; 0; 0; 0; 0; s8 "";
1206
1207 dnl Character encoding record.
1208 7; 20; 1; 12; "windows-1252";
1209
1210 dnl Dictionary termination record.
1211 999; 0;
1212
1213 dnl Compressed data.
1214 i8 1 100 254 253 254 253; i8 255 251; "abcdefgh"; s8 "0123";
1215 i8 253 253 253 254; i8 101 102 253 253; s8 "jklm"; s8 "nopqrstu";
1216 s8 "vwxyzABC"; s8 "DEFG"; s8 "HIJKLMNO";
1217 i8 254 253 252 0 0 0 0 0; s8 "PQRSTUVW";
1218
1219 ])
1220 for variant in be le; do
1221   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1222   AT_DATA([sys-file.sps], [dnl
1223 GET FILE='sys-file.sav'.
1224 DISPLAY DICTIONARY.
1225 LIST.
1226 ])
1227   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1228   AT_CHECK([cat pspp.csv], [0], [dnl
1229 Table: Variables
1230 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
1231 num1,1,Unknown,Input,8,Right,F8.0,F8.0
1232 num2,2,Unknown,Input,8,Right,F8.0,F8.0
1233 str4,3,Nominal,Input,4,Left,A4,A4
1234 str8,4,Nominal,Input,8,Left,A8,A8
1235 str15,5,Nominal,Input,15,Left,A15,A15
1236
1237 Table: Data List
1238 num1,num2,str4,str8,str15
1239 -99,0,,abcdefgh,0123
1240 .,151,jklm,nopqrstu,vwxyzABC
1241 1,2,DEFG,HIJKLMNO,PQRSTUV
1242 ])
1243 done
1244 AT_CLEANUP
1245
1246 AT_SETUP([compressed data, zero bias])
1247 AT_KEYWORDS([sack synthetic system file positive])
1248 AT_DATA([sys-file.sack], [dnl
1249 dnl File header.
1250 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1251 2; dnl Layout code
1252 6; dnl Nominal case size
1253 1; dnl Simple compression.
1254 0; dnl Not weighted
1255 -1; dnl Unspecified number of cases.
1256 0.0; dnl Bias.
1257 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1258 i8 0 *3;
1259
1260 dnl Numeric variables.
1261 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1262 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
1263
1264 dnl String variable.
1265 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
1266 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
1267 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
1268 2; -1; 0; 0; 0; 0; s8 "";
1269
1270 dnl Character encoding record.
1271 7; 20; 1; 12; "windows-1252";
1272
1273 dnl Dictionary termination record.
1274 999; 0;
1275
1276 dnl Compressed data.
1277 i8 1 100 254 253 254 253; i8 255 251; "abcdefgh"; s8 "0123";
1278 i8 253 253 253 254; i8 101 102 253 253; s8 "jklm"; s8 "nopqrstu";
1279 s8 "vwxyzABC"; s8 "DEFG"; s8 "HIJKLMNO";
1280 i8 254 253 252 0 0 0 0 0; s8 "PQRSTUVW";
1281
1282 ])
1283 for variant in be le; do
1284   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1285   AT_DATA([sys-file.sps], [dnl
1286 GET FILE='sys-file.sav'.
1287 DISPLAY DICTIONARY.
1288 LIST.
1289 ])
1290   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0])
1291   AT_CHECK([cat pspp.csv], [0], [dnl
1292 Table: Variables
1293 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
1294 num1,1,Unknown,Input,8,Right,F8.0,F8.0
1295 num2,2,Unknown,Input,8,Right,F8.0,F8.0
1296 str4,3,Nominal,Input,4,Left,A4,A4
1297 str8,4,Nominal,Input,8,Left,A8,A8
1298 str15,5,Nominal,Input,15,Left,A15,A15
1299
1300 Table: Data List
1301 num1,num2,str4,str8,str15
1302 1,100,,abcdefgh,0123
1303 .,251,jklm,nopqrstu,vwxyzABC
1304 101,102,DEFG,HIJKLMNO,PQRSTUV
1305 ])
1306 done
1307 AT_CLEANUP
1308
1309 AT_SETUP([compressed data, other bias])
1310 AT_KEYWORDS([sack synthetic system file positive])
1311 AT_DATA([sys-file.sack], [dnl
1312 dnl File header.
1313 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1314 2; dnl Layout code
1315 6; dnl Nominal case size
1316 1; dnl Simple compression.
1317 0; dnl Not weighted
1318 -1; dnl Unspecified number of cases.
1319 50.0; dnl Bias.
1320 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1321 i8 0 *3;
1322
1323 dnl Numeric variables.
1324 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1325 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
1326
1327 dnl String variable.
1328 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
1329 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
1330 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
1331 2; -1; 0; 0; 0; 0; s8 "";
1332
1333 dnl Character encoding record.
1334 7; 20; 1; 12; "windows-1252";
1335
1336 dnl Dictionary termination record.
1337 999; 0;
1338
1339 dnl Compressed data.
1340 i8 1 100 254 253 254 253; i8 255 251; "abcdefgh"; s8 "0123";
1341 i8 253 253 253 254; i8 101 102 253 253; s8 "jklm"; s8 "nopqrstu";
1342 s8 "vwxyzABC"; s8 "DEFG"; s8 "HIJKLMNO";
1343 i8 254 253 252 0 0 0 0 0; s8 "PQRSTUVW";
1344
1345 ])
1346 for variant in be le; do
1347   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1348   AT_DATA([sys-file.sps], [dnl
1349 GET FILE='sys-file.sav'.
1350 DISPLAY DICTIONARY.
1351 LIST.
1352 ])
1353   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0],
1354     [warning: `sys-file.sav' near offset 0x54: Compression bias is not the usual value of 100, or system file uses unrecognized floating-point format.
1355 ])
1356   AT_CHECK([cat pspp.csv], [0], [dnl
1357 "warning: `sys-file.sav' near offset 0x54: Compression bias is not the usual value of 100, or system file uses unrecognized floating-point format."
1358
1359 Table: Variables
1360 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
1361 num1,1,Unknown,Input,8,Right,F8.0,F8.0
1362 num2,2,Unknown,Input,8,Right,F8.0,F8.0
1363 str4,3,Nominal,Input,4,Left,A4,A4
1364 str8,4,Nominal,Input,8,Left,A8,A8
1365 str15,5,Nominal,Input,15,Left,A15,A15
1366
1367 Table: Data List
1368 num1,num2,str4,str8,str15
1369 -49,50,,abcdefgh,0123
1370 .,201,jklm,nopqrstu,vwxyzABC
1371 51,52,DEFG,HIJKLMNO,PQRSTUV
1372 ])
1373 done
1374 AT_CLEANUP
1375
1376 m4_divert_push([PREPARE_TESTS])
1377 zcompressed_sack () {
1378     cat <<'EOF'
1379 dnl File header.
1380 "$FL3"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1381 2; dnl Layout code
1382 6; dnl Nominal case size
1383 2; dnl zlib compressed
1384 0; dnl Not weighted
1385 -1; dnl Unspecified number of cases.
1386 100.0; dnl Bias.
1387 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1388 i8 0 *3;
1389
1390 dnl Numeric variables.
1391 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1392 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
1393
1394 dnl String variable.
1395 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
1396 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
1397 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
1398 2; -1; 0; 0; 0; 0; s8 "";
1399
1400 dnl Character encoding record.
1401 7; 20; 1; 12; "windows-1252";
1402
1403 dnl Dictionary termination record.
1404 999; 0;
1405
1406 dnl ZLIB data header.
1407 i64 0x194;    # zheader_ofs
1408 i64 0x205;    # ztrailer_ofs
1409 i64 48;       # ztrailer_len
1410
1411 dnl ZLIB data block.
1412 dnl
1413 dnl This is the compressed form of:
1414 dnl
1415 dnl 01 64 fe fd fe fd ff fb  61 62 63 64 65 66 67 68  |.d......abcdefgh|
1416 dnl 30 31 32 33 20 20 20 20  fd fd fd fe 65 66 fd fd  |0123    ....ef..|
1417 dnl 6a 6b 6c 6d 20 20 20 20  6e 6f 70 71 72 73 74 75  |jklm    nopqrstu|
1418 dnl 76 77 78 79 7a 41 42 43  44 45 46 47 20 20 20 20  |vwxyzABCDEFG    |
1419 dnl 48 49 4a 4b 4c 4d 4e 4f  fe fd fc 00 00 00 00 00  |HIJKLMNO........|
1420 dnl 50 51 52 53 54 55 56 57                           |PQRSTUVW|
1421 dnl
1422 dnl which is the data from the "compressed data" test.
1423 hex "78 01 63 4c f9 f7 f7 df  df ff bf 13 93 92 53 52";
1424 hex "d3 d2 33 0c 0c 8d 8c 15  80 e0 ef df bf ff 52 d3";
1425 hex "fe fe cd ca ce c9 05 f1  f3 f2 0b 0a 8b 8a 4b 4a";
1426 hex "cb ca 2b 2a ab 1c 9d 9c  5d 5c dd dc 41 e2 1e 9e";
1427 hex "5e de 3e be 7e fe ff fe  fe 61 00 81 80 c0 a0 e0";
1428 hex "90 d0 b0 70 00 0f 3f 23  d7";
1429
1430 dnl ZLIB data trailer fixed header:
1431 i64 -100;     # ztrailer_bias
1432 i64 0;        # ztrailer_zero
1433 0x3ff000;     # block_size
1434 1;            # n_blocks
1435
1436 dnl ZLIB block descriptor:
1437 i64 0x194;    # uncompressed_ofs
1438 i64 0x1ac;    # compressed_ofs
1439 88;           # uncompressed_size
1440 89;           # compressed_size
1441 EOF
1442 }
1443 m4_divert_pop([PREPARE_TESTS])
1444
1445 AT_SETUP([zcompressed data])
1446 AT_KEYWORDS([sack synthetic system file positive zlib])
1447 zcompressed_sack > sys-file.sack
1448 for variant in be le; do
1449   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1450   AT_DATA([sys-file.sps], [dnl
1451 GET FILE='sys-file.sav'.
1452 DISPLAY DICTIONARY.
1453 LIST.
1454 ])
1455   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1456   AT_CHECK([cat pspp.csv], [0], [dnl
1457 Table: Variables
1458 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
1459 num1,1,Unknown,Input,8,Right,F8.0,F8.0
1460 num2,2,Unknown,Input,8,Right,F8.0,F8.0
1461 str4,3,Nominal,Input,4,Left,A4,A4
1462 str8,4,Nominal,Input,8,Left,A8,A8
1463 str15,5,Nominal,Input,15,Left,A15,A15
1464
1465 Table: Data List
1466 num1,num2,str4,str8,str15
1467 -99,0,,abcdefgh,0123
1468 .,151,jklm,nopqrstu,vwxyzABC
1469 1,2,DEFG,HIJKLMNO,PQRSTUV
1470 ])
1471 done
1472 AT_CLEANUP
1473 \f
1474 AT_BANNER([system file reader - negative])
1475
1476 AT_SETUP([no variables])
1477 AT_KEYWORDS([sack synthetic system file negative])
1478 AT_DATA([sys-file.sack], [dnl
1479 dnl File header.
1480 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1481 2; dnl Layout code
1482 0; dnl Nominal case size (empty)
1483 0; dnl Not compressed
1484 0; dnl Not weighted
1485 0; dnl 0 cases.
1486 100.0; dnl Bias.
1487 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1488 i8 0 *3;
1489
1490 dnl Character encoding record.
1491 7; 20; 1; 12; "windows-1252";
1492
1493 dnl Dictionary termination record.
1494 999; 0;
1495 ])
1496 for variant in be le; do
1497   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1498   AT_DATA([sys-file.sps], [dnl
1499 GET FILE='sys-file.sav'.
1500 ])
1501   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
1502 sys-file.sps:1: error: GET: `sys-file.sav': Data file dictionary has no variables.
1503 ])
1504
1505   dnl At one point pspp-convert would hang forever if there were no variables,
1506   dnl so check against regression.
1507   AT_CHECK([pspp-convert sys-file.sav sys-file.txt])
1508   AT_CHECK([cat sys-file.txt], [0], [
1509 ])
1510 done
1511 AT_CLEANUP
1512
1513 AT_SETUP([unspecified character encoding])
1514 AT_KEYWORDS([sack synthetic system file positive])
1515 AT_DATA([sys-file.sack], [dnl
1516 dnl File header.
1517 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1518 2; dnl Layout code
1519 4; dnl Nominal case size
1520 0; dnl Not compressed
1521 0; dnl Not weighted
1522 0; dnl No cases.
1523 100.0; dnl Bias.
1524 "01 Jan 11"; "20:53:52";
1525 "PSPP synthetic test file: "; i8 244; i8 245; i8 246; i8 248; s34 "";
1526 i8 0 *3;
1527
1528 dnl Numeric variables.
1529 2; 0; 0; 0; 0x050800 *2; s8 "A";
1530 2; 0; 0; 0; 0x050800 *2; s8 "B";
1531 2; 0; 0; 0; 0x050800 *2; s8 "C";
1532 2; 0; 0; 0; 0x050800 *2; s8 "D";
1533
1534 dnl Dictionary termination record.
1535 999; 0;
1536 ])
1537 for variant in be le; do
1538   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1539   AT_DATA([sys-file.sps], [dnl
1540 GET 'sys-file.sav'.
1541 ])
1542   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [stdout])
1543   AT_CHECK([sed 's/default encoding.*For/default encoding.  For/' stdout], [0], [dnl
1544 "warning: `sys-file.sav': This system file does not indicate its own character encoding.  Using default encoding.  For best results, specify an encoding explicitly.  Use SYSFILE INFO with ENCODING=""DETECT"" to analyze the possible encodings."
1545 ])
1546 done
1547 AT_CLEANUP
1548
1549 AT_SETUP([misplaced type 4 record])
1550 AT_KEYWORDS([sack synthetic system file negative])
1551 AT_DATA([sys-file.sack], [dnl
1552 dnl File header.
1553 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1554 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1555
1556 dnl Numeric variable.
1557 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1558
1559 dnl Type 4 record.
1560 >>4<<;
1561 ])
1562 for variant in be le; do
1563   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1564   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1565 ])
1566   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
1567    [error: `sys-file.sav' near offset 0xd4: Misplaced type 4 record.
1568 ])
1569 done
1570 AT_CLEANUP
1571
1572 AT_SETUP([bad record type])
1573 AT_KEYWORDS([sack synthetic system file negative])
1574 AT_DATA([sys-file.sack], [dnl
1575 dnl File header.
1576 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1577 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1578
1579 dnl Numeric variable.
1580 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1581
1582 dnl Type 8 record (not a valid type).
1583 >>8<<;
1584 ])
1585 for variant in be le; do
1586   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1587   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1588 ])
1589   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
1590    [error: `sys-file.sav' near offset 0xd4: Unrecognized record type 8.
1591 ])
1592 done
1593 AT_CLEANUP
1594
1595 AT_SETUP([wrong number of variable positions])
1596 AT_KEYWORDS([sack synthetic system file negative])
1597 AT_DATA([sys-file.sack], [dnl
1598 dnl File header.
1599 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1600 2; >>2<<; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1601
1602 dnl Numeric variable.
1603 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1604
1605 dnl Character encoding record.
1606 7; 20; 1; 12; "windows-1252";
1607
1608 dnl End of dictionary.
1609 999; 0;
1610 ])
1611 for variant in be le; do
1612   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1613   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1614 ])
1615   AT_CHECK([pspp -O format=csv sys-file.sps], [0],
1616    [warning: `sys-file.sav': File header claims 2 variable positions but 1 were read from file.
1617 ])
1618 done
1619 AT_CLEANUP
1620
1621 AT_SETUP([variable name may not begin with `#'])
1622 AT_KEYWORDS([sack synthetic system file negative])
1623 AT_DATA([sys-file.sack], [dnl
1624 dnl File header.
1625 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1626 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1627
1628 dnl Numeric variable.
1629 2; 0; 0; 0; 0x050800 *2; s8 >>"$UM1"<<;
1630
1631 dnl Character encoding record.
1632 7; 20; 1; 12; "windows-1252";
1633
1634 dnl End of dictionary.
1635 999; 0;
1636 ])
1637 for variant in be le; do
1638   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1639   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1640 ])
1641   AT_CHECK([pspp -O format=csv sys-file.sps], 0,
1642    [warning: `sys-file.sav' near offset 0xb4: Renaming variable with invalid name `$UM1' to `VAR001'.
1643 ])
1644 done
1645 AT_CLEANUP
1646
1647 AT_SETUP([variable name may not be reserved word])
1648 AT_KEYWORDS([sack synthetic system file negative])
1649 AT_DATA([sys-file.sack], [dnl
1650 dnl File header.
1651 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1652 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1653
1654 dnl Numeric variable.
1655 2; 0; 0; 0; 0x050800 *2; s8 >>"TO"<<;
1656
1657 dnl Character encoding record.
1658 7; 20; 1; 12; "windows-1252";
1659
1660 dnl End of dictionary.
1661 999; 0;
1662 ])
1663 for variant in be le; do
1664   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1665   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1666 ])
1667   AT_CHECK([pspp -O format=csv sys-file.sps], 0,
1668    [warning: `sys-file.sav' near offset 0xb4: Renaming variable with invalid name `TO' to `VAR001'.
1669 ])
1670 done
1671 AT_CLEANUP
1672
1673 AT_SETUP([variable width must be between 0 and 255])
1674 AT_KEYWORDS([sack synthetic system file negative])
1675 AT_DATA([sys-file.sack], [dnl
1676 dnl File header.
1677 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1678 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1679
1680 dnl String variable with invalid width 256.
1681 2; 256; 0; 0; 0x050800 *2; s8 "VAR1";
1682
1683 dnl Character encoding record.
1684 7; 20; 1; 12; "windows-1252";
1685
1686 dnl End of dictionary.
1687 999; 0;
1688 ])
1689 for variant in be le; do
1690   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1691   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1692 ])
1693   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
1694    [error: `sys-file.sav' near offset 0xb4: Bad width 256 for variable VAR1.
1695 ])
1696 done
1697 AT_CLEANUP
1698
1699 dnl SPSS-generated system file can contain duplicate variable names
1700 dnl (see bug #41475).
1701 AT_SETUP([duplicate variable name])
1702 AT_KEYWORDS([sack synthetic system file negative])
1703 AT_DATA([sys-file.sack], [dnl
1704 dnl File header.
1705 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1706 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1707
1708 dnl Numeric variables.
1709 2; 0; 0; 0; 0x050800 *2; s8 "VAR1";
1710 2; 0; 0; 0; 0x050800 *2; s8 "VAR1";
1711
1712 dnl Character encoding record.
1713 7; 20; 1; 12; "windows-1252";
1714
1715 dnl End of dictionary.
1716 999; 0;
1717 ])
1718 for variant in be le; do
1719   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1720   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1721 DISPLAY DICTIONARY.
1722 ])
1723   AT_CHECK([pspp -O format=csv sys-file.sps], [0],
1724    [warning: `sys-file.sav' near offset 0xd4: Renaming variable with duplicate name `VAR1' to `VAR001'.
1725
1726 Table: Variables
1727 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
1728 var1,1,Unknown,Input,8,Right,F8.0,F8.0
1729 var001,2,Unknown,Input,8,Right,F8.0,F8.0
1730 ])
1731 done
1732 AT_CLEANUP
1733
1734 AT_SETUP([variable label indicator not 0 or 1])
1735 AT_KEYWORDS([sack synthetic system file negative])
1736 AT_DATA([sys-file.sack], [dnl
1737 dnl File header.
1738 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1739 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1740
1741 dnl Numeric variable.
1742 2; 0; >>2<<; 0; 0x050800 *2; s8 "VAR1";
1743
1744 dnl Character encoding record.
1745 7; 20; 1; 12; "windows-1252";
1746
1747 dnl End of dictionary.
1748 999; 0;
1749 ])
1750 for variant in be le; do
1751   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1752   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1753 ])
1754   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
1755    [error: `sys-file.sav' near offset 0xb4: Variable label indicator field is not 0 or 1.
1756 ])
1757 done
1758 AT_CLEANUP
1759
1760 AT_SETUP([invalid numeric missing value indicator])
1761 AT_KEYWORDS([sack synthetic system file negative])
1762 AT_DATA([sys-file.sack], [dnl
1763 dnl File header.
1764 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1765 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1766
1767 dnl Numeric variable.
1768 2; 0; 0; >>-1<<; 0x050800 *2; s8 "VAR1";
1769
1770 dnl Character encoding record.
1771 7; 20; 1; 12; "windows-1252";
1772
1773 dnl End of dictionary.
1774 999; 0;
1775 ])
1776 for variant in be le; do
1777   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1778   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1779 ])
1780   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
1781    ["error: `sys-file.sav' near offset 0xb4: Numeric missing value indicator field is not -3, -2, 0, 1, 2, or 3."
1782 ])
1783 done
1784 AT_CLEANUP
1785
1786 AT_SETUP([invalid string missing value indicator])
1787 AT_KEYWORDS([sack synthetic system file negative])
1788 AT_DATA([sys-file.sack], [dnl
1789 dnl File header.
1790 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1791 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1792
1793 dnl String variable.
1794 2; 8; 0; >>4<<; 0x010800 *2; s8 "VAR1";
1795
1796 dnl Character encoding record.
1797 7; 20; 1; 12; "windows-1252";
1798
1799 dnl End of dictionary.
1800 999; 0;
1801 ])
1802 for variant in be le; do
1803   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1804   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1805 ])
1806   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
1807    ["error: `sys-file.sav' near offset 0xb4: String missing value indicator field is not 0, 1, 2, or 3."
1808 ])
1809 done
1810 AT_CLEANUP
1811
1812 AT_SETUP([missing string continuation record])
1813 AT_KEYWORDS([sack synthetic system file negative])
1814 AT_DATA([sys-file.sack], [dnl
1815 dnl File header.
1816 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1817 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1818
1819 dnl String variable.
1820 2; 10; 0; 0; 0x010a00 *2; s8 "VAR1";
1821 >>2; 0; 0; 0; 0x050800 *2; s8 "VAR2";<<
1822
1823 dnl Character encoding record.
1824 7; 20; 1; 12; "windows-1252";
1825
1826 dnl End of dictionary.
1827 999; 0;
1828 ])
1829 for variant in be le; do
1830   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1831   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1832 ])
1833   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
1834    [error: `sys-file.sav' near offset 0xb4: Missing string continuation record.
1835 ])
1836 done
1837 AT_CLEANUP
1838
1839 AT_SETUP([invalid variable format])
1840 AT_KEYWORDS([sack synthetic system file negative])
1841 AT_DATA([sys-file.sack], [dnl
1842 dnl File header.
1843 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1844 2; 4; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1845
1846 dnl Numeric variable, invalid format types.
1847 dnl No warning is issued for type 0 because it has been observed in real
1848 dnl system files.
1849 2; 0; 0; 0; >>0xff0800; 0<<; s8 "NUM1";
1850
1851 dnl Numeric variable, string formats.
1852 2; 0; 0; 0; >>0x010800<<; >>0x021000<<; s8 "VAR1";
1853
1854 dnl String variable, numeric formats.
1855 2; 4; 0; 0; >>0x050800<<; >>0x110a01<<; s8 "STR1";
1856
1857 dnl String variable, wrong width formats.
1858 2; 4; 0; 0; >>0x010800<<; >>0x020400<<; s8 "STR2";
1859
1860 dnl Character encoding record.
1861 7; 20; 1; 12; "windows-1252";
1862
1863 dnl End of dictionary.
1864 999; 0;
1865 ])
1866 for variant in be le; do
1867   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1868   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1869 ])
1870   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
1871 warning: `sys-file.sav' near offset 0xc0: Variable NUM1 with width 0 has invalid print format 0xff0800.
1872
1873 warning: `sys-file.sav' near offset 0xe0: Variable VAR1 with width 0 has invalid print format 0x10800.
1874
1875 warning: `sys-file.sav' near offset 0xe4: Variable VAR1 with width 0 has invalid write format 0x21000.
1876
1877 warning: `sys-file.sav' near offset 0x100: Variable STR1 with width 4 has invalid print format 0x50800.
1878
1879 warning: `sys-file.sav' near offset 0x104: Variable STR1 with width 4 has invalid write format 0x110a01.
1880
1881 warning: `sys-file.sav' near offset 0x120: Variable STR2 with width 4 has invalid print format 0x10800.
1882
1883 warning: `sys-file.sav' near offset 0x124: Variable STR2 with width 4 has invalid write format 0x20400.
1884 ])
1885 done
1886 AT_CLEANUP
1887
1888 AT_SETUP([invalid long string missing values])
1889 AT_KEYWORDS([sack synthetic system file negative])
1890 AT_DATA([sys-file.sack], [dnl
1891 dnl File header.
1892 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1893 2; dnl Layout code
1894 7; dnl Nominal case size
1895 0; dnl Not compressed
1896 0; dnl Not weighted
1897 1; dnl 1 case.
1898 100.0; dnl Bias.
1899 "01 Jan 11"; "20:53:52";
1900 "PSPP synthetic test file: "; i8 244; i8 245; i8 246; i8 248; s34 "";
1901 i8 0 *3;
1902
1903 dnl One numeric variable.
1904 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1905
1906 dnl Long string variables that will have missing values added with a
1907 dnl later record.
1908 2; 9; 0; 0; 0x010900 *2; s8 "STR1";
1909 2; -1; 0; 0; 0; 0; s8 "";
1910 2; 10; 0; 0; 0x010a00 *2; s8 "STR2";
1911 2; -1; 0; 0; 0; 0; s8 "";
1912 2; 11; 0; 0; 0x010b00 *2; s8 "STR3";
1913 2; -1; 0; 0; 0; 0; s8 "";
1914
1915 dnl Machine integer info record.
1916 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
1917
1918 dnl Machine floating-point info record.
1919 7; 4; 8; 3; SYSMIS; HIGHEST; LOWEST;
1920
1921 dnl Long string variable missing values record.
1922 7; 22; 1; COUNT (
1923 dnl Zero missing values (not allowed) for STR1 .
1924 COUNT("STR1"); i8 >>0<<; 8;
1925
1926 dnl Four missing values (not allowed) for STR2.
1927 COUNT("STR2"); i8 4; 8;
1928 "abcdefgh"; "ijklmnop"; "qrstuvwx"; "yz012345";
1929
1930 dnl Missing values for unknown variable
1931 COUNT(>>"Nonexistent"<<); i8 1; 8; "abcdefgh";
1932
1933 dnl Missing values for numeric variable
1934 COUNT(>>"NUM1"<<); i8 1; 8; "abcdefgh";
1935
1936 dnl Too long missing value
1937 COUNT("STR3"); i8 1; >>COUNT("abcdefghijkl")<<;
1938
1939 dnl Buggy way that this was written in old PSPP, with a length
1940 dnl before each missing value instead of just once.
1941 COUNT("STR3"); i8 2; 8; "ABCDEFGH"; >>8<<; "IJKLMNOP";
1942 );
1943
1944 dnl Character encoding record.
1945 7; 20; 1; 12; "windows-1252";
1946
1947 dnl Dictionary termination record.
1948 999; 0;
1949 s8 "abcd"; s8 "efgh"; s8 "ijkl"; s8 "mnop"; s8 "qrst"; s8 "uvwx";
1950 s16 "yzABCDEFGHI"; s16 "JKLMNOPQR"; s16 "STUVWXYZ01";
1951 s16 "23456789abc"; s32 "defghijklmnopqstuvwxyzABC";
1952 ])
1953
1954 for variant in be le; do
1955   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1956   AT_DATA([sys-file.sps], [dnl
1957 GET FILE='sys-file.sav'.
1958 DISPLAY DICTIONARY.
1959 ])
1960   AT_CHECK([pspp -O format=csv sys-file.sps], [0],
1961    ["warning: `sys-file.sav' near offset 0x1f8: Long string missing values record says variable STR1 has 0 missing values, but only 1 to 3 missing values are allowed."
1962
1963 "warning: `sys-file.sav' near offset 0x205: Long string missing values record says variable STR2 has 4 missing values, but only 1 to 3 missing values are allowed."
1964
1965 warning: `sys-file.sav' near offset 0x23a: Ignoring long string missing value record for unknown variable Nonexistent.
1966
1967 warning: `sys-file.sav' near offset 0x24f: Ignoring long string missing value record for numeric variable NUM1.
1968
1969 "warning: `sys-file.sav' near offset 0x268: Ignoring long string missing value 0 for variable str3, with width 11, that has bad value width 12."
1970
1971 "warning: `sys-file.sav' near offset 0x289: This file has corrupted metadata written by a buggy version of PSPP.  To fix it, save a new copy of the file."
1972
1973 Table: Variables
1974 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1975 num1,1,Unknown,Input,8,Right,F8.0,F8.0,
1976 str1,2,Nominal,Input,9,Left,A9,A9,
1977 str2,3,Nominal,Input,10,Left,A10,A10,"""abcdefgh""; ""ijklmnop""; ""qrstuvwx"""
1978 str3,4,Nominal,Input,11,Left,A11,A11,"""ABCDEFGH""; ""IJKLMNOP"""
1979 ])
1980 done
1981 AT_CLEANUP
1982
1983 AT_SETUP([weighting variable must be numeric])
1984 AT_KEYWORDS([sack synthetic system file negative])
1985 AT_DATA([sys-file.sack], [dnl
1986 dnl File header.
1987 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1988 2; 2; 1; >>2<<; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1989
1990 dnl Numeric variable.
1991 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1992
1993 dnl String variable.
1994 2; 4; 0; 0; 0x010400 *2; s8 "STR1";
1995
1996 dnl Character encoding record.
1997 7; 20; 1; 12; "windows-1252";
1998
1999 dnl End of dictionary.
2000 999; 0;
2001 ])
2002 for variant in be le; do
2003   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2004   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2005 DISPLAY DICTIONARY.
2006 ])
2007   AT_CHECK([pspp -O format=csv sys-file.sps], [0],
2008    [warning: `sys-file.sav' near offset 0x4c: Ignoring string variable `STR1' set as weighting variable.
2009
2010 Table: Variables
2011 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
2012 num1,1,Unknown,Input,8,Right,F8.0,F8.0
2013 str1,2,Nominal,Input,4,Left,A4,A4
2014 ])
2015 done
2016 AT_CLEANUP
2017
2018 AT_SETUP([bad weighting variable index])
2019 AT_KEYWORDS([sack synthetic system file negative])
2020 AT_DATA([sys-file.sack], [dnl
2021 dnl File header.
2022 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2023 2; 2; 1; >>3<<; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2024
2025 dnl Numeric variable.
2026 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2027
2028 dnl String variable.
2029 2; 4; 0; 0; 0x010400 *2; s8 "STR1";
2030
2031 dnl Character encoding record.
2032 7; 20; 1; 12; "windows-1252";
2033
2034 dnl End of dictionary.
2035 999; 0;
2036 ])
2037 for variant in be le; do
2038   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2039   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2040 ])
2041   AT_CHECK([pspp -O format=csv sys-file.sps], 0,
2042    [warning: `sys-file.sav' near offset 0x4c: Weight variable index 3 not in valid range 1...2.  Treating file as unweighted.
2043 ])
2044 done
2045 AT_CLEANUP
2046
2047 AT_SETUP([variable index is long string continuation])
2048 AT_KEYWORDS([sack synthetic system file negative])
2049 AT_DATA([sys-file.sack], [dnl
2050 dnl File header.
2051 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2052 2; 3; 1; >>3<<; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2053
2054 dnl Numeric variable.
2055 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2056
2057 dnl Long string variable.
2058 2; 9; 0; 0; 0x010900 *2; s8 "STR1";
2059 (2; -1; 0; 0; 0; 0; s8 "");
2060
2061 dnl Character encoding record.
2062 7; 20; 1; 12; "windows-1252";
2063
2064 dnl End of dictionary.
2065 999; 0;
2066 ])
2067 for variant in be le; do
2068   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2069   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2070 ])
2071   AT_CHECK([pspp -O format=csv sys-file.sps], 0,
2072    [warning: `sys-file.sav' near offset 0x4c: Weight variable index 3 refers to long string continuation.  Treating file as unweighted.
2073 ])
2074 done
2075 AT_CLEANUP
2076
2077 AT_SETUP([multiple documents records])
2078 AT_KEYWORDS([sack synthetic system file negative])
2079 AT_DATA([sys-file.sack], [dnl
2080 dnl File header.
2081 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2082 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2083
2084 dnl Numeric variables, no label or missing values.
2085 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2086 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
2087
2088 dnl Two document records.
2089 (6; 1; s80 "One line of documents") >>* 2<<;
2090
2091 dnl Character encoding record.
2092 7; 20; 1; 12; "windows-1252";
2093
2094 dnl Dictionary termination record.
2095 999; 0;
2096
2097 dnl Data.
2098 1.0;
2099 ])
2100 for variant in be le; do
2101   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2102   AT_DATA([sys-file.sps], [dnl
2103 GET FILE='sys-file.sav'.
2104 ])
2105   AT_CHECK([pspp -O format=csv sys-file.sps], 0, [dnl
2106 warning: `sys-file.sav' near offset 0x14c: Duplicate type 6 (document) record.
2107 ])
2108 done
2109 AT_CLEANUP
2110
2111
2112 AT_SETUP([extension record too large])
2113 AT_KEYWORDS([sack synthetic system file negative])
2114 AT_DATA([sys-file.sack], [dnl
2115 dnl File header.
2116 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2117 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2118
2119 dnl Numeric variable, no label or missing values.
2120 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2121
2122 dnl Too-large extension record.
2123 7; 3; >>0xfffff000 * 2<<;
2124 ])
2125 for variant in be le; do
2126   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2127   AT_DATA([sys-file.sps], [dnl
2128 GET FILE='sys-file.sav'.
2129 ])
2130   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
2131 error: `sys-file.sav' near offset 0xd8: Record type 7 subtype 3 too large.
2132 ])
2133 done
2134 AT_CLEANUP
2135
2136 AT_SETUP([unknown extension record])
2137 AT_KEYWORDS([sack synthetic system file negative])
2138 AT_DATA([sys-file.sack], [dnl
2139 dnl File header.
2140 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2141 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2142
2143 dnl Numeric variable, no label or missing values.
2144 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2145
2146 dnl Unknown extension record type.
2147 7; 30; 1; 1; i8 0;
2148
2149 dnl Character encoding record.
2150 7; 20; 1; 12; "windows-1252";
2151
2152 dnl End of dictionary.
2153 999; 0;
2154 ])
2155 for variant in be le; do
2156   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2157   AT_DATA([sys-file.sps], [dnl
2158 GET FILE='sys-file.sav'.
2159 ])
2160   AT_CHECK_UNQUOTED([pspp -O format=csv sys-file.sps], [0], [dnl
2161 "warning: \`sys-file.sav' near offset 0xd8: Unrecognized record type 7, subtype 30.  For help, please send this file to ${PACKAGE_BUGREPORT} and mention that you were using ${PACKAGE_STRING}."
2162 ])
2163 done
2164 AT_CLEANUP
2165
2166 AT_SETUP([bad machine integer info size])
2167 AT_KEYWORDS([sack synthetic system file negative])
2168 AT_DATA([sys-file.sack], [dnl
2169 dnl File header.
2170 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2171 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2172
2173 dnl Numeric variable, no label or missing values.
2174 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2175
2176 dnl Machine integer info record.
2177 7; 3; 4; >>9<<; 1; 2; 3; -1; 1; 1; ENDIAN; 1252; >>1234<<;
2178
2179 dnl Character encoding record.
2180 7; 20; 1; 12; "windows-1252";
2181
2182 dnl End of dictionary.
2183 999; 0;
2184 ])
2185 for variant in be le; do
2186   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2187   AT_DATA([sys-file.sps], [dnl
2188 GET FILE='sys-file.sav'.
2189 ])
2190   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2191 "warning: `sys-file.sav' near offset 0xd8: Record type 7, subtype 3 has bad count 9 (expected 8)."
2192 ])
2193 done
2194 AT_CLEANUP
2195
2196 AT_SETUP([bad machine integer info float format])
2197 AT_KEYWORDS([sack synthetic system file negative])
2198 AT_DATA([sys-file.sack], [dnl
2199 dnl File header.
2200 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2201 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2202
2203 dnl Numeric variable, no label or missing values.
2204 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2205
2206 dnl Machine integer info record.
2207 7; 3; 4; 8; 1; 2; 3; -1; >>2<<; 1; ENDIAN; 1252;
2208
2209 dnl Character encoding record.
2210 7; 20; 1; 12; "windows-1252";
2211
2212 dnl End of dictionary.
2213 999; 0;
2214 ])
2215 for variant in be le; do
2216   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2217   AT_DATA([sys-file.sps], [dnl
2218 GET FILE='sys-file.sav'.
2219 ])
2220   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
2221 error: `sys-file.sav' near offset 0xd8: Floating-point representation indicated by system file (2) differs from expected (1).
2222 ])
2223 done
2224 AT_CLEANUP
2225
2226 AT_SETUP([bad machine integer info endianness])
2227 AT_KEYWORDS([sack synthetic system file negative])
2228 AT_DATA([sys-file.sack], [dnl
2229 dnl File header.
2230 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2231 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2232
2233 dnl Numeric variable, no label or missing values.
2234 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2235
2236 dnl Machine integer info record.
2237 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; >>3<<; 1252;
2238
2239 dnl Character encoding record.
2240 7; 20; 1; 12; "windows-1252";
2241
2242 dnl End of dictionary.
2243 999; 0;
2244 ])
2245 for variant in "be 1" "le 2"; do
2246   set $variant
2247   AT_CHECK([sack --$[1] sys-file.sack > sys-file.sav])
2248   AT_DATA([sys-file.sps], [dnl
2249 GET FILE='sys-file.sav'.
2250 DISPLAY DICTIONARY.
2251 ])
2252   AT_CHECK_UNQUOTED([pspp -O format=csv sys-file.sps], [0], [dnl
2253 warning: \`sys-file.sav' near offset 0xd8: Integer format indicated by system file (3) differs from expected ($[2]).
2254
2255 Table: Variables
2256 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
2257 num1,1,Unknown,Input,8,Right,F8.0,F8.0
2258 ])
2259 done
2260 AT_CLEANUP
2261
2262
2263 AT_SETUP([bad machine floating-point info size])
2264 AT_KEYWORDS([sack synthetic system file negative])
2265 AT_DATA([sys-file.sack], [dnl
2266 dnl File header.
2267 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2268 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2269
2270 dnl Numeric variable, no label or missing values.
2271 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2272
2273 dnl Machine floating-point info record.
2274 7; 4; 8; >>4<<; SYSMIS; HIGHEST; LOWEST; 0.0;
2275
2276 dnl Character encoding record.
2277 7; 20; 1; 12; "windows-1252";
2278
2279 dnl End of dictionary.
2280 999; 0;
2281 ])
2282 for variant in be le; do
2283   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2284   AT_DATA([sys-file.sps], [dnl
2285 GET FILE='sys-file.sav'.
2286 ])
2287   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2288 "warning: `sys-file.sav' near offset 0xd8: Record type 7, subtype 4 has bad count 4 (expected 3)."
2289 ])
2290 done
2291 AT_CLEANUP
2292
2293 AT_SETUP([wrong special floating point values])
2294 AT_KEYWORDS([sack synthetic system file negative])
2295 AT_DATA([sys-file.sack], [dnl
2296 dnl File header.
2297 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2298 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2299
2300 dnl Numeric variable, no label or missing values.
2301 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2302
2303 dnl Machine floating-point info record.
2304 7; 4; 8; 3; >>0.0<<; >>1.0<<; >>2.0<<;
2305
2306 dnl Character encoding record.
2307 7; 20; 1; 12; "windows-1252";
2308
2309 dnl End of dictionary.
2310 999; 0;
2311 ])
2312 for variant in be le; do
2313   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2314   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2315 ])
2316   AT_CHECK([pspp -O format=csv sys-file.sps | sed 's/ [(].*/.../'], [0], [dnl
2317 "warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 0...
2318
2319 "warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 1...
2320
2321 "warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 2...
2322 ])
2323 done
2324 AT_CLEANUP
2325
2326 AT_SETUP([bad mrsets name])
2327 AT_KEYWORDS([sack synthetic system file negative multiple response])
2328 AT_DATA([sys-file.sack], [dnl
2329 dnl File header.
2330 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2331 2; dnl Layout code
2332 16; dnl Nominal case size
2333 0; dnl Not compressed
2334 0; dnl Not weighted
2335 0; dnl No cases.
2336 100.0; dnl Bias.
2337 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
2338 i8 0 *3;
2339
2340 dnl $a
2341 2; 0; 0; 0; 0x050800 *2; i8 0x82; i8 0xa0; s6 "";
2342 2; 0; 0; 0; 0x050800 *2; s8 "B";
2343 2; 0; 0; 0; 0x050800 *2; s8 "C";
2344
2345 dnl $b
2346 2; 0; 0; 0; 0x050800 *2; s8 "D";
2347 2; 0; 0; 0; 0x050800 *2; s8 "E";
2348 2; 0; 0; 0; 0x050800 *2; s8 "F";
2349 2; 0; 0; 0; 0x050800 *2; s8 "G";
2350
2351 dnl $c
2352 2; 4; 0; 0; 0x010400 *2; s8 "H";
2353 2; 4; 0; 0; 0x010400 *2; s8 "I";
2354 2; 4; 0; 0; 0x010400 *2; s8 "J";
2355
2356 dnl $d
2357 2; 0; 0; 0; 0x050800 *2; s8 "K";
2358 2; 0; 0; 0; 0x050800 *2; s8 "L";
2359 2; 0; 0; 0; 0x050800 *2; s8 "M";
2360
2361 dnl $e
2362 2; 6; 0; 0; 0x010600 *2; s8 "N";
2363 2; 6; 0; 0; 0x010600 *2; s8 "O";
2364 2; 6; 0; 0; 0x010600 *2; s8 "P";
2365
2366 dnl Machine integer info record.
2367 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 932;
2368
2369 7; 7; 1;
2370 COUNT(
2371   "$a=C 10 my mcgroup "; i8 0x82; i8 0xa0; " b c"; i8 10;
2372   "b=D2 55 0  g e f d"; i8 10;
2373   "$c=D4 "; i8 0x82; i8 0xcd; i8 0x82; i8 0xa2; " 10 mdgroup #2 h i j"; i8 10);
2374
2375 7; 19; 1;
2376 COUNT(
2377   "$d=E 1 2 34 13 third mdgroup k l m"; i8 10;
2378   "e=E 11 6 choice 0  n o p"; i8 10);
2379
2380 dnl Character encoding record.
2381 7; 20; 1; 9; "shift_jis";
2382
2383 dnl Dictionary termination record.
2384 999; 0;
2385 ])
2386 for variant in be le; do
2387   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2388   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2389 MRSETS /DISPLAY NAME=ALL.
2390 ])
2391   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2392 warning: `sys-file.sav': Invalid multiple response set name `b'.
2393
2394 warning: `sys-file.sav': Invalid multiple response set name `e'.
2395
2396 Table: Multiple Response Sets
2397 Name,Label,Encoding,Counted Value,Member Variables
2398 $a,my mcgroup,Categories,,"あ
2399 b
2400 c"
2401 $c,mdgroup #2,Dichotomies,はい,"h
2402 i
2403 j"
2404 $d,third mdgroup,Dichotomies,34,"k
2405 l
2406 m"
2407 ])
2408 done
2409 AT_CLEANUP
2410
2411 AT_SETUP([missing space after C in mrsets])
2412 AT_KEYWORDS([sack synthetic system file negative multiple response])
2413 AT_DATA([sys-file.sack], [dnl
2414 dnl File header.
2415 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2416 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2417
2418 dnl Numeric variable, no label or missing values.
2419 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2420
2421 dnl Multiple response sets.
2422 7; 7; 1; COUNT("$a=Cx");
2423
2424 dnl Character encoding record.
2425 7; 20; 1; 12; "windows-1252";
2426
2427 999; 0;
2428 ])
2429 for variant in be le; do
2430   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2431   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2432 ])
2433   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2434 warning: `sys-file.sav' near offset 0xd8: Missing space following `C' at offset 4 in MRSETS record.
2435 ])
2436 done
2437 AT_CLEANUP
2438
2439 AT_SETUP([missing space after E in mrsets])
2440 AT_KEYWORDS([sack synthetic system file negative multiple response])
2441 AT_DATA([sys-file.sack], [dnl
2442 dnl File header.
2443 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2444 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2445
2446 dnl Numeric variable, no label or missing values.
2447 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2448
2449 dnl Multiple response sets.
2450 7; 7; 1; COUNT("$a=Ex");
2451
2452 dnl Character encoding record.
2453 7; 20; 1; 12; "windows-1252";
2454
2455 999; 0;
2456 ])
2457 for variant in be le; do
2458   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2459   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2460 ])
2461   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2462 warning: `sys-file.sav' near offset 0xd8: Missing space following `E' at offset 4 in MRSETS record.
2463 ])
2464 done
2465 AT_CLEANUP
2466
2467 AT_SETUP([missing label source in mrsets])
2468 AT_KEYWORDS([sack synthetic system file negative multiple response])
2469 AT_DATA([sys-file.sack], [dnl
2470 dnl File header.
2471 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2472 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2473
2474 dnl Numeric variable, no label or missing values.
2475 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2476
2477 dnl Multiple response sets.
2478 7; 7; 1; COUNT("$a=E ");
2479
2480 dnl Character encoding record.
2481 7; 20; 1; 12; "windows-1252";
2482
2483 999; 0;
2484 ])
2485 for variant in be le; do
2486   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2487   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2488 ])
2489   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2490 warning: `sys-file.sav' near offset 0xd8: Missing label source value following `E' at offset 5 in MRSETS record.
2491
2492 warning: `sys-file.sav' near offset 0xd8: Expecting digit at offset 5 in MRSETS record.
2493 ])
2494 done
2495 AT_CLEANUP
2496
2497 AT_SETUP([unexpected label source in mrsets])
2498 AT_KEYWORDS([sack synthetic system file negative multiple response])
2499 AT_DATA([sys-file.sack], [dnl
2500 dnl File header.
2501 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2502 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2503
2504 dnl Numeric variable, no label or missing values.
2505 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2506
2507 dnl Multiple response sets.
2508 7; 7; 1; COUNT("$a=E 2");
2509
2510 dnl Character encoding record.
2511 7; 20; 1; 12; "windows-1252";
2512
2513 999; 0;
2514 ])
2515 for variant in be le; do
2516   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2517   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2518 ])
2519   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2520 warning: `sys-file.sav' near offset 0xd8: Unexpected label source value following `E' at offset 7 in MRSETS record.
2521
2522 warning: `sys-file.sav' near offset 0xd8: Expecting digit at offset 7 in MRSETS record.
2523 ])
2524 done
2525 AT_CLEANUP
2526
2527 AT_SETUP([bad type character in mrsets])
2528 AT_KEYWORDS([sack synthetic system file negative multiple response])
2529 AT_DATA([sys-file.sack], [dnl
2530 dnl File header.
2531 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2532 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2533
2534 dnl Numeric variable, no label or missing values.
2535 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2536
2537 dnl Multiple response sets.
2538 7; 7; 1; COUNT("$a=");
2539
2540 dnl Character encoding record.
2541 7; 20; 1; 12; "windows-1252";
2542
2543 999; 0;
2544 ])
2545 for variant in be le; do
2546   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2547   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2548 ])
2549   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2550 "warning: `sys-file.sav' near offset 0xd8: Missing `C', `D', or `E' at offset 3 in MRSETS record."
2551 ])
2552 done
2553 AT_CLEANUP
2554
2555 AT_SETUP([bad counted string length in mrsets])
2556 AT_KEYWORDS([sack synthetic system file negative multiple response])
2557 AT_DATA([sys-file.sack], [dnl
2558 dnl File header.
2559 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2560 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2561
2562 dnl Numeric variable, no label or missing values.
2563 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2564
2565 dnl Multiple response sets.
2566 7; 7; 1; COUNT("$a=Dx");
2567
2568 dnl Character encoding record.
2569 7; 20; 1; 12; "windows-1252";
2570
2571 999; 0;
2572 ])
2573 for variant in be le; do
2574   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2575   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2576 ])
2577   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2578 warning: `sys-file.sav' near offset 0xd8: Expecting digit at offset 4 in MRSETS record.
2579 ])
2580 done
2581 AT_CLEANUP
2582
2583 AT_SETUP([missing space in counted string in mrsets])
2584 AT_KEYWORDS([sack synthetic system file negative multiple response])
2585 AT_DATA([sys-file.sack], [dnl
2586 dnl File header.
2587 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2588 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2589
2590 dnl Numeric variable, no label or missing values.
2591 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2592
2593 dnl Multiple response sets.
2594 7; 7; 1; COUNT("$a=D1x");
2595
2596 dnl Character encoding record.
2597 7; 20; 1; 12; "windows-1252";
2598
2599 999; 0;
2600 ])
2601 for variant in be le; do
2602   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2603   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2604 ])
2605   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2606 warning: `sys-file.sav' near offset 0xd8: Expecting space at offset 5 in MRSETS record.
2607 ])
2608 done
2609 AT_CLEANUP
2610
2611 AT_SETUP([counted string too long in mrsets])
2612 AT_KEYWORDS([sack synthetic system file negative multiple response])
2613 AT_DATA([sys-file.sack], [dnl
2614 dnl File header.
2615 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2616 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2617
2618 dnl Numeric variable, no label or missing values.
2619 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2620
2621 dnl Multiple response sets.
2622 7; 7; 1; COUNT("$a=D4 abc");
2623
2624 dnl Character encoding record.
2625 7; 20; 1; 12; "windows-1252";
2626
2627 999; 0;
2628 ])
2629 for variant in be le; do
2630   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2631   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2632 ])
2633   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2634 warning: `sys-file.sav' near offset 0xd8: 4-byte string starting at offset 6 exceeds record length 9.
2635 ])
2636 done
2637 AT_CLEANUP
2638
2639 AT_SETUP([missing space after counted string in mrsets])
2640 AT_KEYWORDS([sack synthetic system file negative multiple response])
2641 AT_DATA([sys-file.sack], [dnl
2642 dnl File header.
2643 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2644 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2645
2646 dnl Numeric variable, no label or missing values.
2647 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2648
2649 dnl Multiple response sets.
2650 7; 7; 1; COUNT("$a=D3 abcx");
2651
2652 dnl Character encoding record.
2653 7; 20; 1; 12; "windows-1252";
2654
2655 999; 0;
2656 ])
2657 for variant in be le; do
2658   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2659   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2660 ])
2661   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2662 warning: `sys-file.sav' near offset 0xd8: Expecting space at offset 9 following 3-byte string.
2663 ])
2664 done
2665 AT_CLEANUP
2666
2667 AT_SETUP([missing newline after variable name in mrsets])
2668 AT_KEYWORDS([sack synthetic system file negative multiple response])
2669 AT_DATA([sys-file.sack], [dnl
2670 dnl File header.
2671 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2672 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2673
2674 dnl Numeric variable, no label or missing values.
2675 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2676
2677 dnl Multiple response sets.
2678 7; 7; 1; COUNT("$a=C 0  NUM1");
2679
2680 dnl Character encoding record.
2681 7; 20; 1; 12; "windows-1252";
2682
2683 999; 0;
2684 ])
2685 for variant in be le; do
2686   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2687   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2688 ])
2689   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2690 warning: `sys-file.sav' near offset 0xd8: Missing new-line parsing variable names at offset 13 in MRSETS record.
2691
2692 warning: `sys-file.sav': MRSET $a has only one variable.
2693 ])
2694 done
2695 AT_CLEANUP
2696
2697 AT_SETUP([duplicate variable name in mrsets])
2698 AT_KEYWORDS([sack synthetic system file negative multiple response])
2699 AT_DATA([sys-file.sack], [dnl
2700 dnl File header.
2701 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2702 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2703
2704 dnl Numeric variable, no label or missing values.
2705 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2706
2707 dnl Multiple response sets.
2708 7; 7; 1; COUNT("$a=C 0  NUM1 NUM1"; i8 10);
2709
2710 dnl Character encoding record.
2711 7; 20; 1; 12; "windows-1252";
2712
2713 999; 0;
2714 ])
2715 for variant in be le; do
2716   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2717   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2718 ])
2719   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2720 warning: `sys-file.sav': MRSET $a contains duplicate variable name NUM1.
2721
2722 warning: `sys-file.sav': MRSET $a has only one variable.
2723 ])
2724 done
2725 AT_CLEANUP
2726
2727 AT_SETUP([mixed variable types in mrsets])
2728 AT_KEYWORDS([sack synthetic system file negative multiple response])
2729 AT_DATA([sys-file.sack], [dnl
2730 dnl File header.
2731 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2732 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2733
2734 dnl Variables.
2735 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2736 2; 8; 0; 0; 0x010800 *2; s8 "STR1";
2737
2738 dnl Multiple response sets.
2739 7; 7; 1; COUNT("$a=C 0  NUM1 STR1"; i8 10);
2740
2741 dnl Character encoding record.
2742 7; 20; 1; 12; "windows-1252";
2743
2744 999; 0;
2745 ])
2746 for variant in be le; do
2747   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2748   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2749 ])
2750   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2751 warning: `sys-file.sav': MRSET $a contains both string and numeric variables.
2752
2753 warning: `sys-file.sav': MRSET $a has only one variable.
2754 ])
2755 done
2756 AT_CLEANUP
2757
2758 AT_SETUP([missing newline after variable name in mrsets])
2759 AT_KEYWORDS([sack synthetic system file negative multiple response])
2760 AT_DATA([sys-file.sack], [dnl
2761 dnl File header.
2762 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2763 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2764
2765 dnl Numeric variable, no label or missing values.
2766 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2767
2768 dnl Multiple response sets.
2769 7; 7; 1; COUNT("$a=C 0  NUM1"; i8 10);
2770
2771 dnl Character encoding record.
2772 7; 20; 1; 12; "windows-1252";
2773
2774 999; 0;
2775 ])
2776 for variant in be le; do
2777   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2778   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2779 ])
2780   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2781 warning: `sys-file.sav': MRSET $a has only one variable.
2782 ])
2783 done
2784 AT_CLEANUP
2785
2786 AT_SETUP([zero or one variable in mrset])
2787 AT_KEYWORDS([sack synthetic system file negative multiple response])
2788 AT_DATA([sys-file.sack], [dnl
2789 dnl File header.
2790 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2791 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2792
2793 dnl Numeric variable, no label or missing values.
2794 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2795
2796 dnl Multiple response sets.
2797 7; 7; 1; COUNT("$a=C 0  NUM1"; i8 10; "$b=C 0  "; i8 10);
2798
2799 dnl Character encoding record.
2800 7; 20; 1; 12; "windows-1252";
2801
2802 999; 0;
2803 ])
2804 for variant in be le; do
2805   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2806   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2807 ])
2808   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2809 warning: `sys-file.sav': MRSET $a has only one variable.
2810
2811 warning: `sys-file.sav': MRSET $b has no variables.
2812 ])
2813 done
2814 AT_CLEANUP
2815
2816 AT_SETUP([wrong display parameter size])
2817 AT_KEYWORDS([sack synthetic system file negative])
2818 AT_DATA([sys-file.sack], [dnl
2819 dnl File header.
2820 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2821 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2822
2823 dnl Numeric variable, no label or missing values.
2824 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2825
2826 dnl Display parameters record.
2827 7; 11; >>8<<; 2; 1.0; 1.0;
2828
2829 dnl Character encoding record.
2830 7; 20; 1; 12; "windows-1252";
2831
2832 dnl End of dictionary.
2833 999; 0;
2834 ])
2835 for variant in be le; do
2836   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2837   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2838 ])
2839   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2840 "warning: `sys-file.sav' near offset 0xd8: Record type 7, subtype 11 has bad size 8 (expected 4)."
2841 ])
2842 done
2843 AT_CLEANUP
2844
2845 AT_SETUP([wrong display parameter count])
2846 AT_KEYWORDS([sack synthetic system file negative])
2847 AT_DATA([sys-file.sack], [dnl
2848 dnl File header.
2849 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2850 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2851
2852 dnl Numeric variable, no label or missing values.
2853 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2854
2855 dnl Display parameters record.
2856 7; 11; 4; >>4<<; 1; 1; 2; 2;
2857
2858 dnl Character encoding record.
2859 7; 20; 1; 12; "windows-1252";
2860
2861 dnl End of dictionary.
2862 999; 0;
2863 ])
2864 for variant in be le; do
2865   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2866   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2867 ])
2868   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2869 warning: `sys-file.sav' near offset 0xd8: Extension 11 has bad count 4 (for 1 variables).
2870 ])
2871 done
2872 AT_CLEANUP
2873
2874 AT_SETUP([wrong display measurement level])
2875 AT_KEYWORDS([sack synthetic system file negative])
2876 AT_DATA([sys-file.sack], [dnl
2877 dnl File header.
2878 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2879 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2880
2881 dnl Numeric variable, no label or missing values.
2882 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2883
2884 dnl Display parameters record.
2885 7; 11; 4; 2; >>4<<; 0;
2886
2887 dnl Character encoding record.
2888 7; 20; 1; 12; "windows-1252";
2889
2890 dnl End of dictionary.
2891 999; 0;
2892 ])
2893 for variant in be le; do
2894   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2895   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2896 ])
2897   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2898 warning: `sys-file.sav' near offset 0xd8: Invalid variable display parameters for variable 0 (NUM1).  Default parameters substituted.
2899 ])
2900 done
2901 AT_CLEANUP
2902
2903 AT_SETUP([wrong display alignment])
2904 AT_KEYWORDS([sack synthetic system file negative])
2905 AT_DATA([sys-file.sack], [dnl
2906 dnl File header.
2907 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2908 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2909
2910 dnl Numeric variable, no label or missing values.
2911 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2912
2913 dnl Display parameters record.
2914 7; 11; 4; 2; 1; >>-1<<;
2915
2916 dnl Character encoding record.
2917 7; 20; 1; 12; "windows-1252";
2918
2919 dnl End of dictionary.
2920 999; 0;
2921 ])
2922 for variant in be le; do
2923   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2924   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2925 ])
2926   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2927 warning: `sys-file.sav' near offset 0xd8: Invalid variable display parameters for variable 0 (NUM1).  Default parameters substituted.
2928 ])
2929 done
2930 AT_CLEANUP
2931
2932 AT_SETUP([bad variable name in variable/value pair])
2933 AT_KEYWORDS([sack synthetic system file negative])
2934 AT_DATA([sys-file.sack], [dnl
2935 dnl File header.
2936 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2937 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2938
2939 dnl Numeric variables.
2940 2; 0; 0; 0; 0x050800 *2; s8 "LONGVARI";
2941
2942 dnl Long variable names.
2943 7; 13; 1; COUNT (>>"xyzzy"<<);
2944
2945 dnl Character encoding record.
2946 7; 20; 1; 12; "windows-1252";
2947
2948 dnl Dictionary termination record.
2949 999; 0;
2950 ])
2951 for variant in be le; do
2952   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2953   AT_DATA([sys-file.sps], [dnl
2954 GET FILE='sys-file.sav'.
2955 ])
2956   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2957 warning: `sys-file.sav' near offset 0xde: Dictionary record refers to unknown variable xyzzy.
2958 ])
2959 done
2960 AT_CLEANUP
2961
2962 AT_SETUP([duplicate long variable name])
2963 AT_KEYWORDS([sack synthetic system file negative])
2964 AT_DATA([sys-file.sack], [dnl
2965 dnl File header.
2966 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2967 2; 4; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2968
2969 dnl Numeric variables.
2970 2; 0; 0; 0; 0x050800 *2; s8 "LONGVARI";
2971 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_A";
2972 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_B";
2973 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_C";
2974
2975 dnl Long variable names.
2976 7; 13; 1; COUNT (
2977 "LONGVARI=_Invalid"; i8 9;
2978 "LONGVARI=$Invalid"; i8 9;
2979 "LONGVARI=#Invalid"; i8 9;
2980 "LONGVA_A=LongVariableName"; i8 9;
2981 "LONGVA_B=LONGVARIABLENAME"; i8 9;
2982 );
2983
2984 dnl Character encoding record.
2985 7; 20; 1; 12; "windows-1252";
2986
2987 dnl Dictionary termination record.
2988 999; 0;
2989 ])
2990 for variant in be le; do
2991   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2992   AT_DATA([sys-file.sps], [dnl
2993 GET FILE='sys-file.sav'.
2994 ])
2995   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2996 warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `_Invalid'.
2997
2998 warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `$Invalid'.
2999
3000 warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `#Invalid'.
3001
3002 warning: `sys-file.sav' near offset 0x138: Duplicate long variable name `LONGVARIABLENAME'.
3003 ])
3004 done
3005 AT_CLEANUP
3006
3007 AT_SETUP([bad very long string length])
3008 AT_KEYWORDS([sack synthetic system file negative])
3009 AT_DATA([sys-file.sack], [dnl
3010 dnl File header.
3011 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3012 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3013
3014 dnl Numeric variable.
3015 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3016
3017 dnl Very long string map.
3018 7; 14; 1; COUNT (
3019 "NUM1=00000"; i8 0; i8 9;
3020 "NUM1=00255"; i8 0; i8 9;
3021 "NUM1=00256"; i8 0; i8 9;
3022 );
3023
3024 dnl Character encoding record.
3025 7; 20; 1; 12; "windows-1252";
3026
3027 dnl Dictionary termination record.
3028 999; 0;
3029 ])
3030 for variant in be le; do
3031   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3032   AT_DATA([sys-file.sps], [dnl
3033 GET FILE='sys-file.sav'.
3034 ])
3035   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3036 warning: `sys-file.sav' near offset 0xd8: NUM1 listed as string of invalid length 00000 in very long string record.
3037
3038 "warning: `sys-file.sav' near offset 0xd8: NUM1 listed in very long string record with width 00255, which requires only one segment."
3039
3040 error: `sys-file.sav' near offset 0xd8: Very long string NUM1 overflows dictionary.
3041 ])
3042 done
3043 AT_CLEANUP
3044
3045 AT_SETUP([bad very long string segment width])
3046 AT_KEYWORDS([sack synthetic system file negative])
3047 AT_DATA([sys-file.sack], [dnl
3048 dnl File header.
3049 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3050 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3051
3052 dnl Variables.
3053 2; 255; 0; 0; 0x01ff00 *2; s8 "STR1";
3054 (2; -1; 0; 0; 0; 0; s8 "") * 31;
3055 2; >>9<<; 0; 0; 0x010900 *2; s8 "STR1_A";
3056 >>2; -1; 0; 0; 0; 0; s8 "";<<
3057
3058 dnl Very long string map.
3059 7; 14; 1; COUNT (
3060 "STR1=00256"; i8 0; i8 9;
3061 );
3062
3063 dnl Character encoding record.
3064 7; 20; 1; 12; "windows-1252";
3065
3066 dnl Dictionary termination record.
3067 999; 0;
3068 ])
3069 for variant in be le; do
3070   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3071   AT_DATA([sys-file.sps], [dnl
3072 GET FILE='sys-file.sav'.
3073 ])
3074   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3075 error: `sys-file.sav' near offset 0x4f8: Very long string with width 256 has segment 1 of width 9 (expected 4).
3076 ])
3077 done
3078 AT_CLEANUP
3079
3080 AT_SETUP([too many value labels])
3081 AT_KEYWORDS([sack synthetic system file negative])
3082 AT_DATA([sys-file.sack], [dnl
3083 dnl File header.
3084 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3085 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3086
3087 dnl Numeric variable.
3088 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3089 3; >>0x7fffffff<<;
3090 ])
3091 for variant in be le; do
3092   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3093   AT_DATA([sys-file.sps], [dnl
3094 GET FILE='sys-file.sav'.
3095 ])
3096   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3097 error: `sys-file.sav' near offset 0xd4: Invalid number of labels 2147483647.
3098 ])
3099 done
3100 AT_CLEANUP
3101
3102 AT_SETUP([missing type 4 record])
3103 AT_KEYWORDS([sack synthetic system file negative])
3104 AT_DATA([sys-file.sack], [dnl
3105 dnl File header.
3106 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3107 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3108
3109 dnl Numeric variable.
3110 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3111
3112 dnl Value label with missing type 4 record.
3113 3; 1; 1.0; i8 3; s7 "one";
3114
3115 dnl Character encoding record.
3116 7; 20; 1; 12; "windows-1252";
3117
3118 dnl End of dictionary.
3119 >>999; 0<<;
3120 ])
3121 for variant in be le; do
3122   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3123   AT_DATA([sys-file.sps], [dnl
3124 GET FILE='sys-file.sav'.
3125 ])
3126   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3127 error: `sys-file.sav' near offset 0xe8: Variable index record (type 4) does not immediately follow value label record (type 3) as it should.
3128 ])
3129 done
3130 AT_CLEANUP
3131
3132 AT_SETUP([value label with no associated variables])
3133 AT_KEYWORDS([sack synthetic system file negative])
3134 AT_DATA([sys-file.sack], [dnl
3135 dnl File header.
3136 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3137 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3138
3139 dnl Numeric variable.
3140 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3141
3142 dnl Value label with no variables.
3143 3; 1; 1.0; i8 3; s7 "one"; 4; >>0<<;
3144 ])
3145 for variant in be le; do
3146   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3147   AT_DATA([sys-file.sps], [dnl
3148 GET FILE='sys-file.sav'.
3149 ])
3150   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3151 error: `sys-file.sav' near offset 0xec: Number of variables associated with a value label (0) is not between 1 and the number of variables (1).
3152 ])
3153 done
3154 AT_CLEANUP
3155
3156 AT_SETUP([type 4 record names long string variable])
3157 AT_KEYWORDS([sack synthetic system file negative])
3158 AT_DATA([sys-file.sack], [dnl
3159 dnl File header.
3160 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3161 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3162
3163 dnl Long string variable.
3164 2; 9; 0; 0; 0x010900 *2; s8 "STR1";
3165 2; -1; 0; 0; 0; 0; s8 "";
3166
3167 dnl Value label that names long string variable.
3168 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 1; >>1<<;
3169
3170 dnl Character encoding record.
3171 7; 20; 1; 12; "windows-1252";
3172
3173 dnl End of dictionary.
3174 999; 0;
3175 ])
3176 for variant in be le; do
3177   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3178   AT_DATA([sys-file.sps], [dnl
3179 GET FILE='sys-file.sav'.
3180 ])
3181   AT_CHECK([pspp -O format=csv sys-file.sps], 0, [dnl
3182 warning: `sys-file.sav' near offset 0xf4: Value labels may not be added to long string variables (e.g. STR1) using records types 3 and 4.
3183 ])
3184 done
3185 AT_CLEANUP
3186
3187 AT_SETUP([value label variable indexes must be in correct range])
3188 AT_KEYWORDS([sack synthetic system file negative])
3189 AT_DATA([sys-file.sack], [dnl
3190 dnl File header.
3191 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3192 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3193
3194 dnl Variables.
3195 2; 6; 0; 0; 0x010600 *2; s8 "STR1";
3196 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3197
3198 dnl Value labels with bad variable indexes.
3199 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 2; >>3; 4;<<
3200 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 2; >>5; 6;<<
3201 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 2; >>7; 8;<<
3202
3203 dnl Character encoding record.
3204 7; 20; 1; 12; "windows-1252";
3205
3206 dnl End of dictionary.
3207 999; 0;
3208 ])
3209 for variant in be le; do
3210   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3211   AT_DATA([sys-file.sps], [dnl
3212 GET FILE='sys-file.sav'.
3213 ])
3214   AT_CHECK([pspp -O format=csv sys-file.sps], 0, [dnl
3215 warning: `sys-file.sav' near offset 0xf4: Value label variable index 3 not in valid range 1...2.
3216
3217 warning: `sys-file.sav' near offset 0xf4: Value label variable index 4 not in valid range 1...2.
3218
3219 warning: `sys-file.sav' near offset 0x11c: Value label variable index 5 not in valid range 1...2.
3220
3221 warning: `sys-file.sav' near offset 0x11c: Value label variable index 6 not in valid range 1...2.
3222
3223 warning: `sys-file.sav' near offset 0x144: Value label variable index 7 not in valid range 1...2.
3224
3225 warning: `sys-file.sav': Suppressed 1 additional warnings for value labels.
3226 ])
3227 done
3228 AT_CLEANUP
3229
3230 AT_SETUP([value label variable indexes must not be long string continuation])
3231 AT_KEYWORDS([sack synthetic system file negative])
3232 AT_DATA([sys-file.sack], [dnl
3233 dnl File header.
3234 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3235 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3236
3237 dnl Long string variable.
3238 2; 9; 0; 0; 0x010900 *2; s8 "STR1";
3239 (2; -1; 0; 0; 0; 0; s8 "");
3240
3241 dnl Value label with long string indexes.
3242 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 1; >>2;<<
3243
3244 dnl Character encoding record.
3245 7; 20; 1; 12; "windows-1252";
3246
3247 dnl End of dictionary.
3248 999; 0;
3249 ])
3250 for variant in be le; do
3251   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3252   AT_DATA([sys-file.sps], [dnl
3253 GET FILE='sys-file.sav'.
3254 ])
3255   AT_CHECK([pspp -O format=csv sys-file.sps], 0, [dnl
3256 warning: `sys-file.sav' near offset 0xf4: Value label variable index 2 refers to long string continuation.
3257 ])
3258 done
3259 AT_CLEANUP
3260
3261 AT_SETUP([variables for value label must all be same type])
3262 AT_KEYWORDS([sack synthetic system file negative])
3263 AT_DATA([sys-file.sack], [dnl
3264 dnl File header.
3265 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3266 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3267
3268 dnl Variables.
3269 2; 6; 0; 0; 0x010600 *2; s8 "STR1";
3270 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3271
3272 dnl Value label that names numeric and string variables.
3273 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 2; >>1; 2<<;
3274
3275 dnl Character encoding record.
3276 7; 20; 1; 12; "windows-1252";
3277
3278 dnl End of dictionary.
3279 999; 0;
3280 ])
3281 for variant in be le; do
3282   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3283   AT_DATA([sys-file.sps], [dnl
3284 GET FILE='sys-file.sav'.
3285 ])
3286   AT_CHECK([pspp -O format=csv sys-file.sps], 0, [dnl
3287 "warning: `sys-file.sav' near offset 0xf4: Variables associated with value label are not all of identical type.  Variable STR1 is string, but variable NUM1 is numeric."
3288 ])
3289 done
3290 AT_CLEANUP
3291
3292 AT_SETUP([duplicate value labels type])
3293 AT_KEYWORDS([sack synthetic system file negative])
3294 AT_DATA([sys-file.sack], [dnl
3295 dnl File header.
3296 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3297 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3298
3299 dnl Variables.
3300 2; 6; 0; 0; 0x010600 *2; s8 "STR1";
3301 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3302
3303 dnl Duplicate value labels.
3304 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 2; >>1; 1<<;
3305 3; 1; 1.0; i8 3; s7 "one"; 4; 2; >>2; 2<<;
3306
3307 dnl Character encoding record.
3308 7; 20; 1; 12; "windows-1252";
3309
3310 dnl End of dictionary.
3311 999; 0;
3312 ])
3313 for variant in be le; do
3314   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3315   AT_DATA([sys-file.sps], [dnl
3316 GET FILE='sys-file.sav'.
3317 ])
3318   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3319 warning: `sys-file.sav' near offset 0xf4: Duplicate value label for `xyzzy ' on STR1.
3320
3321 warning: `sys-file.sav' near offset 0x11c: Duplicate value label for 1 on NUM1.
3322 ])
3323 done
3324 AT_CLEANUP
3325
3326 AT_SETUP([missing attribute value])
3327 AT_KEYWORDS([sack synthetic system file negative])
3328 AT_DATA([sys-file.sack], [dnl
3329 dnl File header.
3330 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3331 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3332
3333 dnl Variables.
3334 2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
3335
3336 dnl Data file attributes record.
3337 7; 17; 1; COUNT (
3338 "Attr1("
3339 );
3340
3341 dnl Variable attributes record.
3342 7; 18; 1; COUNT (
3343 "FIRSTVAR:";
3344   "fred('23'"; i8 10
3345 );
3346
3347 dnl Character encoding record.
3348 7; 20; 1; 12; "windows-1252";
3349
3350 dnl Dictionary termination record.
3351 999; 0;
3352 ])
3353 for variant in be le; do
3354   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3355   AT_DATA([sys-file.sps], [dnl
3356 GET FILE='sys-file.sav'.
3357 ])
3358   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3359 warning: `sys-file.sav' near offset 0xde: Error parsing attribute value Attr1[[1]].
3360
3361 warning: `sys-file.sav' near offset 0x101: Error parsing attribute value fred[[2]].
3362 ])
3363 done
3364 AT_CLEANUP
3365
3366 AT_SETUP([unquoted attribute value])
3367 AT_KEYWORDS([sack synthetic system file negative])
3368 AT_DATA([sys-file.sack], [dnl
3369 dnl File header.
3370 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3371 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3372
3373 dnl Variables.
3374 2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
3375
3376 dnl Data file attributes record.
3377 7; 17; 1; COUNT (
3378 "Attr1(value"; i8 10;
3379 ")"
3380 );
3381
3382 dnl Variable attributes record.
3383 7; 18; 1; COUNT (
3384 "FIRSTVAR:";
3385   "fred(23"; i8 10; ")"
3386 );
3387
3388 dnl Character encoding record.
3389 7; 20; 1; 12; "windows-1252";
3390
3391 dnl Dictionary termination record.
3392 999; 0;
3393 ])
3394 for variant in be le; do
3395   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3396   AT_DATA([sys-file.sps], [dnl
3397 GET FILE='sys-file.sav'.
3398 ])
3399   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3400 warning: `sys-file.sav' near offset 0xe4: Attribute value Attr1[[1]] is not quoted: value.
3401
3402 warning: `sys-file.sav' near offset 0x106: Attribute value fred[[1]] is not quoted: 23.
3403 ])
3404 done
3405 AT_CLEANUP
3406
3407 AT_SETUP([duplicate attribute name])
3408 AT_KEYWORDS([sack synthetic system file negative])
3409 AT_DATA([sys-file.sack], [dnl
3410 dnl File header.
3411 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3412 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3413
3414 dnl Variables.
3415 2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
3416
3417 dnl Data file attributes record.
3418 7; 17; 1; COUNT (
3419 "Attr1('value'"; i8 10; ")";
3420 "Attr1('value'"; i8 10; ")";
3421 );
3422
3423 dnl Variable attributes record.
3424 7; 18; 1; COUNT (
3425 "FIRSTVAR:";
3426   "fred('23'"; i8 10; ")";
3427   "fred('23'"; i8 10; ")";
3428 );
3429
3430 dnl Character encoding record.
3431 7; 20; 1; 12; "windows-1252";
3432
3433 dnl Dictionary termination record.
3434 999; 0;
3435 ])
3436 for variant in be le; do
3437   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3438   AT_DATA([sys-file.sps], [dnl
3439 GET FILE='sys-file.sav'.
3440 ])
3441   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3442 warning: `sys-file.sav' near offset 0xf6: Duplicate attribute Attr1.
3443
3444 warning: `sys-file.sav' near offset 0x125: Duplicate attribute fred.
3445 ])
3446 done
3447 AT_CLEANUP
3448
3449 AT_SETUP([bad variable name in long string value label])
3450 AT_KEYWORDS([sack synthetic system file negative])
3451 AT_DATA([sys-file.sack], [dnl
3452 dnl File header.
3453 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3454 2; 3; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3455
3456 dnl Variables.
3457 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3458 2; 14; 0; 0; 0x010e00 *2; s8 "STR14";
3459 2; -1; 0; 0; 0; 0; s8 "";
3460
3461 7; 21; 1; COUNT (
3462 dnl No variable named STR9.
3463 COUNT(>>"STR9"<<); 9;
3464 1; COUNT("RSTUVWXYZ"); COUNT("value label for `RSTUVWXYZ'");
3465
3466 dnl NUM1 is numeric.
3467 COUNT(>>"NUM1"<<); 0;
3468 1; COUNT("xyz"); COUNT("value label for 1.0");
3469
3470 dnl Wrong width for STR14.
3471 COUNT("STR14"); >>9<<;
3472 1; COUNT("RSTUVWXYZ"); COUNT("value label for `RSTUVWXYZ'");
3473
3474 dnl Wrong width for value.
3475 COUNT("STR14"); 14;
3476 1; COUNT(>>"RSTUVWXYZ"<<); COUNT("value label for `RSTUVWXYZ'");
3477
3478 dnl Duplicate value label.
3479 COUNT("STR14"); 14; 2;
3480 COUNT("abcdefghijklmn"); COUNT("value label for `abcdefghijklmn'");
3481 >>COUNT("abcdefghijklmn"); COUNT("another value label for `abcdefghijklmn'")<<;
3482 );
3483
3484 dnl Character encoding record.
3485 7; 20; 1; 12; "windows-1252";
3486
3487 dnl Dictionary termination record.
3488 999; 0;
3489 ])
3490 for variant in be le; do
3491   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3492   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3493 ])
3494   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3495 warning: `sys-file.sav' near offset 0x128: Ignoring long string value label record for unknown variable STR9.
3496
3497 warning: `sys-file.sav' near offset 0x164: Ignoring long string value label record for numeric variable NUM1.
3498
3499 warning: `sys-file.sav' near offset 0x193: Ignoring long string value label record for variable STR14 because the record's width (9) does not match the variable's width (14).
3500
3501 "warning: `sys-file.sav' near offset 0x1d4: Ignoring long string value label 0 for variable str14, with width 14, that has bad value width 9."
3502
3503 warning: `sys-file.sav' near offset 0x259: Duplicate value label for `abcdefghijklmn' on str14.
3504 ])
3505 done
3506 AT_CLEANUP
3507
3508 AT_SETUP([fewer data records than indicated by file header])
3509 AT_KEYWORDS([sack synthetic system file negative])
3510 AT_DATA([sys-file.sack], [dnl
3511 dnl File header.
3512 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3513 2; 2; 0; 0; >>5<<; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3514
3515 dnl Numeric variables.
3516 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3517 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
3518
3519 dnl Character encoding record.
3520 7; 20; 1; 12; "windows-1252";
3521
3522 dnl Data.
3523 999; 0;
3524 1.0; 2.0;
3525 3.0; 4.0;
3526 5.0; 6.0;
3527 7.0; 8.0;
3528 dnl Missing record here.
3529 ])
3530 for variant in be le; do
3531   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3532   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3533 LIST.
3534 ])
3535   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
3536    [error: Error reading case from file `sys-file.sav'.
3537
3538 Table: Data List
3539 num1,num2
3540 1,2
3541 3,4
3542 5,6
3543 7,8
3544 ])
3545 done
3546 AT_CLEANUP
3547
3548 AT_SETUP([partial data record between variables])
3549 AT_KEYWORDS([sack synthetic system file negative])
3550 AT_DATA([sys-file.sack], [dnl
3551 dnl File header.
3552 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3553 2; 2; 0; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3554
3555 dnl Numeric variables.
3556 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3557 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
3558
3559 dnl Character encoding record.
3560 7; 20; 1; 12; "windows-1252";
3561
3562 dnl Data.
3563 999; 0;
3564 1.0; 2.0;
3565 3.0;
3566 ])
3567 for variant in be le; do
3568   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3569   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3570 LIST.
3571 ])
3572   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
3573    [error: `sys-file.sav' near offset 0x12c: File ends in partial case.
3574
3575 Table: Data List
3576 num1,num2
3577 1,2
3578 ])
3579 done
3580 AT_CLEANUP
3581
3582 AT_SETUP([partial data record within long string])
3583 AT_KEYWORDS([sack synthetic system file negative])
3584 AT_DATA([sys-file.sack], [dnl
3585 dnl File header.
3586 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3587 2; 2; 0; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3588
3589 dnl Numeric variables.
3590 2; 14; 0; 0; 0x010e00 *2; s8 "STR14";
3591 2; -1; 0; 0; 0; 0; s8 "";
3592
3593 dnl Character encoding record.
3594 7; 20; 1; 12; "windows-1252";
3595
3596 dnl Data.
3597 999; 0;
3598 s14 "one data item";
3599 s8 "partial";
3600 ])
3601 for variant in be le; do
3602   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3603   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3604 LIST.
3605 ])
3606   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
3607    [error: `sys-file.sav' near offset 0x12a: Unexpected end of file.
3608
3609 Table: Data List
3610 str14
3611 one data item
3612 ])
3613 done
3614 AT_CLEANUP
3615
3616 AT_SETUP([partial compressed data record])
3617 AT_KEYWORDS([sack synthetic system file positive])
3618 AT_DATA([sys-file.sack], [dnl
3619 dnl File header.
3620 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3621 2; dnl Layout code
3622 6; dnl Nominal case size
3623 1; dnl Compressed
3624 0; dnl Not weighted
3625 -1; dnl Unspecified number of cases.
3626 100.0; dnl Bias.
3627 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
3628 i8 0 *3;
3629
3630 dnl Numeric variables.
3631 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3632 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
3633
3634 dnl String variable.
3635 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
3636 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
3637 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
3638 2; -1; 0; 0; 0; 0; s8 "";
3639
3640 dnl Character encoding record.
3641 7; 20; 1; 12; "windows-1252";
3642
3643 dnl Dictionary termination record.
3644 999; 0;
3645
3646 dnl Compressed data.
3647 i8 1 100 254 253 254 253; i8 255 251; "abcdefgh"; s8 "0123";
3648 ])
3649 for variant in be le; do
3650   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3651   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3652 LIST.
3653 ])
3654   AT_CHECK([pspp -O format=csv sys-file.sps], [1],
3655    [error: `sys-file.sav' near offset 0x1ac: File ends in partial case.
3656
3657 Table: Data List
3658 num1,num2,str4,str8,str15
3659 -99,0,,abcdefgh,0123
3660 ])
3661 done
3662 AT_CLEANUP
3663
3664 AT_SETUP([zcompressed data - bad zheader_ofs])
3665 AT_KEYWORDS([sack synthetic system file negative zlib])
3666 zcompressed_sack | sed 's/.*zheader_ofs.*/>>i64 0<<;/' > sys-file.sack
3667 for variant in be le; do
3668   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3669   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3670 ])
3671   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x194: Wrong ZLIB data header offset 0 (expected 0x194).
3672 ])
3673 done
3674 AT_CLEANUP
3675
3676 AT_SETUP([zcompressed data - bad ztrailer_ofs])
3677 AT_KEYWORDS([sack synthetic system file negative zlib])
3678 zcompressed_sack | sed 's/.*ztrailer_ofs.*/>>i64 0<<;/' > sys-file.sack
3679 for variant in be le; do
3680   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3681   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3682 ])
3683   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x194: Impossible ZLIB trailer offset 0x0.
3684 ])
3685 done
3686 AT_CLEANUP
3687
3688 # ztrailer_len must be a multiple of 24 and at least 48,
3689 # so a value of 12 is impossible.
3690 AT_SETUP([zcompressed data - invalid ztrailer_len])
3691 AT_KEYWORDS([sack synthetic system file negative zlib])
3692 zcompressed_sack | sed 's/.*ztrailer_len.*/>>i64 12<<;/' > sys-file.sack
3693 for variant in be le; do
3694   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3695   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3696 ])
3697   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x194: Invalid ZLIB trailer length 12.
3698 ])
3699 done
3700 AT_CLEANUP
3701
3702 # ztrailer_ofs + ztrailer_len must be the file size.
3703 AT_SETUP([zcompressed data - wrong ztrailer_len])
3704 AT_KEYWORDS([sack synthetic system file negative zlib])
3705 zcompressed_sack | sed 's/.*ztrailer_len.*/>>i64 72<<;/' > sys-file.sack
3706 for variant in be le; do
3707   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3708   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3709 ])
3710   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [warning: `sys-file.sav' near offset 0x1ac: End of ZLIB trailer (0x24d) is not file size (0x235).
3711 error: `sys-file.sav' near offset 0x21d: 72-byte ZLIB trailer specifies 1 data blocks (expected 2).
3712 ])
3713 done
3714 AT_CLEANUP
3715
3716 AT_SETUP([zcompressed data - wrong ztrailer_bias])
3717 AT_KEYWORDS([sack synthetic system file negative zlib])
3718 zcompressed_sack | sed 's/.*ztrailer_bias.*/>>i64 0<<;/' > sys-file.sack
3719 for variant in be le; do
3720   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3721   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3722 ])
3723   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x20d: ZLIB trailer bias (0) differs from file header bias (100.00).
3724 ])
3725 done
3726 AT_CLEANUP
3727
3728 AT_SETUP([zcompressed data - wrong ztrailer_zero])
3729 AT_KEYWORDS([sack synthetic system file negative zlib])
3730 zcompressed_sack | sed 's/.*ztrailer_zero.*/>>i64 100<<;/' > sys-file.sack
3731 for variant in be le; do
3732   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3733   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3734 ])
3735   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], [warning: `sys-file.sav' near offset 0x215: ZLIB trailer "zero" field has nonzero value 100.
3736 ])
3737 done
3738 AT_CLEANUP
3739
3740 AT_SETUP([zcompressed data - wrong block_size])
3741 AT_KEYWORDS([sack synthetic system file negative zlib])
3742 zcompressed_sack | sed 's/.*block_size.*/>>0x1000<<;/' > sys-file.sack
3743 for variant in be le; do
3744   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3745   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3746 ])
3747   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], [warning: `sys-file.sav' near offset 0x219: ZLIB trailer specifies unexpected 4096-byte block size.
3748 ])
3749 done
3750 AT_CLEANUP
3751
3752 AT_SETUP([zcompressed data - wrong n_blocks])
3753 AT_KEYWORDS([sack synthetic system file negative zlib])
3754 zcompressed_sack | sed 's/.*n_blocks.*/>>2<<;/' > sys-file.sack
3755 for variant in be le; do
3756   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3757   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3758 ])
3759   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x21d: 48-byte ZLIB trailer specifies 2 data blocks (expected 1).
3760 ])
3761 done
3762 AT_CLEANUP
3763
3764 AT_SETUP([zcompressed data - wrong uncompressed_ofs])
3765 AT_KEYWORDS([sack synthetic system file negative zlib])
3766 zcompressed_sack | sed 's/.*uncompressed_ofs.*/i64 >>0x177<<;/' > sys-file.sack
3767 for variant in be le; do
3768   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3769   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3770 ])
3771   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x21d: ZLIB block descriptor 0 reported uncompressed data offset 0x177, when 0x194 was expected.
3772 ])
3773 done
3774 AT_CLEANUP
3775
3776 AT_SETUP([zcompressed data - wrong compressed_ofs])
3777 AT_KEYWORDS([sack synthetic system file negative zlib])
3778 zcompressed_sack | sed 's/.*@%:@ compressed_ofs.*/i64 >>0x191<<;/' > sys-file.sack
3779 for variant in be le; do
3780   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3781   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3782 ])
3783   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x21d: ZLIB block descriptor 0 reported compressed data offset 0x191, when 0x1ac was expected.
3784 ])
3785 done
3786 AT_CLEANUP
3787
3788 AT_SETUP([zcompressed data - compressed sizes don't add up])
3789 AT_KEYWORDS([sack synthetic system file negative zlib])
3790 AT_DATA([sys-file.sack], [dnl
3791 dnl File header.
3792 "$FL3"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3793 2; dnl Layout code
3794 6; dnl Nominal case size
3795 2; dnl zlib compressed
3796 0; dnl Not weighted
3797 -1; dnl Unspecified number of cases.
3798 100.0; dnl Bias.
3799 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
3800 i8 0 *3;
3801
3802 dnl Numeric variables.
3803 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3804 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
3805
3806 dnl String variable.
3807 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
3808 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
3809 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
3810 2; -1; 0; 0; 0; 0; s8 "";
3811
3812 dnl Character encoding record.
3813 7; 20; 1; 12; "windows-1252";
3814
3815 dnl Dictionary termination record.
3816 999; 0;
3817
3818 dnl ZLIB data header.
3819 i64 0x194;    # zheader_ofs
3820 i64 0x1ac;    # ztrailer_ofs
3821 i64 72;       # ztrailer_len
3822
3823 dnl This is where the ZLIB data blocks would go, but we don't need any to
3824 dnl provoke this message so we omit them.
3825
3826 dnl ZLIB data trailer fixed header:
3827 i64 -100;     # ztrailer_bias
3828 i64 0;        # ztrailer_zero
3829 0x3ff000;     # block_size
3830 2;            # n_blocks
3831
3832 dnl ZLIB block descriptor 1:
3833 i64 0x194;    # uncompressed_ofs
3834 i64 0x1ac;    # compressed_ofs
3835 0x100000;     # uncompressed_size
3836 0x12345;      # compressed_size
3837
3838 dnl ZLIB block descriptor 2:
3839 i64 0x100194; # uncompressed_ofs
3840 i64 0x12421;  # compressed_ofs
3841 0x100000;     # uncompressed_size
3842 0x12345;      # compressed_size
3843 ])
3844 for variant in be le; do
3845   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3846   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3847 ])
3848   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [warning: `sys-file.sav' near offset 0x1c4: ZLIB block descriptor 0 reported block size 0x100000, when 0x3ff000 was expected.
3849 error: `sys-file.sav' near offset 0x1dc: ZLIB block descriptor 1 reported compressed data offset 0x12421, when 0x124f1 was expected.
3850 ])
3851 done
3852 AT_CLEANUP
3853
3854 AT_SETUP([zcompressed data - uncompressed_size > block_size])
3855 AT_KEYWORDS([sack synthetic system file negative zlib])
3856 zcompressed_sack | sed 's/.*uncompressed_size.*/>>0x400000<<;/' > sys-file.sack
3857 for variant in be le; do
3858   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3859   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3860 ])
3861   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], [warning: `sys-file.sav' near offset 0x21d: ZLIB block descriptor 0 reported block size 0x400000, when at most 0x3ff000 was expected.
3862 ])
3863 done
3864 AT_CLEANUP
3865
3866 AT_SETUP([zcompressed data - compression expands data too much])
3867 AT_KEYWORDS([sack synthetic system file negative zlib])
3868 zcompressed_sack | sed 's/.*uncompressed_size.*/>>50<<;/
3869 s/.*@%:@ compressed_size.*/>>100<<;/' > sys-file.sack
3870 for variant in be le; do
3871   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3872   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3873 ])
3874   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x21d: ZLIB block descriptor 0 reports compressed size 100 and uncompressed size 50.
3875 ])
3876 done
3877 AT_CLEANUP
3878
3879 AT_SETUP([zcompressed data - compressed sizes don't add up])
3880 AT_KEYWORDS([sack synthetic system file negative zlib])
3881 zcompressed_sack | sed 's/.*@%:@ compressed_size.*/>>88<<;/' > sys-file.sack
3882 for variant in be le; do
3883   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3884   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3885 ])
3886   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x235: ZLIB trailer is at offset 0x205 but 0x204 would be expected from block descriptors.
3887 ])
3888 done
3889 AT_CLEANUP
3890
3891 # CVE-2017-10791.
3892 # See also https://bugzilla.redhat.com/show_bug.cgi?id=1467004.
3893 # See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866890.
3894 # See also https://security-tracker.debian.org/tracker/CVE-2017-10791.
3895 # Found by team OWL337, using the collAFL fuzzer.
3896 AT_SETUP([integer overflows in long string missing values])
3897 AT_KEYWORDS([system file negative])
3898 cp $top_srcdir/tests/data/CVE-2017-10791.sav .
3899 AT_CHECK([pspp-convert -O csv -e ASCII CVE-2017-10791.sav -], [0], [], [dnl
3900 `CVE-2017-10791.sav' near offset 0x217: Extension record subtype 21 ends unexpectedly.
3901 ])
3902 AT_CLEANUP
3903
3904 # CVE-2017-10792.
3905 # See also https://bugzilla.redhat.com/show_bug.cgi?id=1467005.
3906 # See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866890.
3907 # See also https://security-tracker.debian.org/tracker/CVE-2017-10792.
3908 # Reported by team OWL337, with fuzzer collAFL.
3909 AT_SETUP([null dereference skipping bad extension record 18])
3910 AT_KEYWORDS([system file negative])
3911 cp $top_srcdir/tests/data/CVE-2017-10792.sav .
3912 AT_CHECK([pspp-convert -O csv -e ASCII CVE-2017-10792.sav -], [0], [], [dnl
3913 `CVE-2017-10792.sav' near offset 0x1c0: Record type 7, subtype 18 has bad size 4 (expected 1).
3914 ])
3915 AT_CLEANUP