From: Ben Pfaff Date: Sat, 6 May 2006 18:01:13 +0000 (+0000) Subject: Continue reforming procedure execution. In this phase, add `const' to X-Git-Tag: v0.6.0~895 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=505d1c592469ea99da7723c2770f13f5dc965046;p=pspp-builds.git Continue reforming procedure execution. In this phase, add `const' to the case passed to procedure()'s callback. Updated all users of procedure() as well. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 3c6dbd4c..a27bf63b 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,20 @@ +Sat May 6 10:58:05 2006 Ben Pfaff + + Continue reforming procedure execution. In this phase, add + `const' to the case passed to procedure()'s callback. + + Updated all users of procedure() as well. + + * procedure.c: (struct write_case_data) Add "const" to ccase + parameter for case_func member. + (procedure) Add "const" to ccase parameter for proc_func + parameter. + (multipass_case_func) Make ccase parameter const. + (internal_procedure) Add "const" to ccase parameter for case_func + parameter. + (split_procedure_case_func) Make ccase parameter const. + (multipass_split_case_func) Make ccase parameter const. + Sat May 6 10:30:33 2006 Ben Pfaff Continue reforming procedure execution. In this phase, get rid of diff --git a/src/data/procedure.c b/src/data/procedure.c index 1ecfd331..dde7fcee 100644 --- a/src/data/procedure.c +++ b/src/data/procedure.c @@ -52,8 +52,8 @@ struct write_case_data { /* Function to call for each case. */ - bool (*case_func) (struct ccase *, void *); /* Function. */ - void *aux; /* Auxiliary data. */ + bool (*case_func) (const struct ccase *, void *); + void *aux; struct ccase trns_case; /* Case used for transformations. */ struct ccase sink_case; /* Case written to sink, if @@ -96,7 +96,8 @@ static void add_case_limit_trns (void); static void add_filter_trns (void); static void add_process_if_trns (void); -static bool internal_procedure (bool (*case_func) (struct ccase *, void *), +static bool internal_procedure (bool (*case_func) (const struct ccase *, + void *), bool (*end_func) (void *), void *aux); static void update_last_vfm_invocation (void); @@ -136,7 +137,7 @@ time_of_last_procedure (void) Returns true if successful, false if an I/O error occurred. */ bool -procedure (bool (*proc_func) (struct ccase *, void *), void *aux) +procedure (bool (*proc_func) (const struct ccase *, void *), void *aux) { return internal_procedure (proc_func, NULL, aux); } @@ -153,7 +154,7 @@ struct multipass_aux_data /* Case processing function for multipass_procedure(). */ static bool -multipass_case_func (struct ccase *c, void *aux_data_) +multipass_case_func (const struct ccase *c, void *aux_data_) { struct multipass_aux_data *aux_data = aux_data_; return casefile_append (aux_data->casefile, c); @@ -198,7 +199,7 @@ multipass_procedure (bool (*proc_func) (const struct casefile *, void *aux), Returns true if successful, false if an I/O error occurred (or if CASE_FUNC or END_FUNC ever returned false). */ static bool -internal_procedure (bool (*case_func) (struct ccase *, void *), +internal_procedure (bool (*case_func) (const struct ccase *, void *), bool (*end_func) (void *), void *aux) { @@ -484,8 +485,8 @@ struct split_aux_data }; static int equal_splits (const struct ccase *, const struct ccase *); -static bool split_procedure_case_func (struct ccase *c, void *split_aux_); -static bool split_procedure_end_func (void *split_aux_); +static bool split_procedure_case_func (const struct ccase *c, void *); +static bool split_procedure_end_func (void *); /* Like procedure(), but it automatically breaks the case stream into SPLIT FILE break groups. Before each group of cases with @@ -530,7 +531,7 @@ procedure_with_splits (void (*begin_func) (const struct ccase *, void *aux), /* Case callback used by procedure_with_splits(). */ static bool -split_procedure_case_func (struct ccase *c, void *split_aux_) +split_procedure_case_func (const struct ccase *c, void *split_aux_) { struct split_aux_data *split_aux = split_aux_; @@ -590,7 +591,7 @@ struct multipass_split_aux_data void *func_aux; /* Auxiliary data. */ }; -static bool multipass_split_case_func (struct ccase *c, void *aux_); +static bool multipass_split_case_func (const struct ccase *c, void *aux_); static bool multipass_split_end_func (void *aux_); static bool multipass_split_output (struct multipass_split_aux_data *); @@ -618,7 +619,7 @@ multipass_procedure_with_splits (bool (*split_func) (const struct ccase *first, /* Case callback used by multipass_procedure_with_splits(). */ static bool -multipass_split_case_func (struct ccase *c, void *aux_) +multipass_split_case_func (const struct ccase *c, void *aux_) { struct multipass_split_aux_data *aux = aux_; bool ok = true; diff --git a/src/data/procedure.h b/src/data/procedure.h index 76ca6dc8..3c43e712 100644 --- a/src/data/procedure.h +++ b/src/data/procedure.h @@ -62,7 +62,7 @@ bool proc_has_source (void); void proc_set_sink (struct case_sink *); struct casefile *proc_capture_output (void); -bool procedure (bool (*proc_func) (struct ccase *, void *), +bool procedure (bool (*proc_func) (const struct ccase *, void *), void *aux); bool procedure_with_splits (void (*begin_func) (const struct ccase *, void *), bool (*proc_func) (const struct ccase *, void *), diff --git a/src/language/data-io/get.c b/src/language/data-io/get.c index 0cc628be..5dfe29b3 100644 --- a/src/language/data-io/get.c +++ b/src/language/data-io/get.c @@ -450,7 +450,7 @@ parse_write_command (enum writer_type writer_type, /* Writes case C to writer AW. */ static bool -case_writer_write_case (struct case_writer *aw, struct ccase *c) +case_writer_write_case (struct case_writer *aw, const struct ccase *c) { if (aw->map != NULL) { @@ -462,7 +462,7 @@ case_writer_write_case (struct case_writer *aw, struct ccase *c) /* SAVE and EXPORT. */ -static bool output_proc (struct ccase *, void *); +static bool output_proc (const struct ccase *, void *); /* Parses and performs the SAVE or EXPORT procedure. */ static int @@ -489,7 +489,7 @@ parse_output_proc (enum writer_type writer_type) /* Writes case C to file. */ static bool -output_proc (struct ccase *c, void *aw_) +output_proc (const struct ccase *c, void *aw_) { struct case_writer *aw = aw_; return case_writer_write_case (aw, c); @@ -793,7 +793,7 @@ static bool mtf_delete_file_in_place (struct mtf_proc *, struct mtf_file **); static bool mtf_read_nonactive_records (void *); static bool mtf_processing_finish (void *); -static bool mtf_processing (struct ccase *, void *); +static bool mtf_processing (const struct ccase *, void *); static char *var_type_description (struct variable *); @@ -1305,10 +1305,10 @@ mtf_read_nonactive_records (void *mtf_) static inline int mtf_compare_BY_values (struct mtf_proc *mtf, struct mtf_file *a, struct mtf_file *b, - struct ccase *c) + const struct ccase *c) { - struct ccase *ca = case_is_null (&a->input) ? c : &a->input; - struct ccase *cb = case_is_null (&b->input) ? c : &b->input; + const struct ccase *ca = case_is_null (&a->input) ? c : &a->input; + const struct ccase *cb = case_is_null (&b->input) ? c : &b->input; assert ((a == NULL) + (b == NULL) + (c == NULL) <= 1); return case_compare_2dict (ca, cb, a->by, b->by, mtf->by_cnt); } @@ -1316,7 +1316,7 @@ mtf_compare_BY_values (struct mtf_proc *mtf, /* Perform one iteration of steps 3...7 above. Returns true if successful, false if an I/O error occurred. */ static bool -mtf_processing (struct ccase *c, void *mtf_) +mtf_processing (const struct ccase *c, void *mtf_) { struct mtf_proc *mtf = mtf_; @@ -1420,7 +1420,7 @@ mtf_processing (struct ccase *c, void *mtf_) if (mv != NULL && mtf->seq_nums[mv->index] != mtf->seq_num) { - struct ccase *record + const struct ccase *record = case_is_null (&iter->input) ? c : &iter->input; union value *out = case_data_rw (&mtf->mtf_case, mv->fv); diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index aa289716..49157839 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -154,10 +154,10 @@ static int aggregate_single_case (struct agr_proc *agr, static void dump_aggregate_info (struct agr_proc *agr, struct ccase *output); /* Aggregating to the active file. */ -static bool agr_to_active_file (struct ccase *, void *aux); +static bool agr_to_active_file (const struct ccase *, void *aux); /* Aggregating to a system file. */ -static bool presorted_agr_to_sysfile (struct ccase *, void *aux); +static bool presorted_agr_to_sysfile (const struct ccase *, void *aux); /* Parsing. */ @@ -1074,7 +1074,7 @@ initialize_aggregate_info (struct agr_proc *agr, const struct ccase *input) are dropped. Returns true if successful, false if an I/O error occurred. */ static bool -agr_to_active_file (struct ccase *c, void *agr_) +agr_to_active_file (const struct ccase *c, void *agr_) { struct agr_proc *agr = agr_; @@ -1087,7 +1087,7 @@ agr_to_active_file (struct ccase *c, void *agr_) /* Aggregate the current case and output it if we passed a breakpoint. */ static bool -presorted_agr_to_sysfile (struct ccase *c, void *agr_) +presorted_agr_to_sysfile (const struct ccase *c, void *agr_) { struct agr_proc *agr = agr_; diff --git a/src/language/stats/autorecode.c b/src/language/stats/autorecode.c index e808359b..89f546f2 100644 --- a/src/language/stats/autorecode.c +++ b/src/language/stats/autorecode.c @@ -85,7 +85,7 @@ struct autorecode_pgm static trns_proc_func autorecode_trns_proc; static trns_free_func autorecode_trns_free; -static bool autorecode_proc_func (struct ccase *, void *); +static bool autorecode_proc_func (const struct ccase *, void *); static hsh_compare_func compare_alpha_value, compare_numeric_value; static hsh_hash_func hash_alpha_value, hash_numeric_value; @@ -338,7 +338,7 @@ hash_numeric_value (const void *a_, void *foo UNUSED) } static bool -autorecode_proc_func (struct ccase *c, void *arc_) +autorecode_proc_func (const struct ccase *c, void *arc_) { struct autorecode_pgm *arc = arc_; size_t i;