Introduced casenum_t type to enumerate and count cases.
msgstr ""
"Project-Id-Version: PSPP 0.4.2\n"
"Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2006-07-30 14:13+0800\n"
+"POT-Creation-Date: 2006-09-25 16:28+0800\n"
"PO-Revision-Date: 2006-05-26 17:49+0800\n"
"Last-Translator: John Darrington <john@darrington.wattle.id.au>\n"
"Language-Team: German <pspp-dev@gnu.org>\n"
"system-missing, zero, or negative. These case(s) were ignored."
msgstr ""
-#: src/data/fastfile.c:499
+#: src/data/fastfile.c:536
#, c-format
msgid "%s: Removing temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:623
+#: src/data/fastfile.c:660
#, c-format
msgid "Error writing temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:651
+#: src/data/fastfile.c:688
#, c-format
msgid "%s: Opening temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:695
+#: src/data/fastfile.c:732
#, c-format
msgid "%s: Seeking temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:717
+#: src/data/fastfile.c:754
#, c-format
msgid "%s: Reading temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:720
+#: src/data/fastfile.c:757
#, c-format
msgid "%s: Temporary file ended unexpectedly."
msgstr ""
msgstr ""
#: src/language/data-io/data-list.c:403 src/language/data-io/data-list.c:503
-#: src/language/data-io/print.c:368 src/language/dictionary/split-file.c:84
+#: src/language/data-io/print.c:370 src/language/dictionary/split-file.c:84
#: src/language/dictionary/sys-file-info.c:144
#: src/language/dictionary/sys-file-info.c:378
#: src/language/stats/descriptives.c:894
msgid "Variable"
msgstr ""
-#: src/language/data-io/data-list.c:404 src/language/data-io/print.c:369
+#: src/language/data-io/data-list.c:404 src/language/data-io/print.c:371
msgid "Record"
msgstr ""
-#: src/language/data-io/data-list.c:405 src/language/data-io/print.c:370
+#: src/language/data-io/data-list.c:405 src/language/data-io/print.c:372
#: src/ui/gui/var-sheet.c:78
msgid "Columns"
msgstr "Spalten"
#: src/language/data-io/data-list.c:406 src/language/data-io/data-list.c:504
-#: src/language/data-io/print.c:371
+#: src/language/data-io/print.c:373
msgid "Format"
msgstr ""
msgid "COLUMN subcommand multiply specified."
msgstr ""
-#: src/language/data-io/inpt-pgm.c:385
+#: src/language/data-io/inpt-pgm.c:384
msgid ""
"REREAD: Column numbers must be positive finite numbers. Column set to 1."
msgstr ""
"Data fields must be listed in order of increasing record number."
msgstr ""
-#: src/language/data-io/print.c:246
+#: src/language/data-io/print.c:248
#, c-format
msgid "Output calls for %d records but %d specified on RECORDS subcommand."
msgstr ""
-#: src/language/data-io/print.c:400
+#: src/language/data-io/print.c:402
#, c-format
msgid "Writing %d record to %s."
msgid_plural "Writing %d records to %s."
msgstr[0] ""
msgstr[1] ""
-#: src/language/data-io/print.c:404
+#: src/language/data-io/print.c:406
#, c-format
msgid "Writing %d record."
msgid_plural "Writing %d records."
msgstr ""
#: src/language/dictionary/formats.c:92
-msgid "`(' expected after variable list"
+msgid "`(' expected after variable list."
msgstr ""
#: src/language/dictionary/formats.c:102 src/language/dictionary/numeric.c:71
msgid "Save Data As"
msgstr "Speichern unter"
-#: src/ui/gui/menu-actions.c:582
+#: src/ui/gui/menu-actions.c:500
msgid "Font Selection"
msgstr "Schriftwahlung"
msgid "Sorry. The help system hasn't yet been implemented."
msgstr "Es gibt noch nicht kein Helpsysteme. Schade!"
-#: src/ui/gui/psppire-data-store.c:731
+#: src/ui/gui/psppire-data-store.c:733
msgid "var"
msgstr ""
-#: src/ui/gui/psppire-data-store.c:812 src/ui/gui/psppire-var-store.c:518
+#: src/ui/gui/psppire-data-store.c:814 src/ui/gui/psppire-var-store.c:518
#: src/ui/gui/psppire-var-store.c:528 src/ui/gui/psppire-var-store.c:538
#: src/ui/gui/psppire-var-store.c:735
#, c-format
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2006-07-30 14:13+0800\n"
+"POT-Creation-Date: 2006-09-25 16:28+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"system-missing, zero, or negative. These case(s) were ignored."
msgstr ""
-#: src/data/fastfile.c:499
+#: src/data/fastfile.c:536
#, c-format
msgid "%s: Removing temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:623
+#: src/data/fastfile.c:660
#, c-format
msgid "Error writing temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:651
+#: src/data/fastfile.c:688
#, c-format
msgid "%s: Opening temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:695
+#: src/data/fastfile.c:732
#, c-format
msgid "%s: Seeking temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:717
+#: src/data/fastfile.c:754
#, c-format
msgid "%s: Reading temporary file: %s."
msgstr ""
-#: src/data/fastfile.c:720
+#: src/data/fastfile.c:757
#, c-format
msgid "%s: Temporary file ended unexpectedly."
msgstr ""
msgstr ""
#: src/language/data-io/data-list.c:403 src/language/data-io/data-list.c:503
-#: src/language/data-io/print.c:368 src/language/dictionary/split-file.c:84
+#: src/language/data-io/print.c:370 src/language/dictionary/split-file.c:84
#: src/language/dictionary/sys-file-info.c:144
#: src/language/dictionary/sys-file-info.c:378
#: src/language/stats/descriptives.c:894
msgid "Variable"
msgstr ""
-#: src/language/data-io/data-list.c:404 src/language/data-io/print.c:369
+#: src/language/data-io/data-list.c:404 src/language/data-io/print.c:371
msgid "Record"
msgstr ""
-#: src/language/data-io/data-list.c:405 src/language/data-io/print.c:370
+#: src/language/data-io/data-list.c:405 src/language/data-io/print.c:372
#: src/ui/gui/var-sheet.c:78
msgid "Columns"
msgstr ""
#: src/language/data-io/data-list.c:406 src/language/data-io/data-list.c:504
-#: src/language/data-io/print.c:371
+#: src/language/data-io/print.c:373
msgid "Format"
msgstr ""
msgid "COLUMN subcommand multiply specified."
msgstr ""
-#: src/language/data-io/inpt-pgm.c:385
+#: src/language/data-io/inpt-pgm.c:384
msgid ""
"REREAD: Column numbers must be positive finite numbers. Column set to 1."
msgstr ""
"Data fields must be listed in order of increasing record number."
msgstr ""
-#: src/language/data-io/print.c:246
+#: src/language/data-io/print.c:248
#, c-format
msgid "Output calls for %d records but %d specified on RECORDS subcommand."
msgstr ""
-#: src/language/data-io/print.c:400
+#: src/language/data-io/print.c:402
#, c-format
msgid "Writing %d record to %s."
msgid_plural "Writing %d records to %s."
msgstr[0] ""
msgstr[1] ""
-#: src/language/data-io/print.c:404
+#: src/language/data-io/print.c:406
#, c-format
msgid "Writing %d record."
msgid_plural "Writing %d records."
msgstr ""
#: src/language/dictionary/formats.c:92
-msgid "`(' expected after variable list"
+msgid "`(' expected after variable list."
msgstr ""
#: src/language/dictionary/formats.c:102 src/language/dictionary/numeric.c:71
msgid "Save Data As"
msgstr ""
-#: src/ui/gui/menu-actions.c:582
+#: src/ui/gui/menu-actions.c:500
msgid "Font Selection"
msgstr ""
msgid "Sorry. The help system hasn't yet been implemented."
msgstr ""
-#: src/ui/gui/psppire-data-store.c:731
+#: src/ui/gui/psppire-data-store.c:733
msgid "var"
msgstr ""
-#: src/ui/gui/psppire-data-store.c:812 src/ui/gui/psppire-var-store.c:518
+#: src/ui/gui/psppire-data-store.c:814 src/ui/gui/psppire-var-store.c:518
#: src/ui/gui/psppire-var-store.c:528 src/ui/gui/psppire-var-store.c:538
#: src/ui/gui/psppire-var-store.c:735
#, c-format
+Mon Sep 25 17:11:46 WST 2006 John Darrington <john@darrington.wattle.id.au>
+
+ * casefile-private.h casefile.c casefile.h fastfile.c: Created new
+ casereader method casereader_clone.
+
+ * procedure.c pransformations.h: Introduced new type casenum_t
+
Thu Sep 21 07:00:30 2006 Ben Pfaff <blp@gnu.org>
* variable.c: (width_to_bytes) Rephrase code for clarify.
unsigned long (*cnum) (const struct casereader *);
void (*destroy) (struct casereader * r);
+
+ struct casereader * (*clone) (const struct casereader *);
};
if ( ! read_case ) return false;
if ( ffr->destructive && casefile_in_core (cf) )
+ {
+ case_nullify (c);
case_move (c, read_case);
+ }
else
case_clone (c, read_case);
r->class->destroy(r);
}
+/* Creates a copy of R and returns it */
+struct casereader *
+casereader_clone(const struct casereader *r)
+{
+ /* Would we ever want to clone a destructive reader ?? */
+ assert ( ! r->destructive ) ;
+
+ return r->class->clone (r);
+}
+
/* Destroys casefile CF. */
void
casefile_destroy(struct casefile *cf)
struct casefile;
+/* Casereader functions */
struct casefile *casereader_get_casefile (const struct casereader *r);
void casereader_destroy (struct casereader *r);
+struct casereader *casereader_clone(const struct casereader *r);
+
+
+/* Casefile functions */
+
void casefile_destroy (struct casefile *cf);
bool casefile_error (const struct casefile *cf);
size_t casefile_get_value_cnt (const struct casefile *cf);
struct casereader *casefile_get_reader (const struct casefile *cf);
-struct casereader *casefile_get_destructive_reader (struct casefile *cf);
-
+struct casereader *casefile_get_destructive_reader (struct casefile *cf);
bool casefile_append (struct casefile *cf, const struct ccase *c);
also read with casereaders in this phase, but the
ability to create new casereaders is curtailed.
- In this phase, casereaders could still be cloned (once
- we eventually implement cloning).
+ In this phase, casereaders could still be cloned.
To transition from phase 1 or 2 to phase 3 and create a
casereader, call casefile_get_destructive_reader().
return reader;
}
+
+/* Creates a copy of the casereader CR, and returns it */
+static struct casereader *
+fastfilereader_clone (const struct casereader *cr)
+{
+ const struct fastfilereader *ffr = (const struct fastfilereader *) cr ;
+ struct fastfilereader *new_ffr = xzalloc (sizeof *new_ffr);
+
+ struct casereader *new_reader = (struct casereader *) new_ffr;
+
+ struct casefile *cf = casereader_get_casefile (cr);
+ struct fastfile *ff = (struct fastfile *) cf;
+
+ assert (!cf->being_destroyed);
+
+ /* Flush the buffer to disk if it's not empty. */
+ if (ff->mode == WRITE && ff->storage == DISK)
+ flush_buffer (ff);
+
+ ff->mode = READ;
+
+ casereader_register (cf, new_reader, &class_reader);
+
+ new_ffr->case_idx = ffr->case_idx ;
+ new_reader->destructive = cr->destructive;
+ new_ffr->fd = ffr->fd ;
+ new_ffr->buffer = ffr->buffer ;
+ new_ffr->buffer_pos = ffr->buffer_pos;
+
+ if (ff->storage == DISK)
+ reader_open_file (new_ffr);
+
+ return new_reader;
+}
+
+
+
+
/* Returns the number of `union value's in a case for CF. */
static size_t
fastfile_get_value_cnt (const struct casefile *cf)
fastfilereader_get_next_case,
fastfilereader_cnum,
fastfilereader_destroy,
+ fastfilereader_clone,
};
*CASES_REMAINING. */
static int
case_limit_trns_proc (void *cases_remaining_,
- struct ccase *c UNUSED, int case_nr UNUSED)
+ struct ccase *c UNUSED, casenum_t case_nr UNUSED)
{
size_t *cases_remaining = cases_remaining_;
if (*cases_remaining > 0)
/* FILTER transformation. */
static int
filter_trns_proc (void *filter_var_,
- struct ccase *c UNUSED, int case_nr UNUSED)
+ struct ccase *c UNUSED, casenum_t case_nr UNUSED)
{
struct variable *filter_var = filter_var_;
#include <stdbool.h>
#include <stddef.h>
+typedef unsigned long casenum_t ;
+
/* trns_proc_func return values. */
enum trns_result
{
struct ccase;
typedef void trns_finalize_func (void *);
-typedef int trns_proc_func (void *, struct ccase *, int);
+typedef int trns_proc_func (void *, struct ccase *, casenum_t);
typedef bool trns_free_func (void *);
\f
/* Transformation chains. */
Checks each clause and jumps to the appropriate
transformation. */
static int
-do_if_trns_proc (void *do_if_, struct ccase *c, int case_num UNUSED)
+do_if_trns_proc (void *do_if_, struct ccase *c, casenum_t case_num UNUSED)
{
struct do_if_trns *do_if = do_if_;
struct clause *clause;
/* Breaks out of a DO IF construct. */
static int
-break_trns_proc (void *do_if_, struct ccase *c UNUSED, int case_num UNUSED)
+break_trns_proc (void *do_if_, struct ccase *c UNUSED, casenum_t case_num UNUSED)
{
struct do_if_trns *do_if = do_if_;
/* Sets up LOOP for the first pass. */
static int
-loop_trns_proc (void *loop_, struct ccase *c, int case_num)
+loop_trns_proc (void *loop_, struct ccase *c, casenum_t case_num)
{
struct loop_trns *loop = loop_;
/* Finishes a pass through the loop and starts the next. */
static int
-end_loop_trns_proc (void *loop_, struct ccase *c, int case_num UNUSED)
+end_loop_trns_proc (void *loop_, struct ccase *c, casenum_t case_num UNUSED)
{
struct loop_trns *loop = loop_;
/* Executes BREAK. */
static int
-break_trns_proc (void *loop_, struct ccase *c UNUSED, int case_num UNUSED)
+break_trns_proc (void *loop_, struct ccase *c UNUSED, casenum_t case_num UNUSED)
{
struct loop_trns *loop = loop_;
/* Handle DATA LIST transformation DLS, parsing data into C. */
static int
-data_list_trns_proc (void *dls_, struct ccase *c, int case_num UNUSED)
+data_list_trns_proc (void *dls_, struct ccase *c, casenum_t case_num UNUSED)
{
struct data_list_pgm *dls = dls_;
int retval;
/* Writes case C to the system file specified on XSAVE or XEXPORT. */
static int
-output_trns_proc (void *trns_, struct ccase *c, int case_num UNUSED)
+output_trns_proc (void *trns_, struct ccase *c, casenum_t case_num UNUSED)
{
struct output_trns *t = trns_;
case_writer_write_case (t->aw, c);
/* Sends the current case as the source's output. */
int
-end_case_trns_proc (void *inp_, struct ccase *c, int case_nr UNUSED)
+end_case_trns_proc (void *inp_, struct ccase *c, casenum_t case_nr UNUSED)
{
struct input_program_pgm *inp = inp_;
/* Executes a REREAD transformation. */
static int
-reread_trns_proc (void *t_, struct ccase *c, int case_num)
+reread_trns_proc (void *t_, struct ccase *c, casenum_t case_num)
{
struct reread_trns *t = t_;
/* Executes an END FILE transformation. */
static int
end_file_trns_proc (void *trns_ UNUSED, struct ccase *c UNUSED,
- int case_num UNUSED)
+ casenum_t case_num UNUSED)
{
return TRNS_END_FILE;
}
/* Executes a PRINT SPACE transformation. */
static int
print_space_trns_proc (void *t_, struct ccase *c,
- int case_num UNUSED)
+ casenum_t case_num UNUSED)
{
struct print_space_trns *trns = t_;
int n;
/* Performs the transformation inside print_trns T on case C. */
static int
-print_trns_proc (void *trns_, struct ccase *c, int case_num UNUSED)
+print_trns_proc (void *trns_, struct ccase *c, casenum_t case_num UNUSED)
{
struct print_trns *trns = trns_;
struct prt_out_spec *spec;
/* Executes an AUTORECODE transformation. */
static int
-autorecode_trns_proc (void *trns_, struct ccase *c, int case_idx UNUSED)
+autorecode_trns_proc (void *trns_, struct ccase *c, casenum_t case_idx UNUSED)
{
struct autorecode_trns *trns = trns_;
size_t i;
*/
static int
descriptives_trns_proc (void *trns_, struct ccase * c,
- int case_idx UNUSED)
+ casenum_t case_idx UNUSED)
{
struct dsc_trns *t = trns_;
struct dsc_z_score *z;
Gets the predicted values.
*/
static int
-regression_trns_pred_proc (void *t_, struct ccase *c, int case_idx UNUSED)
+regression_trns_pred_proc (void *t_, struct ccase *c,
+ casenum_t case_idx UNUSED)
{
size_t i;
size_t n_vals;
Gets the residuals.
*/
static int
-regression_trns_resid_proc (void *t_, struct ccase *c, int case_idx UNUSED)
+regression_trns_resid_proc (void *t_, struct ccase *c,
+ casenum_t case_idx UNUSED)
{
size_t i;
size_t n_vals;
#include <stdarg.h>
#include <language/command.h>
#include <language/lexer/lexer.h>
+#include <libpspp/assertion.h>
#include "xalloc.h"
static void read_and_verify_random_case (struct casefile *cf,
struct casereader *reader,
size_t case_idx);
+static void test_casereader_clone (struct casereader *reader1, size_t case_cnt);
+
+
static void fail_test (const char *message, ...);
int
if (token != '.')
return lex_end_of_command ();
- for (pattern = 0; pattern < 6; pattern++)
+ for (pattern = 0; pattern < 7; pattern++)
{
const size_t *size;
for (; j < case_cnt; j++)
read_and_verify_random_case (cf, r2, j);
break;
+ case 6:
+ test_casereader_clone (r1, case_cnt);
+ test_casereader_clone (r2, case_cnt);
+ break;
+ default:
+ NOT_REACHED ();
}
if (casereader_read (r1, &c))
fail_test ("Casereader 1 not at end of file.");
case_destroy (&expected_case);
}
+static void
+test_casereader_clone (struct casereader *reader1, size_t case_cnt)
+{
+ size_t i;
+ size_t cases = 0;
+ struct ccase c1;
+ struct ccase c2;
+ struct casefile *src = casereader_get_casefile (reader1);
+ struct casereader *clone = NULL;
+
+ size_t value_cnt = casefile_get_value_cnt (src);
+
+ struct casefile *newfile = fastfile_create (value_cnt);
+ struct casereader *newreader;
+
+
+ /* Read a 3rd of the cases */
+ for ( i = 0 ; i < case_cnt / 3 ; ++i )
+ casereader_read (reader1, &c1);
+
+ clone = casereader_clone (reader1);
+
+ /* Copy all the cases into a new file */
+ while( casereader_read (reader1, &c1))
+ {
+ casefile_append (newfile, &c1);
+ cases ++;
+ }
+
+ newreader = casefile_get_reader (newfile);
+
+ /* Make sure that the new file's are identical to those returned from
+ the cloned reader */
+ while( casereader_read (clone, &c1))
+ {
+ const union value *v1;
+ const union value *v2;
+ cases --;
+
+ if ( ! casereader_read_xfer (newreader, &c2) )
+ break;
+
+ v1 = case_data_all (&c1) ;
+ v2 = case_data_all (&c2) ;
+
+ if ( 0 != memcmp (v1, v2, value_cnt * MAX_SHORT_STRING))
+ fail_test ("Cloned reader read different value at case %ld", cases);
+ }
+
+ if ( cases > 0 )
+ fail_test ("Cloned reader reads different number of cases.");
+
+}
+
static void
fail_test (const char *message, ...)
{
/* Handle COMPUTE or IF with numeric target variable. */
static int
-compute_num (void *compute_, struct ccase *c, int case_num)
+compute_num (void *compute_, struct ccase *c, casenum_t case_num)
{
struct compute_trns *compute = compute_;
/* Handle COMPUTE or IF with numeric vector element target
variable. */
static int
-compute_num_vec (void *compute_, struct ccase *c, int case_num)
+compute_num_vec (void *compute_, struct ccase *c, casenum_t case_num)
{
struct compute_trns *compute = compute_;
/* Handle COMPUTE or IF with string target variable. */
static int
-compute_str (void *compute_, struct ccase *c, int case_num)
+compute_str (void *compute_, struct ccase *c, casenum_t case_num)
{
struct compute_trns *compute = compute_;
/* Handle COMPUTE or IF with string vector element target
variable. */
static int
-compute_str_vec (void *compute_, struct ccase *c, int case_num)
+compute_str_vec (void *compute_, struct ccase *c, casenum_t case_num)
{
struct compute_trns *compute = compute_;
/* Performs the COUNT transformation T on case C. */
static int
count_trns_proc (void *trns_, struct ccase *c,
- int case_num UNUSED)
+ casenum_t case_num UNUSED)
{
struct count_trns *trns = trns_;
struct dst_var *dv;
/* Performs RECODE transformation. */
static int
-recode_trns_proc (void *trns_, struct ccase *c, int case_idx UNUSED)
+recode_trns_proc (void *trns_, struct ccase *c, casenum_t case_idx UNUSED)
{
struct recode_trns *trns = trns_;
size_t i;
/* Executes a SAMPLE transformation. */
static int
sample_trns_proc (void *t_, struct ccase *c UNUSED,
- int case_num UNUSED)
+ casenum_t case_num UNUSED)
{
struct sample_trns *t = t_;
double U;
/* Performs the SELECT IF transformation T on case C. */
static int
select_if_proc (void *t_, struct ccase *c,
- int case_num)
+ casenum_t case_num)
{
struct select_if_trns *t = t_;
return (expr_evaluate_num (t->e, c, case_num) == 1.0
return reader;
}
+
+static struct casereader *
+flexifilereader_clone (const struct casereader *cr)
+{
+ const struct flexifilereader *ffr = (const struct flexifilereader *) cr;
+ struct flexifilereader *new_ffr = xzalloc (sizeof *new_ffr);
+ struct casereader *new_reader = (struct casereader *) new_ffr;
+ struct casefile *cf = casereader_get_casefile (cr);
+
+ casereader_register (cf, new_reader, CLASS_CASEREADER(&class_reader));
+
+ new_ffr->case_idx = ffr->case_idx ;
+ new_ffr->destructive = ffr->destructive ;
+
+ return new_reader;
+}
+
+
static bool
flexifile_in_core(const struct casefile *cf UNUSED)
{
{
flexifilereader_get_next_case,
0, /* cnum */
- flexifilereader_destroy
+ flexifilereader_destroy,
+ flexifilereader_clone
}
};
diff -b $TEMPDIR/casefile.out - <<EOF
Casefile tests succeeded.
EOF
-
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
if [ $? -ne 0 ] ; then fail ; fi
-
pass;