From 8eac4df36306cd357bba29ffbfaddc537fc0be47 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 22 Oct 2006 11:07:52 +0000 Subject: [PATCH] More constness/namespace policing --- src/language/control/control-stack.c | 8 ++++---- src/language/control/control-stack.h | 6 +++--- src/language/control/do-if.c | 4 ++-- src/language/control/loop.c | 4 ++-- src/language/data-io/matrix-data.c | 2 +- src/language/stats/correlations.q | 4 ++-- src/language/stats/crosstabs.q | 2 +- src/language/stats/frequencies.q | 2 +- src/language/stats/oneway.q | 2 +- src/language/stats/rank.q | 4 ++-- src/output/ascii.c | 4 ++-- src/output/html.c | 4 ++-- src/output/htmlP.h | 2 +- src/output/manager.c | 4 ++-- src/output/manager.h | 2 +- src/output/output.c | 11 +++++------ src/output/output.h | 6 ++---- src/output/postscript.c | 4 ++-- src/output/table.c | 4 ++-- 19 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/language/control/control-stack.c b/src/language/control/control-stack.c index 193b52b0..cac206dd 100644 --- a/src/language/control/control-stack.c +++ b/src/language/control/control-stack.c @@ -11,7 +11,7 @@ struct ctl_struct { - struct ctl_class *class; /* Class of control structure. */ + const struct ctl_class *class; /* Class of control structure. */ struct ctl_struct *down; /* Points toward the bottom of ctl_stack. */ void *private; /* Private data. */ }; @@ -31,7 +31,7 @@ ctl_stack_clear (void) } void -ctl_stack_push (struct ctl_class *class, void *private) +ctl_stack_push (const struct ctl_class *class, void *private) { struct ctl_struct *ctl; @@ -44,7 +44,7 @@ ctl_stack_push (struct ctl_class *class, void *private) } void * -ctl_stack_top (struct ctl_class *class) +ctl_stack_top (const struct ctl_class *class) { struct ctl_struct *top = ctl_stack; if (top != NULL && top->class == class) @@ -61,7 +61,7 @@ ctl_stack_top (struct ctl_class *class) } void * -ctl_stack_search (struct ctl_class *class) +ctl_stack_search (const struct ctl_class *class) { struct ctl_struct *ctl; diff --git a/src/language/control/control-stack.h b/src/language/control/control-stack.h index 87ef4bee..ad373ea4 100644 --- a/src/language/control/control-stack.h +++ b/src/language/control/control-stack.h @@ -30,9 +30,9 @@ struct ctl_class }; void ctl_stack_clear (void); -void ctl_stack_push (struct ctl_class *, void *private); -void *ctl_stack_top (struct ctl_class *); -void *ctl_stack_search (struct ctl_class *); +void ctl_stack_push (const struct ctl_class *, void *private); +void *ctl_stack_top (const struct ctl_class *); +void *ctl_stack_search (const struct ctl_class *); void ctl_stack_pop (void *); bool ctl_stack_is_empty (void); diff --git a/src/language/control/do-if.c b/src/language/control/do-if.c index b39f67e5..48373666 100644 --- a/src/language/control/do-if.c +++ b/src/language/control/do-if.c @@ -80,7 +80,7 @@ struct do_if_trns int past_END_IF_index; /* Transformation just past last clause. */ }; -static struct ctl_class do_if_class; +static const struct ctl_class do_if_class; static int parse_clause (struct do_if_trns *); static void add_clause (struct do_if_trns *, @@ -285,7 +285,7 @@ break_trns_proc (void *do_if_, struct ccase *c UNUSED, casenum_t case_num UNUSED } /* DO IF control structure class definition. */ -static struct ctl_class do_if_class = +static const struct ctl_class do_if_class = { "DO IF", "END IF", diff --git a/src/language/control/loop.c b/src/language/control/loop.c index 1bb044e6..ce80f665 100644 --- a/src/language/control/loop.c +++ b/src/language/control/loop.c @@ -79,7 +79,7 @@ struct loop_trns int past_END_LOOP_index; /* Just past END LOOP transformation. */ }; -static struct ctl_class loop_class; +static const struct ctl_class loop_class; static trns_finalize_func loop_trns_finalize; static trns_proc_func loop_trns_proc, end_loop_trns_proc, break_trns_proc; @@ -371,7 +371,7 @@ break_trns_proc (void *loop_, struct ccase *c UNUSED, casenum_t case_num UNUSED) } /* LOOP control structure class definition. */ -static struct ctl_class loop_class = +static const struct ctl_class loop_class = { "LOOP", "END LOOP", diff --git a/src/language/data-io/matrix-data.c b/src/language/data-io/matrix-data.c index 99664fc6..5c8e011b 100644 --- a/src/language/data-io/matrix-data.c +++ b/src/language/data-io/matrix-data.c @@ -115,7 +115,7 @@ static const int content_type[PROX + 1] = }; /* Name of each content type. */ -static const char *content_names[PROX + 1] = +static const char *const content_names[PROX + 1] = { "N", "N", "N_MATRIX", "MEAN", "STDDEV", "COUNT", "MSE", "DFE", "MAT", "COV", "CORR", "PROX", diff --git a/src/language/stats/correlations.q b/src/language/stats/correlations.q index b1126470..e3a181f0 100644 --- a/src/language/stats/correlations.q +++ b/src/language/stats/correlations.q @@ -41,9 +41,9 @@ struct cor_set size_t nv1, nv2; }; -struct cor_set *cor_list, *cor_last; +static struct cor_set *cor_list, *cor_last; -struct file_handle *matrix_file; +static struct file_handle *matrix_file; static void free_correlations_state (void); static int internal_cmd_correlations (void); diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index 405460de..e7466d72 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -950,7 +950,7 @@ static int n_rows; static int ns_cols, ns_rows; /* Crosstabulation. */ -static struct crosstab *x; +static const struct crosstab *x; /* Number of variables from the crosstabulation to consider. This is either x->nvar, if pivoting is on, or 2, if pivoting is off. */ diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index 24ab054b..d78f37a7 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -118,7 +118,7 @@ struct frq_info }; /* Table of statistics, indexed by dsc_*. */ -static struct frq_info st_name[frq_n_stats + 1] = +static const struct frq_info st_name[frq_n_stats + 1] = { {FRQ_ST_MEAN, N_("Mean")}, {FRQ_ST_SEMEAN, N_("S.E. Mean")}, diff --git a/src/language/stats/oneway.q b/src/language/stats/oneway.q index 0b75608a..9b5a36bc 100644 --- a/src/language/stats/oneway.q +++ b/src/language/stats/oneway.q @@ -88,7 +88,7 @@ static struct hsh_table *global_group_hash ; /* The number of distinct values of the independent variable, when all missing values are disregarded */ -static int ostensible_number_of_groups=-1; +static int ostensible_number_of_groups = -1; /* Function to use for testing for missing values */ diff --git a/src/language/stats/rank.q b/src/language/stats/rank.q index 9441a19b..5f58f8c6 100644 --- a/src/language/stats/rank.q +++ b/src/language/stats/rank.q @@ -117,7 +117,7 @@ static const struct fmt_spec dest_format[n_RANK_FUNCS] = { {FMT_F, 8, 4} /* savage */ }; -static const char *function_name[n_RANK_FUNCS] = { +static const char * const function_name[n_RANK_FUNCS] = { "RANK", "NORMAL", "PERCENT", @@ -128,7 +128,7 @@ static const char *function_name[n_RANK_FUNCS] = { "SAVAGE" }; -static rank_function_t rank_func[n_RANK_FUNCS] = { +static const rank_function_t rank_func[n_RANK_FUNCS] = { rank_rank, rank_normal, rank_percent, diff --git a/src/output/ascii.c b/src/output/ascii.c index 3dba9775..12c58a40 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -247,7 +247,7 @@ enum output_file_arg }; -static struct outp_option option_tab[] = +static const struct outp_option option_tab[] = { {"headers", boolean_arg, 0}, {"paginate", boolean_arg, 1}, @@ -734,7 +734,7 @@ ascii_chart_finalise (struct outp_driver *d UNUSED, struct chart *ch UNUSED) } -struct outp_class ascii_class = +const struct outp_class ascii_class = { "ascii", 0, diff --git a/src/output/html.c b/src/output/html.c index 72ca57d9..a9d524b7 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -149,7 +149,7 @@ enum }; /* All the options that the HTML driver supports. */ -static struct outp_option option_tab[] = +static const struct outp_option option_tab[] = { {"output-file", string_arg, 0}, {"chart-files", string_arg, 1}, @@ -401,7 +401,7 @@ html_finalise_chart(struct outp_driver *d UNUSED, struct chart *ch) /* HTML driver class. */ -struct outp_class html_class = +const struct outp_class html_class = { "html", 1, diff --git a/src/output/htmlP.h b/src/output/htmlP.h index f1bf3d34..fa108ad2 100644 --- a/src/output/htmlP.h +++ b/src/output/htmlP.h @@ -32,7 +32,7 @@ struct html_driver_ext size_t chart_cnt; }; -extern struct outp_class html_class; +extern const struct outp_class html_class; struct outp_driver; void html_put_cell_contents (struct outp_driver *this, diff --git a/src/output/manager.c b/src/output/manager.c index 468b2c23..0d82867a 100644 --- a/src/output/manager.c +++ b/src/output/manager.c @@ -62,10 +62,10 @@ som_blank_line (void) } /* Driver. */ -static struct outp_driver *d=0; +static struct outp_driver *d = 0; /* Table. */ -static struct som_entity *t=0; +static struct som_entity *t = 0; /* Flags. */ static unsigned flags; diff --git a/src/output/manager.h b/src/output/manager.h index 1568dca3..7c0a0dc8 100644 --- a/src/output/manager.h +++ b/src/output/manager.h @@ -47,7 +47,7 @@ enum som_type /* Entity (Table or Chart) . */ struct som_entity { - struct som_table_class *class; /* Table class. */ + const struct som_table_class *class; /* Table class. */ enum som_type type; /* Table or Chart */ void *ext; /* Owned by */ }; diff --git a/src/output/output.c b/src/output/output.c index a63f1171..91df8f02 100644 --- a/src/output/output.c +++ b/src/output/output.c @@ -70,12 +70,12 @@ static struct outp_names *outp_configure_vec; /* A list of driver classes. */ struct outp_driver_class_list { - struct outp_class *class; + const struct outp_class *class; struct outp_driver_class_list *next; }; -struct outp_driver_class_list *outp_class_list; -struct outp_driver *outp_driver_list; +static struct outp_driver_class_list *outp_class_list; +static struct outp_driver *outp_driver_list; char *outp_title; char *outp_subtitle; @@ -91,7 +91,7 @@ static void configure_driver (const struct substring, const struct substring, /* Add a class to the class list. */ static void -add_class (struct outp_class *class) +add_class (const struct outp_class *class) { struct outp_driver_class_list *new_list = xmalloc (sizeof *new_list); @@ -227,7 +227,6 @@ outp_init (void) { extern struct outp_class ascii_class; extern struct outp_class postscript_class; - extern struct outp_class html_class; char def[] = "default"; @@ -797,7 +796,7 @@ destroy_driver (struct outp_driver *d) code and stores subcategory in *SUBCAT on success. Returns -1 on failure. */ int -outp_match_keyword (const char *s, struct outp_option *tab, int *subcat) +outp_match_keyword (const char *s, const struct outp_option *tab, int *subcat) { for (; tab->keyword != NULL; tab++) if (!strcmp (s, tab->keyword)) diff --git a/src/output/output.h b/src/output/output.h index 6782a11e..5f986aa0 100644 --- a/src/output/output.h +++ b/src/output/output.h @@ -103,7 +103,7 @@ enum struct outp_driver { struct outp_driver *next, *prev; /* List of drivers. */ - struct outp_class *class; /* Driver class. */ + const struct outp_class *class; /* Driver class. */ char *name; /* Name of this driver. */ bool page_open; /* 1=page is open, 0=page is closed. */ int device; /* Zero or more of OUTP_DEV_*. */ @@ -128,8 +128,6 @@ struct outp_option int subcat; /* Subcategory. */ }; -/* List of configured output drivers. */ -extern struct outp_driver *outp_driver_list; /* Title, subtitle. */ extern char *outp_title; @@ -152,7 +150,7 @@ bool outp_parse_options (struct substring options, bool (*) (struct outp_driver *, const char *key, const struct string *value), struct outp_driver *); -int outp_match_keyword (const char *, struct outp_option *, int *); +int outp_match_keyword (const char *, const struct outp_option *, int *); int outp_evaluate_dimension (char *, char **); bool outp_get_paper_size (char *, int *h, int *v); diff --git a/src/output/postscript.c b/src/output/postscript.c index b658cdf3..614fb505 100644 --- a/src/output/postscript.c +++ b/src/output/postscript.c @@ -270,7 +270,7 @@ enum }; /* All the options that the PostScript driver supports. */ -static struct outp_option option_tab[] = +static const struct outp_option option_tab[] = { {"output-file", output_file_arg,0}, {"paper-size", paper_size_arg, 0}, @@ -1426,7 +1426,7 @@ reencode_font (struct outp_driver *this, struct font *font) } /* PostScript driver class. */ -struct outp_class postscript_class = +const struct outp_class postscript_class = { "postscript", 0, diff --git a/src/output/table.c b/src/output/table.c index 461a2d84..be2c2136 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -38,7 +38,7 @@ #include "gettext.h" #define _(msgid) gettext (msgid) -struct som_table_class tab_table_class; +const struct som_table_class tab_table_class; static char *command_name; /* Returns the font to use for a cell with the given OPTIONS. */ @@ -1220,7 +1220,7 @@ tabi_render (int c0, int r0, int c1, int r1) y = render_rows (y, c0, c1, (t->nr - t->b) * 2, t->nr * 2 + 1); } -struct som_table_class tab_table_class = +const struct som_table_class tab_table_class = { tabi_table, tabi_driver, -- 2.30.2