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