X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fscratch-writer.c;h=631305fe9d96c6a668c33473780867930f88d3a4;hb=4e8257086ffc71bc5a1785fd86610921be677887;hp=70a65ce9b67760ec585c9a54878174f4abc300bf;hpb=707848060e414fe93458834446dd7cdbf800667f;p=pspp-builds.git diff --git a/src/data/scratch-writer.c b/src/data/scratch-writer.c index 70a65ce9..631305fe 100644 --- a/src/data/scratch-writer.c +++ b/src/data/scratch-writer.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,6 +34,8 @@ #include "xalloc.h" +#define N_(msgid) (msgid) + /* A scratch file writer. */ struct scratch_writer { @@ -44,7 +46,7 @@ struct scratch_writer struct casewriter *subwriter; /* Data output. */ }; -static struct casewriter_class scratch_writer_casewriter_class; +static const struct casewriter_class scratch_writer_casewriter_class; /* Opens FH, which must have referent type FH_REF_SCRATCH, and returns a scratch_writer for it, or a null pointer on @@ -57,10 +59,11 @@ scratch_writer_open (struct file_handle *fh, struct scratch_writer *writer; struct casewriter *casewriter; struct fh_lock *lock; - size_t dict_value_cnt; /* Get exclusive write access to handle. */ - lock = fh_lock (fh, FH_REF_SCRATCH, "scratch file", FH_ACC_WRITE, true); + /* TRANSLATORS: this fragment will be interpolated into + messages in fh_lock() that identify types of files. */ + lock = fh_lock (fh, FH_REF_SCRATCH, N_("scratch file"), FH_ACC_WRITE, true); if (lock == NULL) return NULL; @@ -79,10 +82,9 @@ scratch_writer_open (struct file_handle *fh, } else writer->compactor = NULL; - dict_value_cnt = dict_get_next_value_idx (writer->dict); - writer->subwriter = autopaging_writer_create (dict_value_cnt); + writer->subwriter = autopaging_writer_create (dict_get_proto (writer->dict)); - casewriter = casewriter_create (dict_value_cnt, + casewriter = casewriter_create (dict_get_proto (writer->dict), &scratch_writer_casewriter_class, writer); taint_propagate (casewriter_get_taint (writer->subwriter), casewriter_get_taint (casewriter)); @@ -95,15 +97,8 @@ scratch_writer_casewriter_write (struct casewriter *w UNUSED, void *writer_, struct ccase *c) { struct scratch_writer *writer = writer_; - struct ccase tmp; - if (writer->compactor) - { - case_map_execute (writer->compactor, c, &tmp); - case_destroy (c); - } - else - case_move (&tmp, c); - casewriter_write (writer->subwriter, &tmp); + casewriter_write (writer->subwriter, + case_map_execute (writer->compactor, c)); } /* Closes WRITER. */ @@ -139,7 +134,7 @@ scratch_writer_casewriter_destroy (struct casewriter *w UNUSED, void *writer_) free (writer); } -static struct casewriter_class scratch_writer_casewriter_class = +static const struct casewriter_class scratch_writer_casewriter_class = { scratch_writer_casewriter_write, scratch_writer_casewriter_destroy,