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