(short_names_assign): Fix dumb typo, in which `i' was written where
[pspp-builds.git] / src / data / ChangeLog
1 2007-11-24  Ben Pfaff  <blp@gnu.org>
2
3         Fix warning reported when reading back system files that include
4         very long string variables.  Thanks to Guido Gay <gay@irer.it> for
5         reporting this bug.
6
7         * short-names.c (short_names_assign): Fix dumb typo, in which `i'
8         was written where `j' was meant.
9
10 2007-11-18  Ben Pfaff  <blp@gnu.org>
11
12         Properly write variables that include a range of missing values to
13         system files.  Thanks to Guido Gay <gay@irer.it> for reporting
14         this bug.
15
16         * sys-file-writer.c (write_variable): Correctly calculate
17         n_missing_values field when writing variables that include a range
18         of missing values.
19
20 2007-11-10  Ben Pfaff  <blp@gnu.org>
21
22         Cleanups and bug fixes devised while writing up documentation.
23         Patch #6262.
24
25         * automake.mk (src_data_libdata_a_SOURCES): Add new files.
26
27         * dict-class.c: New file.
28         (dict_class_from_id): Move here.
29         (dict_class_to_name): Move here.
30
31         * dict-class.h: New file.
32         (enum dict_class): Move here.  Change from consecutive integers to
33         consecutive bits, to make testing for any of multiple values
34         easier.  Add new DC_ALL constant.
35
36         * dictionary.c (struct dictionary): Change `case_limit' from
37         size_t to casenumber.
38         (dict_get_vars): Make final argument an enum dict_class.
39         (dict_get_vars_mutable): Ditto.
40         (dict_get_case_limit): Change return value to casenumber.
41         (dict_set_case_limit): Change final argument to a casenumber.
42         (dict_unset_split_var): Add assertion.  Rephrase slightly.
43         (dict_set_label): Use xstrndup to simplify.
44
45         * format.c (fmt_step_width): AHEX format also needs 2-byte
46         stepping.
47         (fmt_set_style): Simplify assertions.
48
49         * missing-values.c (mv_add_num_range): Rename mv_add_range.
50         Simplify implementation.
51         (mv_has_value): Simplify implementation.
52         (mv_pop_value): Remove the first value, not the last, to avoid
53         having GET followed by SAVE reverse the order of missing values.
54         (mv_peek_value): Rename mv_get_value.  Simplify assertion.
55         (mv_has_range): Simplify implementation.
56         (mv_peek_range): Rename mv_get_range.
57         (can_resize_string): Removed.
58         (mv_is_resizable): Use value_is_resizable.
59         (mv_resize): Use value_resize.
60
61         * short-names.h (SHORT_NAME_LEN): Move here.
62
63         * val-type.h: New file, for definitions related to type and width
64         of abstract values.  Before, these definitions were mixed among
65         those related to "union value" and those related to variables.
66         (macro SYSMIS): Move here.
67         (macro LOWEST): Move here.
68         (macro HIGHEST): Move here.
69         (macro MAX_STRING); Move here.
70         (enum val_type): New enum with values VAL_NUMERIC and VAL_STRING.
71         Replaces enum var_type that had values VAR_NUMERIC and VAR_STRING.
72         All references updated.
73         (val_type_is_valid): New function.  Replaces var_type_is_valid.
74         All references updated.
75         (val_type_from_width): New function.  Replaces
76         var_type_from_width.  All references updated.
77
78         * value-labels.c (val_labs_copy): Renamed val_labs_clone.  All
79         references updated.
80         (val_labs_can_set_width): Use value_is_resizable.
81         (val_labs_add): Simply return false if the value labels set is too
82         wide, instead of having undefined behavior.
83         (val_labs_replace): Ditto.
84         (val_labs_replace): Ditto.
85         (val_labs_first): Set iterator to null if iteration is complete.
86         (val_labs_first_sorted): Ditto.
87         (val_labs_done): Become a no-op if the iterator is null.
88
89         * value.c (value_is_resizable): New function.
90         (value_resize): New function.
91
92         * variable.c (var_get_dict_class): New function.
93
94         * variable.h (macro LONG_NAME_LEN): Rename VAR_NAME_LEN.  Update
95         all references.
96
97 2007-11-08  Ben Pfaff  <blp@gnu.org>
98
99         * data-in.c: Make formatted data parsing locale-independent.
100         (parse_number): Use c_strtod instead of strtod, to avoid
101         locale-specific behavior.
102         (parse_Z): Ditto.
103
104 2007-11-06  Ben Pfaff  <blp@gnu.org>
105
106         Patch #6256: add support for binary, 360 file formats.  Reviewed
107         by John Darrington.
108
109         * data-in.c (struct data_in): Add `encoding' member.
110         (data_in): Add `encoding' parameter, and re-encode the data passed
111         in where appropriate.  Update all callers to pass it in.
112         (parse_A): Implement EBCDIC recoding wart described in manual.
113         (parse_AHEX): Implement EBCDIC recoding.
114
115         * data-out.c (data_out_legacy): New function.
116         (data_out): Make into a wrapper around data_out_legacy.
117
118         * file-handle-def.c (struct file_handle): New member `encoding'.
119         (fh_create_file): Set encoding.
120         (fh_default_properties): Set default encoding.
121         (fh_get_legacy_encoding): New function.
122
123         * file-handle-def.h (enum fh_mode): New modes FH_MODE_FIXED
124         (that replaces FH_MODE_BINARY), FH_MODE_VARIABLE,
125         FH_MODE_360_VARIABLE, FH_MODE_360_SPANNED.
126         (struct fh_properties): New member `encoding'.
127
128 2007-11-05  Ben Pfaff  <blp@gnu.org>
129
130         Patch #6258.  Reviewed by John Darrington.
131
132         * file-handle-def.c (fh_lock): Add comment that TYPE should be
133         marked with N_() in the caller.  Added these markings to each
134         caller too.  Should make i18n easier.
135         Suggested by Chusslove Illich <caslav.ilic@gmx.net>.
136
137 2007-11-03  Ben Pfaff  <blp@gnu.org>
138
139         Allow output files to overwrite input files (bug #21280).
140
141         * file-handle-def.c: Separate locking of files for input and for
142         output, to allow both to take place at once.  Also, distinguish a
143         file handle from the identity of the underlying file, because the
144         identity of a file changes over time and the file handle can't
145         represent two different identities.
146         (struct file_handle): Remove `next', `open_cnt', `deleted',
147         `type', `open_mode', `aux', `identity' members.  Change `id' from
148         char array to char *.  Add `ref_cnt' member.
149         (file_handle_from_ll) New function.
150         (file_handles) Removed.
151         (named_handles) New variable.
152         (fh_init) Initialize named_handles.
153         (fh_done) Remove name from all named_handles.
154         (free_handle) Updated for modified struct file_handle.
155         (unname_handle) New function.
156         (fh_ref) New function.
157         (fh_from_file_name) Removed.
158         (fh_unref) New function.
159         (fh_unname) New function.
160         (fh_from_id) Rewritten.
161         (create_handle) Updated for modified struct file_handle.
162         (fh_inline_file) Increment the handle's ref count.
163         (fh_create_file) Updated for modified struct file_handle.
164         (fh_create_scratch) Ditto.
165         (fh_free) Removed.
166         (mode_name) Removed.
167         (fh_open) Removed.
168         (fh_close) Removed.
169         (fh_is_open) Removed.
170         (fh_get_id) Updated for modified struct file_handle.
171         (fh_get_default_handle) Increment the handle's ref count.
172         (fh_set_default_handle) Handle ref counts.
173         (struct fh_lock) New structure.
174         (locks) New static var.
175         (fh_lock) New function.
176         (fh_unlock) New function.
177         (fh_lock_get_aux) New function.
178         (fh_lock_set_aux) New function.
179         (fh_is_locked) New function.
180         (make_key) New function.
181         (free_key) New function.
182         (compare_fh_locks) New function.
183         (hash_fh_lock) New function.
184
185         * file-handle-def.h (enum fh_access) New enum.
186
187         * file-name.c: Made file_identity the same in all supported
188         environments.
189         (struct file_identity): New `name' member.
190         (fn_get_identity): For a file that doesn't exist, get the
191         dev/inode of its directory plus its name.  If even the directory
192         doesn't exist, just use its name.  Merge the Windows
193         implementation into the Unix one.
194         (fn_compare_file_identities): Rewritten.  Merge the Windows
195         implementation into the Unix one.
196         (fn_hash_identity): New function.
197
198         * make-file.c (struct replace_file): New structure.
199         (all_files): New static var.
200         (replace_file_start): New function.
201         (replace_file_commit): New function.
202         (replace_file_abort): New function.
203         (free_replace_file): New function.
204         (unlink_replace_files): New function.
205
206         * por-file-reader.c (struct pfm_reader): Add `lock' member.
207         (close_reader): Unlock file.
208         (pfm_open_reader): Lock file.
209
210         * por-file-writer.c (struct pfm_writer): Add fh_lock, replace_file
211         members.
212         (pfm_open_writer): Lock file and prepare for its replacement.
213         (close_writer): Unlock file.
214
215         * scratch-handle.h (struct scratch_handle): Add unique_id so that
216         different generations of a scratch file can be distinguished.
217
218         * scratch-reader.c (scratch_reader_open): Verify that the file is
219         a scratch file.
220
221         * scratch-writer.c (struct scratch_writer): Add `lock' and `dict',
222         remove scratch_handle member.
223         (scratch_writer_open): Lock handle.  Prepare to replace handle
224         data, instead of doing it immediately.
225         (scratch_writer_casewriter_destroy): Replace handle data and
226         unlock handle.
227
228         * sys-file-reader.c (struct sfm_reader): Add `lock' member.
229         (sfm_open_reader): Lock file.
230         (close_reader): Unlock file.
231
232         * sys-file-writer.c (struct sfm_writer): Add fh_lock, replace_file
233         members.
234         (sfm_open_writer): Lock file and prepare for its replacement.
235         (close_writer): Unlock file.
236
237 2007-11-02  Ben Pfaff  <blp@gnu.org>
238
239         * data-out.c (output_number): Use isfinite (from C99) instead of
240         gsl_isfinite, since we now have universal support for it in
241         gnulib.
242         (output_infinite): Ditto.
243         [!HAVE_ROUND] (round): Remove definition, since we now have a
244         replacement in gnulib.
245
246 2007-10-27  John Darrington <john@darrington.wattle.id.au>
247
248         * dictionary.c: Fixed bug in dict_clone, where the vardict.dict member
249         wasn't initialised correctly. Closes bugs #21330 and 21397
250
251
252 2007-10-08  Ben Pfaff  <blp@gnu.org>
253
254         Fix bug #21280.  Thanks to John Darrington for review.
255
256         * file-name.c (create_stream): New function.
257
258         * por-file-writer.c (pfm_open_writer): Use fh_open to open the
259         file handle before creating the file, to ensure that we don't
260         truncate a file that we're reading.  Make code easier to read by
261         using create_stream.
262
263         * sys-file-write.c (sfm_open_writer): Ditto.
264
265 2007-10-01  Ben Pfaff  <blp@gnu.org>
266
267         Fix bug #21192.  Thanks to John Darrington for review.
268
269         * casereader.c (casereader_read): Decrement case_cnt before
270         calling the casereader's "read" member function, so that we
271         interact properly with lazy_casereader.
272
273         * datasheet.c: Add regression test for above bug fix.
274         (clone_datasheet): New function.
275         (lazy_callback): New function.
276         (check_datasheet_casereader): New function.
277         (check_datasheet): Check datasheet contents are reported correctly
278         through an ordinary casereader and a lazy casereader.
279         (clone_model): Use clone_datasheet.
280
281 2007-09-24  Ben Pfaff  <blp@gnu.org>
282
283         Patch #6210.  Reviewed by John Darrington.
284         * settings.c: Drop "long view", which is not needed any longer.
285         (static var long_view): Removed.
286         (force_long_view): Removed.
287         (get_viewwidth): Removed.
288         (init_viewport): Removed long_view reference.
289
290 2007-09-19  John Darrington <john@darrington.wattle.id.au>
291         
292         * settings.c settings.h: Changed viewport's length and width to be 
293         owned by the user interface which uses the data library.  This allows
294         better abstraction, and makes dynamically adjustable dimensions easier.
295         
296 2007-09-18  Ben Pfaff  <blp@gnu.org>
297
298         * procedure.c (proc_extract_active_file_data): New function.
299
300         * lazy-casereader.h: New file.
301
302         * lazy-casereader.c: New file.
303
304         * casereader.c (casereader_dynamic_cast): New function.
305
306 2007-09-14  Ben Pfaff  <blp@gnu.org>
307
308         * dictionary.c (dict_clone): Copy case indexes from cloned
309         dictionary.  Fixes bug #21061.  Reviewed by John Darrington.
310
311 2007-09-13  John Darrington <john@darrington.wattle.id.au>
312
313         * value.c value.h (create_value): New function.
314
315 2007-09-12  Ben Pfaff  <blp@gnu.org>
316
317         Make it clear that translator casereader and casewriter translate
318         functions are supposed to destroy their input case.
319         
320         * casereader-translator.c (struct casereader_translator): Change
321         input case parameter of translate member function from const
322         struct ccase * to struct ccase *.
323         (casereader_create_translator): Ditto, for translate parameter.
324
325         * casewriter-translator.c (struct casewriter_translator): Ditto.
326         (casewriter_create_translator): Ditto.
327
328 2007-08-27  John Darrington <john@darrington.wattle.id.au>
329         
330         * sys-file-reader.c (read_display_parameters): Force display width 
331         to 8, if the sys file says 0 (like SPSS does).
332
333 2007-08-12  Ben Pfaff  <blp@gnu.org>
334
335         * dictionary.c (dict_dump): New function.
336
337 2007-08-12  Ben Pfaff  <blp@gnu.org>
338
339         Drop dict_compactor in favor of using the new struct case_map.
340
341         * dictionary.c (struct copy_map): Removed.
342         (struct dict_compactor): Removed.
343         (dict_make_compactor): Removed.
344         (dict_compactor_compact): Removed.
345         (dict_compactor_destroy): Removed.
346
347         * procedure.c (struct data_set): Change `compactor' member to be a
348         struct case_map *.
349         (proc_open): Use case_map_to_compact_dict instead of
350         dict_make_compactor.
351         (proc_casereader_read): Use case_map_execute instead of
352         dict_compactor_compact.
353         (proc_commit): Use case_map_destroy instead of
354         dict_compactor_destroy.
355
356         * scratch-writer.c (struct scratch_writer): Change `compactor'
357         member to be a struct case_map *.
358         (scratch_writer_open): Use case_map_to_compact_dict instead of
359         dict_make_compactor.
360         (scratch_writer_casewriter_write): Use case_map_execute instead of
361         dict_compactor_compact.
362
363 2007-08-12  Ben Pfaff  <blp@gnu.org>
364
365         * automake.mk: Add case-map.c, case-map.h.
366
367         * case-map.c: New file.
368
369         * case-map.h: New file.
370
371 2007-08-12  Ben Pfaff  <blp@gnu.org>
372
373         * dictionary.c (dict_compact_values): Don't delete scratch
374         variables as well as compacting case indexes.  Update all callers.
375         (dict_get_compacted_value_cnt): Rename dict_count_values and
376         change interface.  Update all callers.
377         (dict_get_compacted_value_cnt): Remove.
378         (dict_compacting_would_shrink): Remove.
379         (dict_compacting_would_change): Remove.
380         (dict_make_compactor): Add new parameter.  Update all callers.
381         
382         * procedure.c (proc_casereader_read): Use casewriter_get_value_cnt
383         instead of dict_count_values, changing an O(N) operation into
384         O(1).
385
386 2007-08-12  Ben Pfaff  <blp@gnu.org>
387
388         * casereader.c (casereader_read): Don't require cases read by a
389         casereader to be exactly the expected size: as long as they're big
390         enough, it's OK.
391
392 2007-08-12  Ben Pfaff  <blp@gnu.org>
393
394         Make casewriters keep track of the number of `union value's in
395         each case.  This is useful for two reasons: casewriter_write can
396         then check that the case being written is large enough, and later
397         recipients of the casewriter can determine the size of the case.
398         
399         * casewriter-translator.c (casewriter_create_translator): Add
400         value_cnt parameter.
401         
402         * casewriter.c (struct casewriter): Add value_cnt member.
403         (casewriter_write): Check that the case passed in is big enough.
404         (casewriter_get_value_cnt): New function.
405         (casewriter_create): Add value_cnt parameter.
406
407 2007-08-09  Ben Pfaff  <blp@gnu.org>
408
409         Fix bug reported by Jason Stover.
410         * settings.c: Move get_termcap_viewport and in particular the
411         #include for <curses.h> to the end of the file.  curses.h
412         redefines bool on some systems (e.g. OpenBSD), which causes
413         disagreement between uses of bool before its inclusion and
414         afterward.
415         Tested by Jason Stover.
416
417 2007-07-29  Ben Pfaff  <blp@gnu.org>
418
419         Provisional fix for bug #18692 and bug #20161.  Reviewed by John
420         Darrington.
421
422         * file-name.c (fn_open): Only pass "r" or "w" to popen as mode
423         argument (never "rb" or "wb") because SUSv3 says that only those
424         modes are defined, and glibc in fact rejects other modes.
425
426         Open portable files with fn_open so that they can be read from
427         pipes.  Fix missing fh_close call to go along with fh_open.
428         Report an error if the file close reports an error.
429         * por-file-reader.c (close_reader): New function.
430         (por_file_casereader_destroy): Use close_reader.
431         (pfm_open_reader): Open file with fn_open.
432
433 2007-07-28  Ben Pfaff  <blp@gnu.org>
434
435         Make PSPP able to read all the portable files I could find on the
436         web.  Thanks to John Darrington for review.  Bug #17620.
437         * por-file-reader.c (struct pfm_reader): New member `line_length'.
438         (error): Print file offset in hexadecimal.
439         (warning): New function.
440         (advance): Treat lines less than 80 bytes long as padded to 80
441         bytes with spaces.
442         (pfm_open_reader): Call read_documents if we find an "E" record.
443         (convert_format): Convert invalid formats to the default format
444         instead of aborting reading the file.
445         (read_variables): Rename duplicate variable names instead of
446         aborting reading the file.
447         (read_value_label): Allow string variables of different widths to
448         be assigned value labels in the same record.  Replace duplicate
449         value labels instead of aborting.
450         (read_documents): New function.
451
452         * por-file-writer.c (pfm_open_writer): Call write_documents if the
453         dictionary has documents.
454         (write_documents): New function.
455
456 2007-07-25  Ben Pfaff  <blp@gnu.org>
457
458         Fix bugs related to bug #17213.
459
460         * settings.c: Use HAVE_LIBNCURSES instead of HAVE_LIBTERMCAP,
461         since the former is what config.h has.  Include the needed ncurses
462         headers.
463         (static var echo) Rename to `do_echo' because the original name is
464         the same as an ncurses identifier.
465         (get_termcap_viewport) Use error instead of msg.
466
467         * file-name.c (fn_interp_vars): Fix interpolation of $VARS.
468         (fn_close): Don't close stdin, stdout, stderr.
469
470 2007-07-26 John Darrington <john@darrington.wattle.id.au>
471
472         * procedure.c procedure.h: Added callbacks which get invoked whenever 
473         a dataset's transformation chain changes.
474
475 2007-07-24  Ben Pfaff  <blp@gnu.org>
476
477         Fix bug #6113.
478         * sys-file-writer.c (write_variable_display_parameters): Use new
479         var_default_display_width function to choose display width of
480         segments after the first one in a given variable.
481         * variable.c (var_create): Use var_default_display_width to pick
482         new variable's display width.
483         (var_default_display_width): New function.
484         Reviewed by John Darrington.
485
486 2007-07-24  Ben Pfaff  <blp@gnu.org>
487
488         Fix bug #20427.
489         * por-file-writer.c (write_variables): Write weight variable.
490         Reviewed by John Darrington.
491
492 2007-07-23  Ben Pfaff  <blp@gnu.org>
493
494         Improvements to system file reader and writer.
495         
496         First, move all detailed knowledge of very long strings into
497         sys-file-private.[ch], so that this nasty stuff can be isolated.
498
499         * sys-file-private.c (REAL_VLS_CHUNK): New macro.
500         (EFFECTIVE_VLS_CHUNK): New macro.
501         (min_int): New function.
502         (max_int): New function.
503         (sfm_width_to_bytes): Rewrite.
504         (sfm_width_to_octs): New function.
505         (sfm_segment_alloc_width): New function.
506         (sfm_segment_alloc_bytes): New function.
507         (sfm_segment_used_bytes): New function.
508         (sfm_segment_offset): New function.
509         (sfm_segment_effective_offset): New function.
510         (sfm_dictionary_to_sfm_vars): New function.
511
512         * sys-file-private.h (MIN_VERY_LONG_STRING): Removed.
513         (EFFECTIVE_LONG_STRING_LENGTH): Removed.
514         (struct sfm_var): New structure.
515
516         Next, improvements to the system file reader.
517
518         * sys-file-reader.h (struct sfm_read_info): Changed `case_cnt' to
519         type casenumber.  Added `version_major', `version_minor',
520         `version_revision'.
521
522         * sys-file-reader.c (struct sfm_reader): Replaced `flt64_cnt' by
523         `oct_cnt'.  Rename `vars', `var_cnt' to `sfm_vars', `sfm_var_cnt'.
524         Change `case_cnt' to type casenumber.  Removed `has_vls'.
525         (struct sfm_var): Removed.
526         (sfm_open_reader): Don't warn on wrong case size if the file was
527         written by SPSS 13, which tends to get it wrong.  Use
528         sfm_dictionary_to_sfm_vars.
529         (read_header): Always output system file info.
530         (read_variable_record): Simplify code for reading missing values.
531         (read_machine_int32_info): Save version numbers from system file
532         into info struct passed as new argument.
533         (read_long_string_map): Restructured to use new sys-file-private
534         functions.
535         (read_value_labels): Use size_overflow_p.
536         (sys_file_casereader_read): Get rid of distinction between fast
537         and slow paths.  Use information provided by sys-file-primate's
538         struct sfm_var to simplify code.
539         (skip_whole_strings): New function.
540         (read_int32): Renamed read_int.  Changed return value to int.
541         Updated all callers.
542         (read_flt64): Renamed read_float.  Changed return value to
543         double.  Updated all callers.
544         (int32_to_native): Removed.  Changed callers to use
545         integer_convert.
546         (flt64_to_double): Removed.  Changed callers to use float_convert.
547         
548         Finally, get rid of int32, flt64 terminology and types in system
549         file writer.  The former wasn't very useful since a POSIX "int"
550         can hold the whole range of int32 and we generally didn't have a
551         need for it to be exactly-32-bits, just at-least-32-bits.  The
552         latter was inconvenient because we had to assume that it could be
553         different from double and thereby convert special values SYSMIS,
554         HIGHEST, LOWEST to and from it in multiple places.  Instead, now
555         we just use "int" and "double" in most places, and do conversions,
556         if necessary, very close to where we do I/O.  This change meant
557         that the writer code couldn't represent records in the file as C
558         structs any longer, but that's no great loss.  The code actually
559         seems to be more readable without them.
560
561         Simplify the compression buffering code: only buffer as much as
562         necessary, which is no more than eight 8-byte units at any given
563         time.
564
565         * sys-file-writer.c (typedef flt64): Removed.
566         (macro second_lowest_flt64): Removed.
567         (struct sysfile_header): Removed.
568         (struct sysfile_variable): Removed.
569         (struct sfm_writer): Removed `needs_translation', `has_vls',
570         `flt64_cnt'.  Changed `compress' to type bool and `case_cnt' to
571         type casenumber.  Renamed `vars' to `sfm_vars', `var_cnt' to
572         `sfm_var_cnt'.  Replaced `buf', `end', `ptr', `x', `y' for
573         compression buffering by `opcodes', `opcode_cnt', `data',
574         `data_cnt'.  Renamed `var_cnt_vls' as `segment_cnt'.
575         (sfm_open_writer): Use sfm_dictionary_to_sfm_vars.  Use simple
576         data writer functions instead of structures.
577         (calc_oct_idx): New function.
578         (write_header): Use simple data writer functions instead of
579         structures.
580         (write_format_spec): Renamed write_format.  New argument.
581         (write_variable_continuation_records): New function.
582         (write_variable): Use simple data writer functions instead of
583         structures.  Use write_variable_continuation_records.  Write
584         entire very long string instead of requiring caller to understand
585         them.
586         (write_value_labels): Use simple data writer functions instead of
587         structures.
588         (write_documents): Ditto.
589         (write_variable_display_parameters): Use sys-file-private
590         functions to simplify.  Use simple data writer functions instead
591         of structures.
592         (write_vls_length_table): Use simple data writer functions instead
593         of structures.
594         (write_longvar_table): Ditto.
595         (write_rec_7_34): Break into new functions
596         write_integer_info_record, write_float_info_record.  Use simple
597         data writer functions instead of structures.
598         (buf_write): Removed.
599         (append_string_max): Removed.
600         (ensure_buf_space): Removed.
601         (sys_file_casewriter_write): Get rid of the distinction between
602         fast and slow paths, which didn't seem to be too useful.  Use new
603         functions write_case_uncompressed, write_case_compressed.
604         (put_instruction): Removed.
605         (put_element): Removed.
606         (write_compressed_data): Removed.
607         (close_writer): Use flush_compressed.  Only write case count to
608         system file if it will fit in the field.
609         (write_case_compressed): New function.
610         (write_case_uncompressed): New function.
611         (flush_compressed): New function.
612         (put_cmp_opcode): New function.
613         (put_cmp_number): New function.
614         (write_int): New function.
615         (convert_double_to_output_format): New function.
616         (write_float): New function.
617         (write_value): New function.
618         (write_string): New function.
619         (write_bytes): New function.
620         (write_zeros): New function.
621         (write_spaces): New function.
622
623         Reviewed by John Darrington.
624
625 2007-07-22  Ben Pfaff  <blp@gnu.org>
626
627         Don't try to write very long strings to portable files.  The
628         format does not support it.
629
630         * por-file-writer.c (MAX_POR_WIDTH): New macro.
631         (pfm_open_writer): Limit output width to MAX_POR_WIDTH.
632         (write_format): Add arg to take width to resize format to.
633         (write_value): Limit width of value written to MAX_POR_WIDTH.
634         (write_variables): Limit width of variable and its output formats
635         to MAX_POR_WIDTH.
636         Reviewed by John Darrington.
637
638 2007-07-22  Ben Pfaff  <blp@gnu.org>
639
640         * sys-file-reader.c (read_variable_to_value_map): Use max_warnings
641         local variable instead of literal 5.
642         Reviewed by John Darrington.
643         
644 2007-07-22  Ben Pfaff  <blp@gnu.org>
645
646         Fix problems with uniqueness of short names in system files with
647         very long string variables.  Now a variable may have multiple
648         short names.
649         
650         * automake.mk (src_data_libdata_a_SOURCES): Add new files
651         short-names.c, short-names.h.
652
653         * dictionary.c (dict_clone): Clone all the short names.
654         (compare_strings): Move into short-names.c.
655         (hash_strings): Ditto.
656         (set_var_short_name_suffix): Ditto.
657         (dict_assign_short_names): Ditto, rename short_names_assign,
658         change to assign all short names.
659         
660         * por-file-writer.c (write_variables): Use short_names_assign
661         instead of dict_assign_short_names.
662
663         * short-names.c: New file.
664
665         * short-names.h: New file.
666
667         * sys-file-private.c (sfm_width_to_segments): New function.
668
669         * sys-file-reader.c (read_long_var_name_map): Save and restore all
670         the short names, not just the first one.
671         
672         * sys-file-writer.c (cont_var_name): Removed.
673         (sfm_open_writer): Use short_names_assign instead of
674         dict_assign_short_names.  Use unique short names assigned by
675         short_names_assign instead of those generated by cont_var_name.
676
677         * variable.c (struct variable): Remove `short_name' member,
678         replace by `short_names' and `short_name_cnt'.
679         (var_create) Initialize new members.
680         (var_get_short_name_cnt): New function.
681         (var_get_short_name): Now takes an index argument.  Changed most
682         callers to pass 0.
683         (var_set_short_name): Ditto.
684         (var_clear_short_name): Renamed var_clear_short_names, changed to
685         clear all short names.
686         
687         Reviewed by John Darrington.
688
689 2007-07-22  Ben Pfaff  <blp@gnu.org>
690
691         * variable.c (var_set_width): Use new var_set_width function.
692
693         * missing-values.c (mv_n_values): Drop assertion, which was not
694         needed.
695
696         * format.c (fmt_default_for_width): New function.
697         (fmt_resize): New function.
698
699         Reviewed by John Darrington.
700
701 2007-07-18 John Darrington <john@darrington.wattle.id.au>
702
703         * datasheet.c (datasheet_delete_columns): Added assertion to check
704         we're not deleting outside the range of the sheet.  
705
706         
707         * dictionary.c dictionary.h variable.c: Added the ability for string
708         variables to be resized.
709         
710         * vardict.h: Added some prototypes (moved from dictionary.h) as
711         these should only be called by variable.c
712
713
714 2007-07-14 John Darrington <john@darrington.wattle.id.au>
715
716         * sfm-reader.c: Respect case_cnt field in file header.
717
718 2007-07-01 John Darrington <john@darrington.wattle.id.au>
719
720         * transformation.c transformation.h (trns_chain_execute): Changed the 
721         signature (Patch #6057)
722
723 2007-06-10  Ben Pfaff  <blp@gnu.org>
724
725         * casereader-filter.c (casereader_filter_destroy): Make sure to
726         write all the remaining excluded cases to the casewriter, if any.
727
728         * caseinit.c (init_list_destroy): Rewrite.
729         (init_list_clear): Ditto.
730
731         * casegrouper.c (casegrouper_get_next_group): Always set *reader
732         to null when returning false.
733
734 2007-06-06  Ben Pfaff  <blp@gnu.org>
735
736         Actually implement the new procedure code and adapt all of its
737         clients to match.  Also adapt all of the other case sources and
738         sinks in the tree and their clients to use the
739         casereader/casewriter infrastructure.
740
741         * automake.mk: Add and remove files.
742
743         * any-reader.c: Change into a casereader.
744         * por-file-reader.c: Ditto.
745         * scratch-reader.c: Ditto.
746         * sys-file-reader.c: Ditto.
747
748         * any-writer.c: Change into a casewriter.
749         * por-file-writer.c: Ditto.
750         * scratch-writer.c: Ditto.
751         * sys-file-writer.c: Ditto.
752
753         * procedure.c: Change to use casereader, casewriter, caseinit, and
754         other new infrastructure.
755
756         * scratch-handle.c: Adapt to new infrastructure.
757
758         * case-sink.c: Removed, now dead code.
759         * case-sink.h: Ditto.
760         * case-source.c: Ditto.
761         * case-source.h: Ditto.
762         * casefile-factory.c: Ditto.
763         * casefile-private.h: Ditto.
764         * casefile.c: Ditto.
765         * casefile.h: Ditto.
766         * casefilter.c: Ditto.
767         * casefilter.h: Ditto.
768         * fastfile.c: Ditto.
769         * fastfile.h: Ditto.
770         * fastfile-factory.c: Ditto.
771         * fastfile-factory.h: Ditto.
772         * storage-stream.c: Ditto.
773         * storage-stream.h: Ditto.
774
775 2007-06-06  Ben Pfaff  <blp@gnu.org>
776
777         Add datasheet code.
778
779         * automake.mk: Add new files.
780
781         * datasheet.c: New file.
782
783         * datasheet.h: New file.
784
785 2007-06-06  Ben Pfaff  <blp@gnu.org>
786
787         Until now, the procedure code has provided a case to the
788         case_source, which has filled in the data values that come from
789         the active file.  "Left" data values that don't come from the
790         active file naturally stay the same from case to case, because the
791         procedure code keeps using that same case.
792
793         One of the compromises that comes with the new procedure code is
794         that the active file allocates and provides its own case, which
795         the procedure code then has to resize to provide room for any
796         other variables that should go in the case and then fill in the
797         values of "left" variables.  Then, when we're done with that case,
798         we have to save the values of "left" variables to copy into the
799         next case read from the active file.
800
801         The caseinit code helps with this.
802
803         * automake.mk: Add new files.
804
805         * caseinit.c: New file. 
806
807         * caseinit.h: New file. 
808
809 2007-06-06  Ben Pfaff  <blp@gnu.org>
810
811         * value.h (value_cnt_from_width): New function.
812
813         * variable.c (var_get_value_cnt): Use new function.
814
815 2007-06-06  Ben Pfaff  <blp@gnu.org>
816
817         Add casegrouper, to allow cases read from a given casereader to be
818         broken into groups, each of which has its own casereader.
819         Generally cases are grouped based on having equal values for some
820         set of variables.
821
822         * automake.mk: Add new files.
823
824         * casegrouper.c: New file.
825
826         * casegrouper.h: New file.
827
828 2007-06-06  Ben Pfaff  <blp@gnu.org>
829
830         Add interface to lexicographical ordering of cases.
831
832         * automake.mk: Add new files.
833
834         * case-ordering.c: New file.
835
836         * case-ordering.h: New file.
837
838 2007-06-06  Ben Pfaff  <blp@gnu.org>
839
840         Add casereaders and casewriters, the basis of the new data processing
841         implementation.  A casereader is a uniform interface to reading cases
842         from a data source; a casewriter is a uniform interface to writing
843         cases to a data sink.
844
845         * automake.mk: Add new files.
846         
847         * casereader-filter.c: New file.
848         
849         * casereader-provider.h: New file.
850
851         * casereader-translator.c: New file.
852         
853         * casereader.c: New file.
854         
855         * casereader.h: New file.
856         
857         * casewriter-provider.h: New file.
858         
859         * casewriter-translator.c: New file.
860         
861         * casewriter.c: New file.
862         
863         * casewriter.h: New file.
864
865 2007-06-06  Ben Pfaff  <blp@gnu.org>
866
867         "casewindow" data structure that extends the deque (from libpspp)
868         of cases with the ability to dump cases to disk if we get too many
869         of them in memory.
870
871         * automake.mk: Add new files.
872
873         * casewindow.c: New file.
874
875         * casewindow.h: New file.
876
877 2007-06-06  Ben Pfaff  <blp@gnu.org>
878
879         sparse_cases data structure that augments a sparse_array of cases
880         with the ability to dump cases to disk if we get too many cases in
881         memory.
882
883         * automake.mk: Add new files.
884
885         * sparse-cases.c: New file.
886
887         * sparse-cases.h: New file.
888
889 2007-06-06  Ben Pfaff  <blp@gnu.org>
890
891         Adds a low-level on-disk case array data structure.
892         
893         * automake.mk: Add new files.
894
895         * case-tmpfile.c: New file.
896
897         * case-tmpfile.h: New file.
898
899 2007-06-06  Ben Pfaff  <blp@gnu.org>
900
901         In a couple of places we calculate the maximum number of cases to
902         keep in memory based on the user-defined workspace.  Enable
903         centralizing the calculation through a new function.
904         
905         * settings.c (get_workspace_cases): New function.
906
907 2007-06-06  Ben Pfaff  <blp@gnu.org>
908
909         The casenumber type is defined in transformations.h, but case.h is
910         a more sensible place.  Move it.
911
912         * case.h (CASENUMBER_MAX): New macro.
913         (typedef casenumber): Move here, from transformations.h.
914
915 2007-06-03  Ben Pfaff  <blp@gnu.org>
916
917         Slightly generalize case_to_values and case_from_values functions.
918
919         * case.c (case_to_values): Rename case_copy_out, change interface.
920         (case_from_values): Rename case_copy_in, change interface.
921
922         * fastfile.c (fastfilereader_get_next_case): Update caller.
923         (write_case_to_disk): Ditto.
924
925 2007-06-02  Ben Pfaff  <blp@gnu.org>
926
927         Clean up after a forgotten part of patch #5829.
928         
929         * casedeque.h: Remove unused file.
930
931         * automake.mk: Remove casedeque.h from sources.
932
933 2007-05-10  Jason Stover  <jhs@math.gcsu.edu>
934
935         * category.c: Removed redundant #include
936
937 2007-05-06  Ben Pfaff  <blp@gnu.org>
938
939         Abstract the documents within a dictionary a little better.
940         Thanks to John Darrington for suggestion, initial version, and
941         review.  Patch #5917.
942
943         * dictionary.c (struct dictionary): Change `documents' member from
944         char * to struct string.
945         (dict_clear): Destroy struct string.
946         (dict_get_documents): Convert struct string to char *.
947         (dict_set_documents): Set struct string.  Pad to 80-character
948         multiple.
949         (dict_clear_documents): New function.
950         (dict_add_document_line): New function.
951         (dict_get_document_line_cnt): New function.
952         (dict_get_document_line): New function.
953
954         * dictionary.h (macro DOC_LINE_LENGTH): New macro.
955
956         * sys-file-reader.c (read_documents): Use new document functions.
957
958 2007-04-19 John Darrington <john@darrington.wattle.id.au>
959
960         * sys-file-reader.c: When reading a system file which has no 
961         long name table, automatically create one where the long names 
962         are the lower case versions of the short names.
963         
964 2007-04-22  Ben Pfaff  <blp@gnu.org>
965
966         * dictionary.c (dict_set_split_vars): dict_destroy expects that
967         dict_clear will free most data related to the dictionary.
968         dict_clear does a decent job, except that dict_set_split_vars on
969         some systems won't actually free the dict's "split" member.
970         Instead, it'll allocate a 1-byte region.  Fix this.
971
972         * value.c (value_copy): New function.
973         (value_set_missing): Ditto.
974
975 2007-04-22 John Darrington <john@darrington.wattle.id.au>
976
977         * Deleted existing category.h and moved cat-routines.h into 
978         category.h  Encapsulated struct cat_vals better.
979
980 2007-04-19 John Darrington <john@darrington.wattle.id.au>
981
982         * sys-file-reader.c: When reading a system file which has no 
983         long name table, automatically create one where the long names 
984         are the lower case versions of the short names.
985         
986 2007-04-16 John Darrington <john@darrington.wattle.id.au>
987
988         * sys-file-reader.c: Some versions of Other Software seem to 
989         produce system files with string  variables' measure set to 
990         zero.  We'll assume these are supposed to be nominal variables.
991
992 2007-03-30  Ben Pfaff  <blp@gnu.org>
993
994         * procedure.c: Adapt to new deque data structure.
995
996 Mon Feb 19 10:53:21 2007  John McCabe-Dansted <gmatht@gmail.com>
997                           Ben Pfaff <blp@gnu.org>
998
999         * file-name.c: Mingw compatibility fixes.
1000         (fn_search_path): Use ISSLASH instead of comparing against '/'
1001         directly.
1002         (fn_dir_name): Use dir_name from gnulib.
1003         (fn_is_absolute): Use IS_ABSOLUTE_FILE_NAME from gnulib.
1004         (fn_get_identity): Use GetFullPathName instead of canonicalize
1005         from gnulib, because the latter does not fully support
1006         Windows-style path names.  Use this implementation based on the
1007         detected presence of Windows instead of the absence of Unix, since
1008         the new implementation is Windows-specific.
1009         (fn_compare_file_identities): In Windows implementation, compare
1010         names case-insensitively.
1011
1012 Sun Feb 18 13:28:02 2007  Ben Pfaff  <blp@gnu.org>
1013
1014         * make-file.c: Don't include mkstemp.h, because gnulib now causes
1015         <stdlib.h> to have the same effect.
1016
1017 Sun Feb 18 11:20:24 2007  Ben Pfaff  <blp@gnu.org>
1018
1019         * por-file-reader.c: Add missing _() around messages.
1020
1021 Sun Feb 11 20:44:13 2007  Ben Pfaff  <blp@gnu.org>
1022
1023         * make-file.c: Include "mkstemp.h", without which linking on
1024         mingw32 fails.
1025
1026 Thu Feb  8 14:59:05 2007  Ben Pfaff  <blp@gnu.org>
1027  
1028         Reduce platform dependence.
1029  
1030         * file-name.c (fn_tilde_expand): Removed, and removed calls to it.
1031         Everywhere we using this, we really should have just depended on
1032         the shell to expand tildes.
1033         (fn_search_path): Simplify, given that we don't do tilde expansion
1034         any longer.
1035         (fn_normalize): Removed.  Caller changed to use the canonicalize
1036         module from gnulib.
1037         (fn_get_cwd): Removed.  Only user was fn_normalize.
1038         (fn_is_absolute): Really only test for absolute names.
1039         (fn_is_special): Use pipe files if HAVE_POPEN, not if we're in
1040         unix.
1041         (fn_readlink): Removed, as it was only used fn_normalize.
1042         (fn_exists): Assume the stat function is available; gnulib does.
1043         (fn_open): Use pipe files if HAVE_POPEN, not if we're in unix.
1044  
1045 Sat Feb  3 21:52:17 2007  Ben Pfaff  <blp@gnu.org>
1046
1047         * dictionary.c (dict_create_vector_assert): New function.
1048
1049 Wed Feb  7 21:25:15 2007  Ben Pfaff  <blp@gnu.org>
1050
1051         * file-name.c (fn_normalize): Correct name of function
1052         fn_is_special.  Thanks to John McCabe-Dansted <gmatht@gmail.com>
1053         for pointing this out.
1054
1055 Thu Feb  1 16:53:37 2007  Ben Pfaff  <blp@gnu.org>
1056
1057         We are using a single member in struct file_handle, the "name"
1058         field, for more than one purpose.  When it begins with '"', it's a
1059         file name; otherwise, it's a token that can be used to identify
1060         it.  When that assertion fires, it's because we searched for the
1061         name case-sensitively as a file name (so that there was no match),
1062         and then we try to insert it case-insensitively as a token, which
1063         fails because duplicates aren't allowed.
1064
1065         Solution: break the two purposes into two separate fields.  This
1066         fixes the problem and likely makes the code easier to read too.
1067
1068         Fixes bug #18922.  Thanks to John Darrington for bug report and
1069         review.
1070
1071         * file-handle-def.c (struct file_handle): New `id' member.
1072         (fh_from_name): Rename fh_from_id.  Update all callers.
1073         (create_handle): New `id' parameter.  Update all callers.
1074         (fh_create_file): Ditto.
1075         (fh_get_id): New function.
1076
1077 Mon Jan 15 16:18:10 2007  Ben Pfaff  <blp@gnu.org>
1078
1079         * case.c (case_is_null): Change return type to bool.
1080
1081 Mon Jan 15 10:57:28 2007  Ben Pfaff  <blp@gnu.org>
1082
1083         Add debugging code.
1084         
1085         * case.c (case_clone) [DEBUGGING]: When debugging, don't use
1086         reference counting to share data.  This makes it easy for
1087         valgrind, etc. to find accesses to cases that have been destroyed
1088         but have been kept around by another user's ref-count.  This often
1089         happens when the data set is small enough to find in memory; if a
1090         bigger data set that would overflow to disk were used, then data
1091         corruption would occur.
1092
1093 Mon Jan 15 10:55:18 2007  Ben Pfaff  <blp@gnu.org>
1094
1095         Simplify code.
1096
1097         * case.c (case_unshare): Make it check internally whether the
1098         ref_cnt is greater than 1, so that the callers don't have to.
1099         Update callers not to check.
1100
1101 Mon Jan 15 10:53:01 2007  Ben Pfaff  <blp@gnu.org>
1102
1103         Before, I was thinking that I might want to get rid of reference
1104         counting at some point.  Now, I'm pretty sure that it's here to
1105         stay.  Thus, because we have to store the value_cnt anyway for
1106         reference-counted cases, we might as well expose it to users.
1107
1108         * case.c (case_get_value_cnt): New function.
1109         (case_resize): Drop OLD_CNT argument.  Update all callers.  Only
1110         resize case if its size actually changed.
1111
1112         * casefile.c (casefile_append_xfer): Use case_get_value_cnt
1113         instead of peeking inside struct case directly.
1114         (casefile_append): Ditto.
1115
1116 Mon Jan 15 10:50:22 2007  Ben Pfaff  <blp@gnu.org>
1117
1118         Get rid of the inlines for the case functions, which made the
1119         header file hard to read.  (Also, in testing with "-O2 -DNDEBUG",
1120         the inlines didn't speed up "make check" at all, which is not a
1121         perfect benchmark but seems indicative.)
1122         
1123         * case.c: Remove #ifdef DEBUGGING...#endif around many function
1124         definitions.  Remove some assertions on nonnull pointers that were
1125         redundant with a pointer dereference soon after in the function.
1126         Also:
1127         (struct case_data): Move definition here from case.h.
1128         (case_data): Ditto.
1129         (case_num): Ditto.
1130         (case_str): Ditto.
1131         (case_data_wr): Ditto.
1132         
1133 Sun Jan 14 21:41:12 2007  Ben Pfaff  <blp@gnu.org>
1134
1135         * automake.mk: Add casedeque.h to sources.
1136         
1137         * casedeque.h: New file.
1138
1139         * procedure.c: (struct dataset) Change lag_count, lag_head,
1140         lag_queue member into single struct casedeque member.  Update all
1141         users to use the casedeque instead.
1142         (lag_case) Removed.
1143
1144 Sun Jan 14 21:43:12 2007  Ben Pfaff  <blp@gnu.org>
1145
1146         * procedure.c: Simplify lagged cases interface.  Updated all
1147         clients--well, the only client--to use the simplified interface.
1148         (dataset_n_lag) Removed.
1149         (dataset_set_n_lag) Removed.
1150         (dataset_need_lag) New function.
1151
1152 Tue Jan  9 07:20:05 WST 2007 John Darrington <john@darrington.wattle.id.au>
1153
1154         * dictionary.c procedure.c: More changes to ensure that callbacks occur
1155         whenever appropriate, but only when the dataset/dictionary is in a 
1156         consistent state.
1157
1158 Sun Jan  7 08:33:04 WST 2007 John Darrington <john@darrington.wattle.id.au>
1159
1160         * dictionary.c dictionary.h : Added callbacks for change of filter and 
1161         split variables.  Refactored some code to ensure that callbacks get
1162         invoked when appropriate.
1163
1164         * procedure.c (proc_cancel_temporary_transformations): Make sure that 
1165         replace_dict callback occurs when permanent_dict replaces the current
1166         dictionary.
1167
1168 Wed Jan  3 11:02:11 WST 2007 John Darrington <john@darrington.wattle.id.au>
1169
1170         * dictionary.c dictionary.h : Added callback for when the weight 
1171         variable of a dictionary changes.
1172
1173 Mon Jan  1 10:36:26 WST 2007 John Darrington <john@darrington.wattle.id.au>
1174
1175         * dictionary.c dictionary.h : Added replace_source and replace_dict
1176         callbacks, and functions to deal with them.
1177
1178 Fri Dec 22 13:56:08 2006  Ben Pfaff  <blp@gnu.org>
1179
1180         Simplify missing value handling.
1181
1182         * missing-values.h (enum mv_class): New type.
1183         (enum mv_type): Moved definition into missing-values.c and renamed
1184         each MV_* to MVT_*, to distinguish them from the exposed mv_class
1185         enums.  Updated all uses.
1186         (struct missing_values): Changed type of `type' from `enum
1187         mv_type' to `int' because the definition is no longer exposed.
1188         
1189         * missing-values.c (mv_is_value_missing): Add new enum mv_class
1190         parameter.  Update all callers.
1191         (mv_is_num_missing): Ditto.
1192         (mv_is_str_missing): Ditto.
1193         (mv_is_value_user_missing): Removed.  Changed callers to use
1194         mv_is_value_missing.
1195         (mv_is_num_user_missing): Removed.  Changed callers to use
1196         mv_is_num_missing.
1197         (mv_is_str_user_missing): Removed.  Changed callers to use
1198         mv_is_str_missing.
1199         (mv_is_value_system_missing): Removed.  Changed callers to use
1200         mv_is_value_missing.
1201         (mv_set_type): Removed.  Changed callers to use mv_clear.
1202         (mv_clear): New function.
1203         
1204         * variable.c (var_is_value_missing): Add new enum mv_class
1205         parameter.  Update all callers.
1206         (var_is_num_missing): Ditto.
1207         (var_is_str_missing): Ditto.
1208         (var_is_value_user_missing): Removed.  Changed callers to use
1209         var_is_value_missing.
1210         (var_is_num_user_missing): Removed.  Changed callers to use
1211         var_is_num_missing.
1212         (var_is_str_user_missing): Removed.  Changed callers to use
1213         var_is_str_missing.
1214         (var_is_value_system_missing): Removed.  Changed callers to use
1215         var_is_value_missing.
1216         
1217         * casefilter.c (struct casefilter): Use enum mv_class in place of
1218         bool.
1219         (casefilter_variable_missing): Adapt to new member.
1220         (casefilter_create): Change signature to take enum mv_class,
1221         update callers.
1222
1223 Fri Dec 22 20:08:38 WST 2006 John Darrington <john@darrington.wattle.id.au>
1224
1225         * casefile-factory.h fastfile-factory.c fastfile-factory.h: New files.
1226
1227         * case-sink.c case-sink.h procedure.c procedure.h 
1228           storage-stream.c: Now uses the factory.
1229         
1230 Sat Dec 16 22:05:18 2006  Ben Pfaff  <blp@gnu.org>
1231
1232         Make it possible to pull cases from the active file with a
1233         function call, instead of requiring indirection through a callback
1234         function.
1235
1236         * case-source.h (struct case_source_class): Change ->read function
1237         to return a single case, instead of calling a callback function
1238         for each case.  Change ->destroy function to return an error
1239         status.
1240
1241         * case-source.c (free_case_source): Pass along the value returned
1242         by the case_source ->destroy function.
1243
1244         * procedure.c (struct write_case_data): Removed.
1245         (struct dataset): Added some members to track procedure state.
1246         (procedure): Optimize the trivial case at this level.
1247         (internal_procedure): Re-implement in terms of proc_open,
1248         proc_read, proc_close.
1249         (proc_open) New function.
1250         (proc_read) New function.
1251         (proc_close) New function.
1252         (write_case) Moved into proc_read.
1253         (close_active_file) Moved closing of data source into proc_close.
1254
1255         * storage-source.c: Rewrote to conform with modified
1256         case_source_class interface.
1257
1258         * transformations.c (trns_chain_execute): Added argument to allow
1259         starting execution from an arbitrary transformation.  Updated
1260         callers.
1261
1262         * transformations.h (enum TRNS_NEXT_CASE) Renamed TRNS_END_CASE.
1263
1264 Sat Dec 16 14:09:25 2006  Ben Pfaff  <blp@gnu.org>
1265
1266         * sys-file-reader.c (read_display_parameters): Don't assume that
1267         MEASURE_* and ALIGN_* have the same values found in system files.
1268
1269         * sys-file-writer.c (write_variable_display_parameters): Ditto.
1270
1271         * variable.h: Change MEASURE_NOMINAL, MEASURE_ORDINAL,
1272         MEASURE_SCALE to be 0-based instead of 1-based.  This also fixes
1273         the value of n_MEASURES, which was off by 1 (at least from my
1274         point of view).
1275
1276 Sat Dec 16 12:17:34 WST 2006 John Darrington <john@darrington.wattle.id.au>
1277
1278         * dictionary.c dictionary.h vardict.h variable.c: Added optional
1279                 callbacks which are invoked when the dictionary or its 
1280                 variables are changed.  
1281         
1282         * missing-values.c missing-values.h value-labels.c: Tidied up
1283                 consistency checks, and made some of them return false 
1284                 instead of assert-failing. 
1285
1286 Wed Dec 13 19:30:11 2006  Ben Pfaff  <blp@gnu.org>
1287
1288         * calendar.c (calendar_days_in_month): New function.
1289
1290 Mon Dec 11 07:53:39 2006  Ben Pfaff  <blp@gnu.org>
1291
1292         * value-labels.c (hash_int_val_lab): Only hash as many bytes as
1293         the value label's width.
1294
1295 Sun Dec 10 14:21:29 2006  Ben Pfaff  <blp@gnu.org>
1296
1297         * sfm-private.h: Move contents into sys-file-writer.c, which is
1298         the only remaining user.  Removed Borland C++-specific directives.
1299         
1300         * sys-file-reader.c: Clean up and rewrite entire file.  The
1301         rewritten version is simpler and better abstracted, and should be
1302         easier to maintain and extend.  It avoids using structures to read
1303         file data, which is prone to padding variations among compilers.
1304         It should also handle non-IEEE 754 system files, although I
1305         haven't been able to find any.  It has been tested against many
1306         .sav files obtained from the Web and found to produce the same
1307         results as the earlier version of the code, or in some cases
1308         improved results.  It is more tolerant of format variations found
1309         in the wild.
1310
1311         * sys-file-reader.h (struct sfm_read_info): Removed `big_endian'
1312         member, putting an enum integer_format in its place.  New member
1313         `float_format'.  Changed `compressed' member to type bool.
1314
1315 Sun Dec 10 13:48:53 2006  Ben Pfaff  <blp@gnu.org>
1316
1317         * dictionary.c (dict_delete_consecutive_vars): New function.
1318
1319 Sat Dec  9 20:08:25 2006  Ben Pfaff  <blp@gnu.org>
1320
1321         * file-name.c (fn_search_path): Remove prefix arg that was unused
1322         by any caller.  Updated all callers.
1323
1324 Sat Dec  9 20:04:22 2006  Ben Pfaff  <blp@gnu.org>
1325
1326         * format.c (fmt_dollar_template): Use user's decimal point
1327         character.  Add assertion.
1328
1329 Sat Dec  9 20:02:25 2006  Ben Pfaff  <blp@gnu.org>
1330
1331         * format.c (fmt_dollar_template): New function, based on
1332         dollar_format_template from var-type-dialog.c.
1333
1334 Sat Dec  9 18:05:59 2006  Ben Pfaff  <blp@gnu.org>
1335
1336         * data-out.c (output_scientific): Fix bad assumption that "buf" is
1337         null-terminated.
1338         
1339 Sat Dec  9 17:23:23 2006  Ben Pfaff  <blp@gnu.org>
1340
1341         Finish converting struct variable to an opaque type.  In this
1342         phase, we add remaining setter and getter functions, convert the
1343         remaining PSPP code to use them, and do a bunch of cleanup.  The
1344         resulting changes are pervasive but mostly trivial, and only the
1345         notable changes are logged.
1346         
1347         * automake.mk (src_data_libdata_a_SOURCES): Add the new source
1348         files.
1349         
1350         * case.c (case_data): Renamed case_data_idx.
1351         (case_num): Renamed case_num_idx.
1352         (case_str): Renamed case_str_idx.
1353         (case_data_rw): Renamed case_data_rw_idx.
1354
1355         * case.h (case_data): New function with old name and an interface
1356         that takes a variable instead of an index, which is easier to
1357         use.  Updated all callers to use the new interface, or to use the
1358         new *_idx function (see above).
1359         (case_num): Ditto.
1360         (case_str): Ditto.
1361         (case_data_rw): Ditto.
1362         
1363         * category.c (cat_stored_values_destroy): Changed interface to
1364         take a struct cat_vals * instead of a struct variable *.
1365
1366         * dictionary.c (dict_clone): Use new vector_clone function.     
1367         (dict_clear) Use new var_destroy function.
1368         (add_var) New function.
1369         (dict_create_var) Rewrite in terms of dict_create_var_assert.
1370         (dict_create_var_assert) Rewrite in terms of add_var.
1371         (dict_clone_var) Rewrite in terms of dict_clone_var_assert.
1372         (dict_clone_var_assert) Rewrite in terms of var_clone, add_var.
1373         (dict_lookup_var) Use new var_create, var_destroy functions.
1374         (dict_contains_var) Rewrite in terms of new vardict functionality.
1375         (set_var_dict_index) New function.
1376         (set_var_case_index) New function.
1377         (reindex_vars) New function.
1378         (dict_delete_var) Rewrite in terms of new vardict functionality.
1379         (dict_reorder_var) Ditto.
1380         (dict_reorder_vars) Ditto.
1381         (rename_var) New function.
1382         (dict_rename_var) Use rename_var.
1383         (dict_rename_vars) Use pool to simplify code.  Use rename_var.
1384         (dict_get_compacted_idx_to_fv) Rename
1385         dict_get_compacted_dict_index_to_case_index, update callers.
1386         (dict_create_vector) Use new vector_create function.
1387         (dict_clear_vectors) Use new vector_destroy function.
1388         (set_var_short_name_suffix) Move here from variable.c, renamed
1389         from var_set_short_name_suffix, make static, update caller.
1390
1391         * sys-file-private.c: New file.  
1392         (sfm_width_to_bytes) Moved here from variable.c, renamed from
1393         width_to_bytes, update callers.
1394
1395         * sys-file-private.h: New file.  Later it will supplant
1396         sfm-private.h; for now it supplements it.
1397         (macro MIN_VERY_LONG_STRING) New macro.
1398         (macro EFFECTIVE_LONG_STRING_LENGTH) New macro, from value.h.
1399
1400         * sys-file-reader.c: Use MIN_VERY_LONG_STRING - 1 where
1401         MAX_LONG_STRING was used before.
1402
1403         * sys-file-writer.c: Ditto.
1404
1405         * value-labels.c: Change the paradigm here to be that a null
1406         pointer is OK for a struct val_labs * in most cases; it just
1407         represents an empty set of value labels.
1408         (val_labs_copy) A copy of a null set is a null set.
1409         (val_labs_count) A null set has 0 labels.
1410         (val_labs_replace) Change return type to void.  Rewrite for
1411         simplicity.
1412         (val_labs_find) A null set does not contain the value.
1413         (value_to_string) Moved to variable.c, renamed var_get_value_name,
1414         transposed argument order, updated all callers.
1415
1416         * value.c: New file.
1417         (value_dup) Moved here from variable.c.
1418         (compare_values) Ditto.
1419         (hash_value) Ditto.
1420
1421         * value.h: (macro MAX_SHORT_STRING) Rewrote for simplicity.
1422         (macro MAX_LONG_STRING) Removed, because it was only interesting
1423         for system files, not for general code.
1424         (macro MAX_VERY_LONG_STRING) Ditto.
1425         (macro EFFECTIVE_LONG_STRING_LENGTH) Moved to sys-file-private.h.
1426         (macro MAX_ELEMS_PER_VALUE) Removed, as it was unused.
1427
1428         * vardict.h: New file, for an interface between variables and
1429         their dictionaries.
1430
1431         * variable.c: A lot of functions were moved around, for better
1432         organization.
1433         (struct variable) Move definition here, from variable.h.
1434         (var_type_adj) Removed--makes i18n hard.
1435         (var_type_noun) Ditto.
1436         (var_create) New function.
1437         (var_clone) New function.
1438         (var_destroy) New function.
1439         (var_set_name) Assert that variable is not in a dictionary.
1440         (compare_var_names) Rename compare_vars_by_name and fix a couple
1441         of callers who thought the args were strings.
1442         (hash_var_name) Rename hash_var_by_name.
1443         (compare_var_ptr_names) Rename compare_var_ptrs_by_name.
1444         (hash_var_ptr_name) Rename hash_var_ptr_by_name.
1445         (var_is_very_long_string) Removed, because it was only interesting
1446         to system file code.
1447         (var_set_missing_values) Allow the argument to be the wrong width,
1448         as long as we can resize it.  Simplify callers who were doing the
1449         resizing themselves.
1450         (var_get_value_labels) New function.
1451         (var_has_value_labels) New function.
1452         (var_set_value_labels) New function.
1453         (alloc_value_labels) New function.
1454         (var_add_value_label) New function.
1455         (var_replace_value_label) New function.
1456         (var_clear_value_labels) New function.
1457         (var_lookup_value_label) New function.
1458         (var_get_value_name) Moved here from variable.c, renamed from
1459         var_get_value_name, transposed argument order, updated all
1460         callers.
1461         (var_to_string) Moved here, from variable-label.c.
1462         (var_set_leave) New function.
1463         (var_get_leave) New function.
1464         (var_must_leave) New function.
1465         (var_set_short_name_suffix) Moved to dictionary.c, renamed
1466         set_var_short_name_suffix.
1467         (var_get_dict_index) New function.
1468         (var_get_case_index) New function.
1469         (var_get_obs_vals) New function.
1470         (var_set_obs_vals) New function.
1471         (var_has_obs_vals) New function.
1472         (var_get_vardict) New function.
1473         (var_set_vardict) New function.
1474         (var_has_vardict) New function.
1475         (var_clear_vardict) New function.
1476         (value_dup) Moved to value.c.
1477         (compare_values) Ditto.
1478         (hash_value) Ditto.
1479
1480         * variable.h: (enum NUMERIC) Rename VAR_NUMERIC, update all users.
1481         (enum ALPHA) Rename VAR_STRING, update all users.
1482
1483         * vector.c: New file.
1484         (struct vector) Moved here, from variable.h.
1485         (check_widths) New function.
1486         (vector_create) New function.
1487         (vector_clone) New function.
1488         (vector_destroy) New function.
1489         (vector_get_name) New function.
1490         (vector_get_var) New function.
1491         (vector_get_var_cnt) New function.
1492         (compare_vector_ptrs_by_name) New function.
1493
1494         * vector.h: New file.
1495
1496 Sun Dec 10 11:32:56 WST 2006 John Darrington <john@darrington.wattle.id.au>
1497
1498         * casefilter.c (casefilter_variable_missing): Avoided comparision of
1499         string variables to SYSMIS.  Thanks to Ben Pfaff for reporting this
1500         problem.
1501
1502 Sat Dec  9 07:18:03 WST 2006 John Darrington <john@darrington.wattle.id.au>
1503
1504         * value-labels.c (destroy_atoms): New function.
1505         * value-labels.c (atom_create): Call destroy_atoms in atexit handler.
1506
1507 Thu Dec  7 17:38:26 2006  Ben Pfaff  <blp@gnu.org>
1508
1509         Thanks to Jason Stover for pointing out this problem.
1510         
1511         * data-out.c (output_number): Use gsl_finite from GSL, which is
1512         portable, instead of isfinite, which is not.
1513         (power256) Ditto.
1514
1515 Thu Dec  7 15:22:38 WST 2006 John Darrington <john@darrington.wattle.id.au>
1516
1517         * variable.c variable.h (value_dup): New function.
1518
1519 Mon Dec  4 22:20:17 2006  Ben Pfaff  <blp@gnu.org>
1520
1521         Start converting struct variable to an opaque type.  In this
1522         phase, we add a bunch of setter and getter functions and convert
1523         most of the PSPP code to use them.  The resulting changes are
1524         pervasive but mostly trivial, and only the notable changes are
1525         logged.
1526         
1527         * format.c (fmt_equal): New function.
1528         
1529         * variable.c (var_type_is_valid): New function.
1530         (measure_is_valid) Moved here, from format.c.
1531         (alignment_is_valid) Moved here, from format.c.
1532         (var_get_name) New function.
1533         (var_set_name) New function.
1534         (width_to_type) New function.
1535         (var_get_type) New function.
1536         (var_get_width) New function.
1537         (var_set_width) New function.
1538         (var_is_numeric) New function.
1539         (var_is_alpha) New function.
1540         (var_is_short_string) New function.
1541         (var_is_long_string) New function.
1542         (var_is_very_long_string) New function.
1543         (var_get_missing_values) New function.
1544         (var_set_missing_values) New function.
1545         (var_clear_missing_values) New function.
1546         (var_has_missing_values) New function.
1547         (var_is_value_missing) New function.
1548         (var_is_num_missing) New function.
1549         (var_is_str_missing) New function.
1550         (var_is_value_user_missing) New function.
1551         (var_is_num_user_missing) New function.
1552         (var_is_str_user_missing) New function.
1553         (var_is_value_system_missing) New function.
1554         (var_get_print_format) New function.
1555         (var_set_print_format) New function.
1556         (var_get_write_format) New function.
1557         (var_set_write_format) New function.
1558         (var_set_both_formats) New function.
1559         (var_get_label) New function.
1560         (var_set_label) New function.
1561         (var_clear_label) New function.
1562         (var_has_label) New function.
1563         (var_get_measure) New function.
1564         (var_set_measure) New function.
1565         (var_get_display_width) New function.
1566         (var_set_display_width) New function.
1567         (var_get_alignment) New function.
1568         (var_set_alignment) New function.
1569         (var_get_value_cnt) New function.
1570         (var_get_leave) New function.
1571         (var_get_short_name) New function.
1572
1573         * variable.h: (struct variable) Removed "type" and "nv" members;
1574         they are now computed from "width" where needed.
1575
1576 Mon Dec  4 21:38:40 2006  Ben Pfaff  <blp@gnu.org>
1577
1578         * missing-values.c (mv_resize): Don't write beyond end of the
1579         allocated buffer when resizing a long string.
1580
1581 Sat Dec  2 16:28:32 2006  Ben Pfaff  <blp@gnu.org>
1582
1583         Clean up identifier code: don't require identifier enumerations to
1584         be in a particular order; make better use of string library;
1585         expose less of the internals.
1586                 
1587         * identifier.c: (lex_skip_identifier) Rename lex_id_get_length,
1588         change interface.  Updated all callers.
1589         (lex_id_match) Change interface to use struct substring, update
1590         all callers.
1591         (lex_id_match_len) Removed.  Update callers to use lex_id_match.
1592         (global array keywords[]) Make static, change form.  Update all
1593         users to use lex_id_name instead.
1594         (lex_is_keyword) New function.
1595         (lex_id_to_token) Change interface to use struct substring, update
1596         all callers.
1597         (lex_id_name) New function.
1598
1599         * identifier.h: (T_FIRST_KEYWORD) Removed.  Changed users to call
1600         lex_is_keyword instead.
1601         (T_LAST_KEYWORD) Removed.
1602         (T_N_KEYWORDS) Removed.
1603         
1604 Sat Nov 18 20:46:35 2006  Ben Pfaff  <blp@gnu.org>
1605
1606         * format.c: (fmt_date_template) Distinguish characters for which a
1607         space is output and any date delimiter is allowed on input, from
1608         those for which a space is output and only a space is allowed on
1609         input.  The former is represented by X, the latter by a space.
1610         Also, drop distinction between h and H, changing the former to the
1611         latter.
1612
1613         * data-in.c: Completely rewrite internals to conform to SPSS input
1614         formats as closely as possible.
1615         (data_in) Changed external interface by replacing the structure
1616         that was used as a single argument by a set of arguments.  Updated
1617         all callers.
1618         (data_in_finite_line) Removed.  Converted all callers to use plain
1619         data_in.
1620         (data_in_get_integer_format) New function.
1621         (data_in_set_integer_format) New function.
1622         (data_in_get_float_format) New function.
1623         (data_in_set_float_format) New function.
1624
1625         * data-in.h: (enums DI_IGNORE_ERROR, DI_IMPLIED_DECIMALS) Removed.
1626         (struct data_in) Removed.
1627
1628         * data-out.c: (output_date) Drop each component from the input as
1629         it is output, to allow us to drop the distinction between h (a
1630         count of hours) and H (the hour of day) template characters.
1631         Also, handle new X template character.
1632         (output_scientific) Follow more rational rule on when to drop
1633         fraction introduced between SPSS 13 and 15.  Updated test case to
1634         match new behavior.
1635
1636 Sat Nov 11 11:41:26 2006  Ben Pfaff  <blp@gnu.org>
1637
1638         Fix buffer overflow reported by John Darrington.
1639
1640         * data-out.c (output_bcd_integer): In case of SYSMIS, etc.,
1641         realize that DIGITS is a count of nibbles, not of bytes.
1642
1643 Sat Nov  4 15:59:56 2006  Ben Pfaff  <blp@gnu.org>
1644
1645         * calendar.c (calendar_offset_to_gregorian) Also return the
1646         year-of-day.  Change callers to new interface.
1647
1648         * data-out.c: Completely rewrite internals to conform to SPSS
1649         output formats as completely as possible.
1650         (data_out) Change interface to put input parameters before output
1651         parameters, for consistency with the style I now prefer.  Update
1652         all callers.
1653         (data_out_get_integer_format) New public function.
1654         (data_out_set_integer_format) New public function.
1655         (data_out_get_float_format) New public function.
1656         (data_out_set_float_format) New public function.
1657
1658         * data-out.h: New file.  Move prototype for data_out here, from
1659         format.h.
1660
1661         * format.c: (fmt_step_width) Use equality comparison instead of
1662         bitwise and, for clarity.
1663         (fmt_is_string) Ditto.
1664         (fmt_input_to_output) Fix categories that are translated to F
1665         format.
1666
1667 Sun Nov  5 08:29:34 WST 2006 John Darrington <john@darrington.wattle.id.au>
1668
1669         * casefilter.c casefilter.h (new files), casefile.c casefile.h 
1670         casefile-private.h: Added casefilter to assist commands with missing 
1671         values.
1672
1673 Sat Nov  4 11:47:09 2006  Ben Pfaff  <blp@gnu.org>
1674
1675         Implement SET ERRORS, SHOW ERRORS.  Fixes bug #17609.
1676         
1677         * settings.c: (route_errors_to_terminal) New variable.
1678         (route_errors_to_listing) New variable. 
1679         (get_error_routing_to_terminal) New function.
1680         (set_error_routing_to_terminal) New function.
1681         (get_error_routing_to_listing) New function.
1682         (set_error_routing_to_listing) New function.
1683
1684         * settings.h: (SET_ROUTE_* enums) Removed, because unused.
1685
1686 Tue Oct 31 19:58:27 2006  Ben Pfaff  <blp@gnu.org>
1687
1688         * format.c: Completely rewrite, to achieve better abstraction.
1689         Rewrite all references to formats in other files.
1690         
1691         * format.def: Rewrite and reorganize.
1692
1693         * settings.c: Move everything related to custom currency formats
1694         into format.[ch], changing them in form, so as to group related
1695         code and definitions better.  Changed all references to use the
1696         new functions.
1697         (static var decimal) Removed.
1698         (static var grouping) Removed.
1699         (static var cc) Removed.
1700         (get_decimal) Removed.
1701         (set_decimal) Removed.
1702         (get_grouping) Removed.
1703         (set_grouping) Removed.
1704         (get_cc) Removed.
1705         (set_cc) Removed.
1706
1707         * settings.h: (macro CC_CNT) Removed.
1708         (macro CC_WIDTH) Removed.
1709         (struct custom_currency) Removed.
1710
1711 Tue Oct 31 19:56:19 2006  Ben Pfaff  <blp@gnu.org>
1712
1713         * data-in.c (data_in): Use switch statement instead of table, to
1714         avoid dependence on the order of the FMT_* enums.
1715
1716 Tue Oct 31 19:35:36 2006  Ben Pfaff  <blp@gnu.org>
1717
1718         * data-out.c: (num_to_string) Removed, because it was dead code.
1719
1720 Tue Oct 31 18:09:24 2006  Ben Pfaff  <blp@gnu.org>
1721
1722         * data-in.c (parse_trailer): Fix error message.
1723
1724 Sat Oct 28 11:56:50 2006  Ben Pfaff  <blp@gnu.org>
1725
1726         * format.c (fmt_is_binary): New function.
1727
1728 Thu Oct 19 22:59:56 WST 2006 John Darrington <john@darrington.wattle.id.au>
1729
1730         * procedure.c procedure.h: Encapsulated the static data into a single
1731         struct.  
1732
1733 Sat Oct 14 16:56:44 2006  Ben Pfaff  <blp@gnu.org>
1734
1735         * casefile.c (casereader_read_xfer): Always initialize the case,
1736         even on an error condition.
1737
1738 Wed Sep 27 09:37:49 WST 2006 John Darrington <john@darrington.wattle.id.au>
1739
1740         * procedure.c (case_limit_trns_proc): Fixed buglet which rendered the 
1741         entire function useless.
1742
1743 Mon Sep 25 17:11:46 WST 2006 John Darrington <john@darrington.wattle.id.au>
1744
1745         * casefile-private.h casefile.c casefile.h fastfile.c: Created new
1746         casereader method casereader_clone.   
1747         
1748         * procedure.c pransformations.h: Introduced new type casenum_t
1749
1750 Thu Sep 21 07:00:30 2006  Ben Pfaff  <blp@gnu.org>
1751
1752         * variable.c: (width_to_bytes) Rephrase code for clarify.
1753
1754 Sun Jul 16 19:52:03 2006  Ben Pfaff  <blp@gnu.org>
1755
1756         * format.c: (fmt_type_from_string) New function.
1757         (fmt_to_string) Include decimals in output if the format has
1758         decimals, even if the format type does not.  This way, we can
1759         accurately reproduce incorrect formats in user output.
1760         (check_common_specifier) Make the check for a bad format type an
1761         assertion, so we get bug reports if they show up.  Fix message.
1762         Check for decimal places with a format type that doesn't allow
1763         them.
1764         (check_input_specifier) Remove check for FMT_X, which has been
1765         deleted.
1766         (check_output_specifier) Ditto. 
1767
1768         * format.def: Remove FMT_T, FMT_X, FMT_DESCEND, FMT_NEWREC.
1769
1770         * format.h: (macro FMT_TYPE_LEN_MAX) New macro.
1771         (struct fmt_desc) Use FMT_TYPE_LEN_MAX in definition.
1772         (enum fmt_parse_flags) Removed.
1773
1774 Mon Jul 17 18:26:21 WST 2006 John Darrington <john@darrington.wattle.id.au>
1775
1776         * casefile.c casefile.h: Converted to  an abstract base class.
1777         * casefile-private.h fastfile.c fastfile.h: New files.
1778         * automake.mk procedure.c scratch-writer.c storage-stream.c
1779
1780 Wed Jul 12 21:02:26 2006  Ben Pfaff  <blp@gnu.org>
1781
1782         * procedure.c (internal_procedure): Create sink_case with only as
1783         many values as the compacted dictionary.
1784
1785 Wed Jul 12 21:01:00 2006  Ben Pfaff  <blp@gnu.org>
1786
1787         Remove "debugging" code that caused plenty of false positives and
1788         no true positives.
1789         
1790         * case.h (struct ccase): [DEBUGGING] Remove `this' member.
1791
1792         * case.c: Remove all references to `this' member.
1793
1794 Thu Jul  6 19:09:53 2006  Ben Pfaff  <blp@gnu.org>
1795
1796         Fix link error noted by Jason Stover.
1797         
1798         * storage-stream.c: Include <assert.h>.
1799
1800 Tue Jul  4 08:47:35 2006  Ben Pfaff  <blp@gnu.org>
1801
1802         Fix bug #15766 (/KEEP subcommand on SAVE doesn't fully support
1803         ALL) and additional underlying system file issues.
1804
1805         Thanks to John Darrington for review.
1806
1807         First problem: var_hash points to variables not owned by the
1808         sys-file-reader, which the caller may free or modify.  Use an
1809         array of sfm_vars instead, as done earlier (e.g. CVS version
1810         1.12).
1811         
1812         * sys-file-reader.c (struct sfm_reader): Remove var_hash, svars
1813         members and remove all code that references it.  Add vars, var_cnt
1814         members.  Remove fix_specials member, which was unused.
1815         (struct sfm_var) Remove name member, which was unused.
1816         (sfm_close_reader) Free vars member instead of var_hash.
1817         (compare_var_shortnames) Removed.
1818         (hash_var_shortname) Removed.
1819         (sfm_open_reader) Fill out vars array.
1820         (compare_var_index) Removed.
1821         (sfm_read_case) Use vars instead of var_hash.
1822         
1823         Second problem: we're confused about when we actually have very
1824         long strings, causing us to choose incorrectly between slow path
1825         and fast path in sfm_read_case.
1826
1827         * sys-file-reader.c: (sfm_open_reader) Only mark has_vls if we
1828         have very long strings, not when we have long variable names,
1829         which is an unrelated feature.
1830
1831 Tue Jun 27 12:06:49 2006  Ben Pfaff  <blp@gnu.org>
1832
1833         * variable.h: Move var_set and variable parsing declarations to
1834         new header, src/language/lexer/variable-parser.h.  Modified lots
1835         of files to include the new header.
1836
1837 Sun Jun 25 22:39:32 2006  Ben Pfaff  <blp@gnu.org>
1838
1839         * value-labels.c (value_to_string): When there's no value label,
1840         format the variable according to its print format, instead of
1841         always effectively using A or F format.
1842
1843 Mon Jun 19 18:05:42 WST 2006 John Darrington <john@darrington.wattle.id.au>
1844
1845         * casefile.c (casefile_get_random_reader): Nasty hack to get around 
1846         the mode assertion.
1847
1848         * format.c: Removed tortological assertion.
1849
1850 Fri Jun  9 12:20:09 2006  Ben Pfaff  <blp@gnu.org>
1851
1852         Reform string library.
1853         
1854         * file-name.c (fn_interp_vars): Change interface to take a
1855         substring as input.  Updated all users.
1856         
1857 Fri Jun  9 12:11:24 2006  Ben Pfaff  <blp@gnu.org>
1858
1859         * format.c (measure_is_valid): Really return false when m >=
1860         n_MEASURES.
1861
1862 Tue Jun  6 18:46:26 2006  Ben Pfaff  <blp@gnu.org>
1863
1864         Implement random access to casefiles, for use in GUI.
1865         
1866         * casefile.c: (struct casereader) Add `random', `file_ofs',
1867         `buffer_ofs' members.
1868         (casefile_get_random_reader) New function.
1869         (read_open_file) Break part into new function
1870         seek_and_fill_buffer().
1871         (fill_buffer) Update buffer_ofs, file_ofs.
1872         (casereader_seek) New function.
1873
1874 Tue May 30 19:52:33 WST 2006 John Darrington <john@darrington.wattle.id.au>
1875
1876         * settings.c: Added call to i18n{done, init}.
1877
1878 Tue May  9 21:09:17 2006  Ben Pfaff  <blp@gnu.org>
1879
1880         * procedure.h: Add WARN_UNUSED_RESULT to procedure function
1881         prototypes.
1882
1883 Tue May  9 21:08:05 2006  Ben Pfaff  <blp@gnu.org>
1884
1885         * casefile.c: Convert many uses of `int' to `bool'.
1886
1887 Sat May  6 22:49:43 2006  Ben Pfaff  <blp@gnu.org>
1888
1889         * transformations.c (trns_chain_destroy): Destroy chain's trns
1890         member, to fix memory leak.
1891
1892 Sat May  6 22:48:30 2006  Ben Pfaff  <blp@gnu.org>
1893
1894         * storage-stream.c (storage_source_decapsulate): Destroy case
1895         source to fix memory leak.
1896
1897 Sat May  6 22:46:47 2006  Ben Pfaff  <blp@gnu.org>
1898
1899         * scratch-reader.c (scratch_reader_read_case): Copy into existing
1900         case passed as argument instead of initializing the argument as a
1901         case.  Fixes memory leak that showed up in
1902         tests/command/aggregate.sh with scratch files.
1903
1904 Sat May  6 22:45:55 2006  Ben Pfaff  <blp@gnu.org>
1905
1906         * procedure.c (proc_done): Destroy default_dict, to fix memory
1907         leak.
1908
1909 Sat May  6 22:44:44 2006  Ben Pfaff  <blp@gnu.org>
1910
1911         Simplify procedure_with_splits().
1912         
1913         * procedure.c (struct split_aux_data): Removed case_count member.
1914         (procedure_with_splits) Don't initialize case_count.
1915         (split_procedure_case_func) Check whether prev_case is null
1916         instead of case_count.
1917         (split_procedure_end_func) Ditto.
1918
1919 Sat May  6 22:42:23 2006  Ben Pfaff  <blp@gnu.org>
1920
1921         * case.c (case_move): Do nothing if dst and src are the same
1922         object.
1923         (case_try_create) Merge two similar cases.
1924         (case_copy) Unshare only if data must be actually copied.
1925
1926 Sun May  7 10:04:06 WST 2006 John Darrington <john@darrington.wattle.id.au>
1927
1928         * data-in.c data-out.c dictionary.c sys-file-reader.c
1929         sys-file-writer.c variable.c variable.h:  Reworked very long string
1930         support for better encapsulation.
1931
1932 Sat May  6 19:02:00 2006  Ben Pfaff  <blp@gnu.org>
1933
1934         * value-labels.c (val_labs_can_set_width): New function.
1935         (val_labs_set_width) Clear labels if increasing width to long
1936         string.
1937         (val_labs_destroy) Remove unneeded test for null.
1938         
1939 Sat May  6 16:14:08 2006  Ben Pfaff  <blp@gnu.org>
1940
1941         * value-labels.h: Remove unneeded dependency on variable.h.
1942
1943 Sat May  6 15:58:36 2006  Ben Pfaff  <blp@gnu.org>
1944
1945         Get rid of `char *c' member in union value, for cleanliness.
1946         
1947         * value.h: (union value) Remove `c' member.
1948
1949 Sat May  6 15:36:59 2006  Ben Pfaff  <blp@gnu.org>
1950
1951         Make dictionary compacting functions a little more general.
1952         
1953         * sys-file-writer.c (sfm_open_writer): Use
1954         dict_compacting_would_change().
1955         (does_dict_need_translation) Removed.
1956
1957 Sat May  6 15:35:42 2006  Ben Pfaff  <blp@gnu.org>
1958
1959         Make dictionary compacting functions a little more general.
1960         
1961         * dictionary.c (dict_needs_compaction): Rename
1962         dict_compacting_would_shrink().  Update all callers.
1963         (dict_compacting_would_change) New function.
1964         
1965 Sat May  6 14:25:49 2006  Ben Pfaff  <blp@gnu.org>
1966
1967         * sys-file-writer.c: (does_dict_need_translation) Fix bug:
1968         inverted return value (!).
1969
1970 Sat May  6 13:37:52 2006  Ben Pfaff  <blp@gnu.org>
1971
1972         Continue reforming procedure execution.  
1973
1974         * procedure.c: Search and replace "vfm" by "proc".  Notably:
1975         (static var vfm_source) Rename proc_source.  Update all
1976         references.
1977         (static var vfm_sink) Rename proc_sink.  Update all references.
1978         
1979 Sat May  6 12:38:55 2006  Ben Pfaff  <blp@gnu.org>
1980
1981         Continue reforming procedure execution.  In this phase, remove
1982         PROCESS IF, which was deprecated anyway and can be easily
1983         simulated with TEMPORARY followed by SELECT IF.
1984
1985         * procedure.c: (open_active_file) Don't call
1986         add_process_if_trns().
1987         (discard_variables) Get rid of redundant call to
1988         proc_cancel_all_transformations().
1989         (add_process_if_trns) Removed.
1990         (process_if_trns_proc) Removed.
1991         (process_if_trns_free) Removed.
1992
1993 Sat May  6 10:58:05 2006  Ben Pfaff  <blp@gnu.org>
1994
1995         Continue reforming procedure execution.  In this phase, add
1996         `const' to the case passed to procedure()'s callback.
1997
1998         Updated all users of procedure() as well.
1999         
2000         * procedure.c: (struct write_case_data) Add "const" to ccase
2001         parameter for case_func member.
2002         (procedure) Add "const" to ccase parameter for proc_func
2003         parameter.
2004         (multipass_case_func) Make ccase parameter const.
2005         (internal_procedure) Add "const" to ccase parameter for case_func
2006         parameter.
2007         (split_procedure_case_func) Make ccase parameter const.
2008         (multipass_split_case_func) Make ccase parameter const.
2009         
2010 Sat May  6 10:30:33 2006  Ben Pfaff  <blp@gnu.org>
2011
2012         Continue reforming procedure execution.  In this phase, get rid of
2013         the output code for SPLIT FILE groups in procedure.c, which really
2014         shouldn't be doing any output.  Move it into the individual
2015         procedures instead.  This also adds some flexibility.
2016
2017         Updated many users of procedure_with_splits() and
2018         multipass_procedure_with_splits() to call
2019         output_split_file_values() and to deal with increased use of
2020         const.
2021
2022         * procedure.c: (struct split_aux_data) Add "const struct ccase *"
2023         parameter to begin_func member.
2024         (procedure_with_splits) Add "const struct ccase *" parameter to
2025         begin_func parameter.  Make ccase parameter const in proc_func
2026         parameter.
2027         (split_procedure_case_func) Don't dump split file group.  Pass
2028         case to begin_func.
2029         (dump_splits) Moved to language/dictionary/split-file.c as
2030         output_split_file_values().
2031         (struct multipass_split_aux_data) Add "const struct ccase *"
2032         parameter to split_func member.
2033         (multipass_procedure_with_splits) Add "const struct ccase *"
2034         parameter to split_func parameter.
2035         (multipass_split_case_func) Save new SPLIT FILE case before
2036         outputting case.
2037         (multipass_split_output) Pass saved SPLIT FILE case to split_func.
2038         
2039 Fri May  5 22:48:50 2006  Ben Pfaff  <blp@gnu.org>
2040
2041         Continue reforming procedure execution.  Change
2042         internal_procedure() so that it calls open_active_file() and
2043         close_active_file(), which isolates most of the actual procedure
2044         functionality.
2045
2046         * procedure.c: (struct write_case_data) Rename `proc_func' member
2047         to `case_func' and update all references.
2048         (procedure) Rewrite as one-line wrapper around
2049         internal_procedure().
2050         (struct multipass_aux_data) New.
2051         (multipass_callback) Renamed multipass_case_func().  Use struct
2052         multipass_aux_data as auxiliary data.
2053         (multipass_end_func) New function.
2054         (multipass_procedure) Rewrite as wrapper for internal_procedure()
2055         that uses multipass_case_func, multipass_end_func.
2056         (internal_procedure) Add `end_func' argument.  Move optimization
2057         of trivial case in here.  Move call to open_active_file() and
2058         close_active_file() in here.  Now assert that vfm_source is
2059         non-null.
2060         (procedure_with_splits_callback) Rename
2061         split_procedure_case_func().
2062         (split_procedure_end_func) New function.
2063         (multipass_split_callback) Rename multipass_split_case_func.
2064         (multipass_split_end_func) New function.
2065         (discard_variables) No need to test for nonnull vfm_source.
2066
2067 Fri May  5 21:34:02 2006  Ben Pfaff  <blp@gnu.org>
2068
2069         Continue reforming procedure execution.  Get rid of unused member.
2070
2071         * procedure.c: (struct write_case_data) Remove `cases_analyzed'
2072         member.
2073         (write_case) Don't increment cases_analyzed.
2074
2075 Thu May  4 21:50:11 2006  Ben Pfaff  <blp@gnu.org>
2076
2077         Continue reforming procedure execution.  In this phase, move
2078         procedure.c and procedure.h from src to src/data.  Update
2079         makefiles and #includes accordingly.
2080
2081         * procedure.c: Moved here from src/.
2082
2083         * procedure.h: Moved here from src/.
2084
2085 Wed May  3 22:42:12 2006  Ben Pfaff  <blp@gnu.org>
2086
2087         Continue reforming procedure execution.  In this phase, get rid of
2088         many global variables, consolidating procedure execution in
2089         procedure.c.  Encapsulate transformations in new "struct
2090         trns_chain".  Also, change implementation of N OF CASES, FILTER,
2091         and PROCESS IF from special cases to transformations.
2092          
2093         * automake.mk: (src_data_libdata_a_SOURCES) Add transformations.c,
2094         transformations.h.
2095
2096         * dictionary.c: (global variable default_dict) Move to
2097         src/procedure.c.
2098
2099         * variable.h: (TRNS_*) Move to transformations.h.
2100         (struct transformation) Move to transformations.c.
2101
2102 Thu May  4 13:47:06 WST 2006 John Darrington <john@darrington.wattle.id.au>
2103
2104         * sys-file-reader.c: Fixed invalid read problems.
2105
2106 Tue May  2 15:57:10 2006  Ben Pfaff  <blp@gnu.org>
2107
2108         * storage-stream.c: Add missing function comments.
2109
2110 Tue May  2 15:50:21 2006  Ben Pfaff  <blp@gnu.org>
2111
2112         Continue reforming procedure execution.  In this phase, add some
2113         new, needed functionality to storage-stream.
2114
2115         * storage-stream.c: (storage_source_decapsulate) New function.
2116
2117 Tue May  2 15:43:36 2006  Ben Pfaff  <blp@gnu.org>
2118
2119         * variable.c (width_to_bytes): Declarations must precede
2120         statements for C90 compliance.
2121
2122 Tue May  2 10:42:05 WST 2006 John Darrington <john@darrington.wattle.id.au>
2123
2124         * data-out.c, data-in.c, variable.c, variable.h: New functions 
2125         copy_mangle and copy_demangle for reading/writing cases; emulates the 
2126         way SPSS deals with strings > 255 bytes.
2127
2128         * sys-file-reader.c sys-file-writer.c: Added support for Record 7, 
2129         subtype 14 needed for strings longer than 255 bytes.
2130
2131         * dictionary.c, format.def, value.c : Updated to use MAX_STRING 
2132         instead of literal values. Also fixed some constness issues.
2133
2134         * format.h: Constness
2135
2136         * sfm-private.h: Renamed the case_size identifier, since I discovered 
2137         that SPSS's respect for this variable is very nominal.
2138
2139 Mon May  1 15:45:42 2006  Ben Pfaff  <blp@gnu.org>
2140
2141         Change case limit type from int to size_t.
2142
2143         * dictionary.c: (struct dictionary) Change type of case_limit
2144         member.
2145         (dict_get_case_limit) Change return type.
2146         (dict_set_case_limit) Change parameter type.
2147
2148 Wed Apr 26 20:01:19 2006  Ben Pfaff  <blp@gnu.org>
2149
2150         * variable.h: (struct variable) Rename `reinit' member as `leave'
2151         and invert sense.  Fix up all references.
2152
2153 Wed Apr 26 19:39:28 2006  Ben Pfaff  <blp@gnu.org>
2154
2155         Continue reforming procedure execution.  In this phase, break
2156         procedure.c into multiple files.
2157         
2158         * automake.mk: (src_data_libdata_a_SOURCES) Add all the new files.
2159
2160         * case-sink.c: New file.
2161
2162         * case-sink.h: New file.
2163         
2164         * case-source.c: New file.
2165
2166         * case-source.h: New file.
2167         
2168         * storage-stream.c: New file.
2169
2170         * storage-stream.h: New file.
2171
2172 Wed Apr 26 14:55:19 2006  Ben Pfaff  <blp@gnu.org>
2173
2174         * variable.h: (struct variable) Remove `init' member and all
2175         references to it from other files.  It was initialized in several
2176         places, but nothing really ever used it for anything worthwhile.
2177         Thanks to Jason Stover for pointing out how confusing this
2178         member is.
2179
2180 Sun Apr 23 22:04:45 2006  Ben Pfaff  <blp@gnu.org>
2181
2182         Continue reforming error message support.  In this phase, get rid
2183         of message "titles" and put the message text in `struct error'.
2184         Now `struct error' encapsulates a message more properly.
2185         
2186         * casefile.c: (io_error) Use err_msg() instead of err_vmsg().
2187         Format message ourselves.
2188
2189         * data-in.c: (vdls_error) Ditto.
2190
2191         * por-file-reader.c: (error) Ditto.
2192
2193         * sys-file-reader.c: (corrupt_msg) Ditto.
2194
2195 Sun Apr 16 18:49:51 2006  Ben Pfaff  <blp@gnu.org>
2196
2197         GNU standards require "file name" instead of "filename" in
2198         documentation.  It's nice for our code to follow the convention
2199         too.
2200         
2201         * casefile.c: (struct casefile) Rename `filename' member to
2202         `file_name'.  Updated all references.
2203
2204         * file-name.c: [!unix] (struct file_identity) Rename
2205         normalized_filename member to normalized_file_name.  Updated all
2206         references.
2207
2208 Sun Apr 16 18:35:33 2006  Ben Pfaff  <blp@gnu.org>
2209
2210         We don't really support anything but Unix-like environments well,
2211         so we might as well de-obfuscate by writing directory and path
2212         separators explicitly.
2213
2214         * file-name.h: (macro DIR_SEPARATOR) Removed.  Changed all usages
2215         to just '/'.
2216         (macro PATH_SEPARATOR) Removed.  Changed all usages to just ':'.
2217         (macro DIR_SEPARATOR_STRING) Removed.  Changed all usages to just
2218         "/".
2219         (macro PATH_SEPARATOR_STRING) Removed.  Changed all usages to just
2220         ":"
2221
2222 Sun Apr 16 18:28:35 2006  Ben Pfaff  <blp@gnu.org>
2223
2224         GNU standards require "file name" instead of "filename" in
2225         documentation.  It's nice for our code to follow the convention
2226         too.
2227         
2228         * filename.c: Rename to file-name.c.
2229
2230         * filename.h: Rename to file-name.h.  Update all inclusions.
2231         Update header guards.
2232
2233         * automake.mk: Update file names.
2234
2235 Sun Apr 16 16:42:47 2006  Ben Pfaff  <blp@gnu.org>
2236
2237         * filename.c: (fn_dirname) Renamed fn_dir_name(), all references
2238         updated.
2239         (fn_basename) Removed (dead code).
2240         (fn_absolute_p) Renamed fn_is_absolute(), all references updated.
2241         (fn_special_p) Renamed fn_is_special(), all references updated.
2242         (fn_exists_p) Renamed fn_exists(), all references updated.
2243
2244 Sun Apr 16 16:33:58 2006  Ben Pfaff  <blp@gnu.org>
2245
2246         * filename.c: (fn_tilde_expand) Rewrite for cleaner code.  
2247         Also, now it only tilde-expands file names, not paths.
2248         (fn_search_path) Tilde-expand one directory at a time.
2249
2250 Sun Apr 16 16:28:06 2006  Ben Pfaff  <blp@gnu.org>
2251
2252         * filename.c: (fn_search_path) rewrite for cleaner code.  Also,
2253         get rid of non-Unixlike version of the code, which has probably
2254         never been tested.
2255         (fn_prepend_dir) Removed (dead code).
2256
2257         * filename.h: (macro DIR_SEPARATOR_STRING) New.
2258         (macro PATH_SEPARATOR_STRING) New.
2259 Sun Apr 16 16:05:28 2006  Ben Pfaff  <blp@gnu.org>
2260
2261         Continue reforming error message support.  In this phase, we get
2262         rid of VM() and the other msg() support for "verbosity", replacing
2263         it by a new function verbose_msg().
2264
2265         * filename.c: (fn_search_path) Use verbose_msg() instead of
2266         msg(VM(), ...).  
2267
2268 Sat Apr 15 19:53:19 2006  Ben Pfaff  <blp@gnu.org>
2269
2270         * sfm-private.h: Get rid of #defines after #error, which makes no
2271         sense.
2272
2273 Sat Apr 15 19:48:57 2006  Ben Pfaff  <blp@gnu.org>
2274
2275         Get rid of our own int32 type in favor of the standard int32_t
2276         type.
2277         
2278         * sfm-private.h: (int32 macro) Don't define this anymore.  Do
2279         include <stdint.h>.
2280
2281         * sys-file-reader.c: Use int32_t instead of int32 throughout.
2282         
2283         * sys-file-writer.c: Use int32_t instead of int32 throughout.
2284
2285 Sat Apr 15 19:36:47 2006  Ben Pfaff  <blp@gnu.org>
2286
2287         Remove ill-considered file routines that are no longer used.
2288         
2289         * filename.c: (fn_open_ext) Removed.
2290         (fn_close_ext) Removed.
2291
2292         * filename.h: (struct file_ext) Removed.
2293
2294 Mon Apr  3 13:22:39 2006  Ben Pfaff  <blp@gnu.org>
2295
2296         * variable.c (var_is_valid_name): Move declarations before code
2297         for C90 compliance.
2298
2299 Tue Apr  4 15:28:40 WST 2006 John Darrington <john@darrington.wattle.id.au>
2300
2301         * filename.ch (fn_interp_vars): Fixed small buglet.
2302
2303 Tue Mar 28 13:47:16 WST 2006 John Darrington <john@darrington.wattle.id.au>
2304         
2305         * filename.[ch] (fn_interp_vars): Changed the signature and semantics
2306         so as to modify the string inline.   Thus makeing it easier to
2307         destroy the results when no longer needed.
2308         
2309 2006-03-25  Jason Stover  <jhs@math.gcsu.edu>
2310
2311         * category.c (cat_stored_values_destroy): Fixed memory leak.
2312
2313 Fri Mar 24 18:15:41 2006  Ben Pfaff  <blp@gnu.org>
2314
2315         Add some missing frees.  Thanks to John Darrington for reporting
2316         these.
2317
2318         * any-writer.c (any_writer_close): Free writer.
2319
2320         * any-reader.c (any_reader_close): Free reader.
2321
2322 Mon Mar 20 16:33:53 2006  Ben Pfaff  <blp@gnu.org>
2323
2324         * por-file-reader.c: (error) Mark as NO_RETURN.
2325
2326 Sat Mar 11 15:06:07 WST 2006 John Darrington <john@darrington.wattle.id.au>
2327
2328         * settings.c: Changed default value of scompress to true.
2329
2330 Sat Mar  4 13:22:51 2006  Ben Pfaff  <blp@gnu.org>
2331
2332         * sfm-private.h: Include variable.h, to get SHORT_NAME_LEN.
2333
2334         * value.h: Remove check on MAX_SHORT_STRING, which I don't think
2335         really applies.
2336
2337         * variable.h: Move definition of SHORT_NAME_LEN, LONG_NAME_LEN
2338         here from pref.h.orig.
2339
2340 Sat Mar  4 12:50:48 WST 2006 John Darrington <john@darrington.wattle.id.au>
2341
2342         * sys-file-reader.c: Fixed bug reading compressed files.
2343
2344 Thu Mar  2 08:40:33 WST 2006 John Darrington <john@darrington.wattle.id.au>
2345
2346         * Numerous renames.  See src/ChangeLog for details.
2347         
2348         * Moved files from src directory