1 2007-12-04 Ben Pfaff <blp@gnu.org>
3 Move DATA LIST parsing into generic infrastructure, and generalize
4 it slightly. Then, use the same infrastructure to implement GET
7 * data-parser.c: New file.
9 * data-parser.h: New file.
11 * data-list.c (struct dls_var_spec): Removed.
12 (ll_to_dls_var_spec): Removed.
13 (enum dls_type): Removed.
14 (struct data_list_pgm): Rename struct data_list_trns. Remove
15 pool, specs, type, record_cnt, delims, skip_records, value_cnt
16 members. Add new `parser' member.
17 (cmd_data_list): Use data-parser infrastructure.
20 (dump_fixed_table): Removed.
21 (dump_free_table): Removed.
23 (read_from_data_list): Removed.
24 (read_from_data_list_fixed): Removed.
25 (read_from_data_list_free): Removed.
26 (read_from_data_list_list): Removed.
27 (data_list_trns_free): Rename arguments for clarity.
28 (data_list_trns_proc): Ditto.
29 (data_list_casereader_read): Removed.
30 (data_list_casereader_destroy): Removed.
31 (data_list_casereader_class): Removed.
33 * get-data.c (cmd_get_data): Support TXT type.
34 (set_type): New function.
35 (parse_get_txt): New function.
37 2007-12-04 Ben Pfaff <blp@gnu.org>
39 * placement-parser.c (parse_column): New function.
40 (parse_column_range): Add `base' argument. Update all callers.
42 2007-12-04 Ben Pfaff <blp@gnu.org>
44 Make GET DATA a separate command, instead of something invoked
47 * automake.mk: Remove get-data.h from sources.
49 * get-data.h: Removed.
51 * get-data.c (parse_get_data_command): Rename cmd_get_data.
53 * get.c (parse_read_command): No longer any need to check for DATA
56 2007-12-04 Ben Pfaff <blp@gnu.org>
58 * src/language/data-io/data-reader.c (struct dfm_reader): New
59 `file_size' member to support dfm_get_percent_read.
60 (dfm_open_reader): Initialize file_size.
61 (dfm_get_percent_read): New function.
63 2007-11-08 Ben Pfaff <blp@gnu.org>
65 Patch #6256: add support for binary, 360 file formats. Reviewed
68 * data-reader.c (struct dfm_reader): New member `block_left'.
69 (dfm_open_reader): Initialize block_left. For FH_MODE_TEXT, open
70 the file in text mode.
71 (read_error): New function.
72 (partial_record): New function.
73 (try_to_read_fully): New function.
74 (enum descriptor_type): New enum.
75 (read_descriptor_word): New function.
76 (corrupt_size): New function.
77 (read_size): New function.
78 (read_file_record): Implement new modes.
79 (read_record): Now take care of tracking line numbers here.
80 (dfm_reader_get_legacy_encoding): New function.
82 * data-writer.c (dfm_put_record): Implement new modes.
83 (dfm_writer_get_legacy_encoding): New function.
85 * file-handle.q: Parse new formats.
86 (cmd_file_handle): Set up new formats.
88 * print.c (struct print_trns): New member `encoding'.
89 (internal_cmd_print): Set encoding.
90 (print_trns_proc): Recode output data if necessary.
91 (flush_records): Recode leader byte.
93 2007-11-03 Ben Pfaff <blp@gnu.org>
95 Allow output files to overwrite input files (bug #21280).
97 * data-list.c (cmd_data_list): Manage file handle reference
100 * data-reader.c (struct dfm_reader): Add `lock' member.
101 (dfm_close_reader): Simplify, as reference counting is now
102 separate from locking.
103 (dfm_open_reader): Lock file.
105 * data-writer.c (struct dfm_writer): Add fh_lock, replace_file
107 (dfm_open_writer): Lock file and prepare for replacement.
108 (dfm_close_writer): Unlock file and replace it.
110 * file-handle.q (cmd_close_file_handle): Use fh_unname.
111 (fh_parse): Don't distinguish existing handles for a given file
112 name from new ones. Manage file handle reference counts.
114 * get.c (parse_read_command): Manage file handle reference counts.
115 (parse_write_command): Ditto.
116 (mtf_close_all_files): Ditto.
118 * inpt-pgm.c (cmd_reread): Manage file handle reference counts.
120 * print-space.c (cmd_print_space): Manage file handle reference
123 * print.c (internal_cmd_print): Manage file handle reference
126 2007-11-03 John Darrington <john@darrington.wattle.id.au>
128 * get.c: Add GET DATA command variant.
130 * get-data.c get-data.h (new files): Added support for
131 GET DATA /TYPE='gnm' command.
133 2007-09-23 Ben Pfaff <blp@gnu.org>
135 Bug #21111. Reviewed by John Darrington.
137 * data-list.c (data_list_trns_proc): Properly set retval when END
138 subcommand is in use.
139 (cmd_data_list): Don't allow END subcommand to be used with DATA
142 2007-09-12 Ben Pfaff <blp@gnu.org>
144 * get.c (get_translate_case): Change input case parameter from
145 const struct ccase * to struct ccase *, to match change in
146 casereader and casewriter translators. Destroy input case, to fix
149 2007-08-12 Ben Pfaff <blp@gnu.org>
151 * get.c (parse_read_command): Compact the values in the target
152 dictionary, to save space.
154 2007-08-12 Ben Pfaff <blp@gnu.org>
156 * get.c (struct case_map): Move into new file src/data/case-map.c.
157 (start_case_map): Ditto, and rename case_map_prepare_dict.
158 (finish_case_map): Ditto, and rename case_map_from_dict.
159 (map_case): Ditto, and rename case_map_execute.
160 (destroy_case_map): Ditto, and rename case_map_destroy.
161 (case_map_get_value_cnt): Ditto.
163 2007-08-12 Ben Pfaff <blp@gnu.org>
165 * get.c (case_map_get_value_cnt): New function.
167 2007-07-25 Ben Pfaff <blp@gnu.org>
170 * data-list.c (read_from_data_list_fixed): Handle multi-record
173 2007-07-11 Ben Pfaff <blp@gnu.org>
175 * get.c (map_case): Create destination case instead of leaving it
176 undefined. Fixes bug #20285.
177 Reviewed by John Darrington.
179 2007-06-06 Ben Pfaff <blp@gnu.org>
181 * get.c: Essentially rewrite MATCH FILES to support FIRST and
184 2007-06-06 Ben Pfaff <blp@gnu.org>
186 Adapt case sources, sinks, and clients of procedure code to the
189 * data-list.c: Make DATA LIST into a casereader.
191 * get.c: Change GET, IMPORT, SAVE, EXPORT to use casereaders,
194 * inpt-pgm.c: Use caseinit code. Turn INPUT PROGRAM into a
197 * list.q: Adapt to new procedure code.
199 2007-05-06 Ben Pfaff <blp@gnu.org>
201 Abstract the documents within a dictionary a little better.
202 Thanks to John Darrington for suggestion, initial version, and
205 * get.c (mtf_merge_dictionary): Simplify creating merged document.
207 * sys-file-info.c (display_documents): Use new
208 dict_get_document_line_cnt and dict_get_document_line functions.
210 Thu Feb 1 16:56:02 2007 Ben Pfaff <blp@gnu.org>
212 * file-handle.q (fh_parse): Update to new fh_create_file
215 Sat Dec 16 22:16:18 2006 Ben Pfaff <blp@gnu.org>
217 Make it possible to pull cases from the active file with a
218 function call, instead of requiring indirection through a callback
221 * automake.mk: Removed matrix-data.c.
223 * matrix-data.c: Removed.
225 * data-list.c (data_list_source_read): Conform with new
226 case_source_class interface.
227 (data_list_source_destroy): Ditto.
229 * get.c (case_reader_source_class): Ditto.
230 (case_reader_source_destroy): Ditto.
231 (parse_output_proc): Take advantage of new procedure interface.
232 (output_proc): Removed.
233 (struct mtf_file): Add "struct ccase *" member to allow use of new
235 (cmd_match_files): Take advantage of new procedure interface.
236 (mtf_processing_finish): Removed.
237 (mtf_read_nonactive_records): Renamed mtf_read_records. Now reads
238 from every file, without any exception for the active file.
239 (mtf_compare_BY_values): Simplify for new interface.
240 (mtf_processing): Simplify for new interface.
242 * inpt-pgm.c (is_valid_state): New function.
243 (input_program_source_read): Conform with new case_source_class
245 (input_program_source_destroy): Ditto.
246 (end_case_trns_proc): Now just needs to return TRNS_END_CASE.
248 Sat Dec 9 18:43:34 2006 Ben Pfaff <blp@gnu.org>
250 * list.q (cmd_list): Use new var_create, var_destroy functions.
252 Thu Nov 30 21:51:58 2006 Ben Pfaff <blp@gnu.org>
254 * inpt-pgm.c (cmd_reread): Always return error code upon detecting
255 syntax error. Fixes bug #18419. Thanks to John Darrington for
258 Sun Nov 19 09:17:45 2006 Ben Pfaff <blp@gnu.org>
260 * data-list.c (parse_free): Follow documented (but odd) rule that
261 N format is treated as F format for free-field input.
263 * data-reader.c (read_file_record): Drop new-line character from
264 input text lines. This is symmetrical with the recently changed
265 dfm_put_record semantics.
267 Thu Nov 2 20:56:03 2006 Ben Pfaff <blp@gnu.org>
269 Implement SKIP keyword on DATA LIST. Fixes bug #17099.
271 * data-list.c: (struct data_list_pgm) Add `skip_records' members.
272 (cmd_data_list) Set skip_records based on user input.
273 (data_list_source_read) Skip records requested by user.
275 Tue Oct 31 20:04:06 2006 Ben Pfaff <blp@gnu.org>
277 * placement-parser.c: (PRS_TYPE_T) Now that struct fmt_spec uses
278 an enum fmt_type for its type member, we can't depend on the
279 ability to put negative values into that member as out-of-band
280 values, because enum fmt_type might be an unsigned type. So use
281 values around SCHAR_MAX instead, because we know that SCHAR_MAX
282 will fit into any type, signed or unsigned, and there aren't
283 nearly that many format types.
284 (parse_var_placements) Add for_input parameter to specify whether
285 we're parsing input or output formats. Update all callers.
286 (fixed_parse_columns) Ditto.
287 (fixed_parse_fortran) Ditto.
289 Tue Oct 31 18:21:48 2006 Ben Pfaff <blp@gnu.org>
291 * print-space.c (print_space_trns_proc): Let dfm_put_record add
292 the new-line character, to match dfm_put_record change below.
294 Sat Oct 28 11:57:19 2006 Ben Pfaff <blp@gnu.org>
296 * data-writer.c (struct dfm_writer): Removed `bounce' member, and
297 all references to it.
298 (dfm_put_record) Change semantics so that it adds formatting
299 itself, such as new-line characters, instead of putting that
300 responsibility on the caller. Also, pad binary records with
301 spaces instead of zeros, for compatibility.
303 * print.c (struct prt_out_spec) New member `sysmis_as_spaces'.
304 (struct print_trns) Remove `omit_new_lines' and all references,
305 since dfm_put_record() is taking care of that. Add
307 (internal_cmd_print) Allow an empty set of data to print. Set
309 (parse_specs) Allow an empty set of data to print.
310 (parse_variable_argument) Only add space with PRINT command. Set
312 (print_trns_proc) Indent records if include_prefix is set, for
313 compatibility. Output SYSMIS as spaces if sysmis_as_spaces is
314 set. Put "1" in first column if PRINT EJECT is used with an
315 external output file.
316 (flush_records) Ditto.
318 Sat Oct 28 16:19:57 WST 2006 John Darrington <john@darrington.wattle.id.au>
320 * data-reader.c: Eliminated references to extern variable getl_buf
322 Sat Aug 5 08:25:07 2006 Ben Pfaff <blp@gnu.org>
324 Fix bug #17329 in REREAD parsing, reported by John Darrington.
326 * inpt-pgm.c (cmd_reread): Fix file handle parsing.
328 Mon Jul 31 10:32:31 2006 Ben Pfaff <blp@gnu.org>
330 * print.c (parse_specs): Allow a comma between specifications.
332 Sun Jul 16 19:57:10 2006 Ben Pfaff <blp@gnu.org>
334 * automake.mk: (src_language_data_io_libdata_io_a_SOURCE) Add
335 print-space.c, placement-parser.c, placement-parser.h.
337 * data-list.c: Basically rewrote the whole thing. Broke out a lot
338 of code into placement-parser.c. Code is much cleaner now.
340 * placement-parser.c: New file.
342 * placement-parser.h: New file.
344 * print.c: Basically rewrote the whole thing. Broke out PRINT
345 SPACE into print-space.c. Code is much cleaner now.
347 * print-space.c: New file.
349 Sat Jul 1 17:39:40 2006 Ben Pfaff <blp@gnu.org>
351 Fix bug #11612, "q2c documentation does not agree with code".
353 * list.q: Audit use of q2c "+" prefixes that indicate that a
354 command may appear multiple times.
356 Sat Jul 1 20:44:22 2006 Ben Pfaff <blp@gnu.org>
358 Fix bug #15786: System File Creation crashes if directoy is
361 * get.c (parse_write_command): Check that the any_writer open
364 Tue Jun 27 22:44:28 2006 Ben Pfaff <blp@gnu.org>
366 Fix regression in command name completion reported by John
367 Darrington. Now completion is again state-dependent and occurs
368 only on the first line of a command.
370 * inpt-pgm.c: (cmd_input_program) Reading of first token in
371 command moved into cmd_parse.
373 Fri Jun 9 13:56:00 2006 Ben Pfaff <blp@gnu.org>
375 Reform string library.
377 * matrix-data.c (context): Use dynamic string.
378 (another_token) Deal with changed dfm_get_record() interface.
382 * data-list.c (struct data_list_pgm) Delete delims, delim_cnt
383 members, replacing them by struct string delims. Update all
384 references to use struct string functions.
385 (cut_field) Change interface to avoid needing "end_blank", by
386 getting the data-reader to remember that state for us. Change
387 internals to use substring. Update both callers.
389 * data-reader.c (read_file_record): Use ds_read_stream().
390 (dfm_get_record) Change interface to return substring. Updated
392 (dfm_expand_tabs) Use ds_find_char(). Now maintain position
393 relative to end-of-line. Use ds_swap().
394 (dfm_reread_record) Don't limit position by line length.
395 (dfm_column_start) Make parameter const.
396 (dfm_columns_past_end) New function.
397 (dfm_get_column) New function.
399 Thu May 25 18:26:26 WST 2006 John Darrington <john@darrington.wattle.id.au>
401 * print.c (print_trns_free): Made the code agree with the comment, by
402 not freeing PRT. Has the side effect that the command no longer
403 crashes on invalid syntax.
405 Tue May 9 20:55:46 2006 Ben Pfaff <blp@gnu.org>
407 * get.c (cmd_match_files): Fix memory leak replacing default_dict.
409 Sat May 6 22:25:09 2006 Ben Pfaff <blp@gnu.org>
413 * list.q (write_fallback_headers): (write_fallback_headers)
414 Properly record width of leader and pass it to write_varname().
416 Sat May 6 19:03:13 2006 Ben Pfaff <blp@gnu.org>
418 * get.c: (mtf_merge_dictionary) Fix value label memory leak.
420 Sat May 6 13:51:16 2006 Ben Pfaff <blp@gnu.org>
422 Use a casefile, instead of a case sink, for MATCH FILES output.
423 It's more straightforward, although it has the same effect.
425 * get.c: (struct mtf_proc) Replace `sink' case sink member by
426 `output' casefile member.
427 (cmd_match_files) Work with casefile instead of sink.
428 (mtf_processing) Add case to casefile instead of sink.
430 Sat May 6 10:43:07 2006 Ben Pfaff <blp@gnu.org>
432 Continue reforming procedure execution. In this phase, get rid of
433 the output code for SPLIT FILE groups in procedure.c, which really
434 shouldn't be doing any output. Move it into the individual
435 procedures instead. This also adds some flexibility.
437 * list.q (write_all_headers): Call output_split_file_values().
439 Wed May 3 23:00:17 2006 Ben Pfaff <blp@gnu.org>
441 Continue reforming procedure execution. In this phase, get rid of
442 many global variables, consolidating procedure execution in
443 procedure.c. Encapsulate transformations in new "struct
444 trns_chain". Also, change implementation of N OF CASES, FILTER,
445 and PROCESS IF from special cases to transformations.
447 * data-list.c: (data_list_trns_proc) Return TRNS_END_FILE at end
448 of file. (Why didn't we do this before?)
449 (cmd_match_files) Direct procedure output to null sink.
450 Use discard_variables() instead of indirect version.
452 * inpt-pgm.c: Use transformation chain.
453 (struct input_program_pgm) Add trns_chain member.
454 (cmd_input_program) Initialize trns_chain member and capture
455 transformations with proc_capture_transformations().
456 (input_program_source_read) Use trns_chain_execute().
457 (destroy_input_program) Destroy input chain.
459 Tue May 2 10:39:56 WST 2006 John Darrington <john@darrington.wattle.id.au>
461 * list.q Changed from using fixed length char buffers to struct
462 string so that any length variables can be used.
464 Mon May 1 18:21:19 2006 Ben Pfaff <blp@gnu.org>
466 Further clean up the CMD_* command result codes.
468 * (enum cmd_result_extensions) New. Add CMD_END_INPUT_PROGRAM and
469 CMD_END_CASE result codes.
470 (struct input_program_pgm) Added case_nr, write_case, wc_data
471 members for use by END CASE transformation.
472 (emit_END_CASE) New function.
473 (cmd_input_program) Interpret CMD_END_CASE by outputting an END
474 CASE transformation. If none is output by the input program
475 itself, add one automatically at the end. Change lack of
476 variables from warning to error.
477 (cmd_end_input_program) Return CMD_END_INPUT_PROGRAM instead of
479 (input_program_source_read) No longer any need to special-case END
480 CASE. Handle TRNS_DROP_CASE properly. Initialize new members in
481 inp for use by END CASE transformation.
482 (destroy_input_program) New function.
483 (input_program_source_destroy) Just call destroy_input_program().
484 (cmd_end_case) Just return CMD_END_CASE.
485 (end_case_trns_proc) No longer a stub handled by
486 input_program_source_read(). Actually output the case and
487 increment the case number.
489 Mon May 1 16:06:30 2006 Ben Pfaff <blp@gnu.org>
491 Remove vestiges of REPEATING DATA support.
493 * data-list.c: (struct rpd_num_or_var) Removed.
494 (struct repeating_data_trns) Removed.
495 (cmd_repeating_data) Removed.
496 (find_variable_input_spec) Removed.
497 (parse_num_or_var) Removed.
498 (parse_repeating_data) Removed.
499 (realize_value) Removed.
500 (struct rpd_parse_info) Removed.
501 (rpd_parse_record) Removed.
502 (repeating_data_trns_proc) Removed.
503 (repeating_data_trns_free) Removed.
504 (repeating_data_set_write_case) Removed.
507 * inpt-pgm.c: (input_program_source_read) Don't deal with
510 * data-list.h: Removed.
512 * automake.mk (src_language_data_io_libdata_io_a_SOURCES): Removed
515 Mon May 1 15:58:28 2006 Ben Pfaff <blp@gnu.org>
517 Remove vestiges of FILE TYPE support.
519 * data-list.c: (cmd_data_list) Don't check for FILE TYPE.
520 (cmd_repeating_data) Ditto.
522 * automake.mk (src_language_data_io_libdata_io_a_SOURCES): Remove
523 file-type.c, file-type.h.
525 * file-type.c: Removed.
527 * file-type.h: Removed.
529 Wed Apr 26 13:16:28 2006 Ben Pfaff <blp@gnu.org>
531 Improve the way we handle the various parsing "states". Until now
532 we've hard-coded the state transitions in the command definition
533 file, but that's error-prone and, worse, it's redundant--we can
534 figure out what state we're in anyhow. We can cleanly handle
535 INPUT PROGRAM and FILE TYPE with a nested command-processing loop.
537 * data-list.c: (cmd_data_list) Use in_file_type() or
538 in_input_program() in place of case_source_is_class() or
539 case_source_is_complex().
541 * file-type.c: NB: Not really fixed except minimally to compile,
542 because it doesn't work anyway.
543 (in_file_type) New function.
544 (cmd_record_type) No need to check that we're in FILE TYPE.
545 (cmd_end_file_type) Ditto.
546 (var file_type_source_class) Make static.
548 * get.c: (cmd_match_files) Check vfm_source instead of pgm_state.
550 * inpt-pgm.c: (in_input_program) New function.
551 (cmd_input_program) Rewrite to include nested command processing
553 (cmd_end_input_program) Just return CMD_END_SUBLOOP.
554 (var input_program_source_class) Make static.
555 (cmd_end_case) No need to check that we're in INPUT PROGRAM.
556 (cmd_end_file) Ditto.
558 * automake.mk (src_language_data_io_libdata_io_a_SOURCES): Add
559 file-type.h, inpt-pgm.h.
561 * file-type.h: New file.
563 * inpt-pgm.h: New file.
565 Tue Apr 25 13:11:55 2006 Ben Pfaff <blp@gnu.org>
567 * print.c: Don't special-case MS-DOS line terminators.
568 (macro LINE_END_WIDTH) Removed.
569 (alloc_line) Line ends are 1 byte.
570 (print_trns_proc) Just output \n for line end.
572 Sun Apr 23 22:05:58 2006 Ben Pfaff <blp@gnu.org>
574 Continue reforming error message support. In this phase, get rid
575 of message "titles" and put the message text in `struct error'.
576 Now `struct error' encapsulates a message more properly.
578 * data-list.c: (macro RPD_ERR) Removed.
579 (rpd_msg) New function. Updated all references to tmsg() to call
580 this function instead.
582 Sat Apr 15 19:38:13 2006 Ben Pfaff <blp@gnu.org>
584 Remove last users of struct file_ext so we can get rid of it
587 * data-reader.c: (struct dfm_reader) Change file member from
588 struct file_ext to FILE *. Updated all references.
589 (dfm_close_reader) Close file with fn_close() instead of
590 fn_close_ext(). Also, make a copy of the file name from the file
591 handle before closing it, because we can't extract it after we
593 (dfm_open_reader) Open file with fn_open() instead of
596 * data-writer.c: (struct dfm_writer) Change file member
597 struct file_ext to FILE *. Updated all references.
598 (dfm_close_writer) Close file with fn_close() instead of
599 fn_close_ext(). Also, make a copy of the file name from the file
600 handle before closing it, because we can't extract it after we
602 (dfm_open_writer) Open file with fn_open() instead of
605 Sat Apr 15 18:00:32 2006 Ben Pfaff <blp@gnu.org>
607 * data-list.c: Add prototype to suppress warning for
608 cmd_repeating_data().
610 Thu Mar 2 08:40:33 WST 2006 John Darrington <john@darrington.wattle.id.au>
612 * Moved files from src directory