From 8297784ffdab47d35820735eb130a484ba9b6c01 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 20 Oct 2006 11:32:56 +0000 Subject: [PATCH] Constness and global namespace patrol. --- po/de.po | 2 +- po/pspp.pot | 2 +- src/data/data-in.c | 5 +++-- src/data/data-out.c | 2 +- src/data/format.c | 8 ++++---- src/data/format.h | 2 +- src/data/identifier.h | 2 ++ src/language/control/control-stack.c | 2 +- src/language/data-io/print-space.c | 3 +-- src/language/expressions/optimize.c | 4 ++-- src/language/expressions/parse.c | 6 +++--- src/language/expressions/private.h | 2 +- src/language/lexer/lexer.c | 7 +------ src/language/stats/frequencies.q | 4 ++-- src/language/stats/means.q | 9 ++++----- src/language/stats/regression.q | 6 +++--- src/output/postscript.c | 3 +-- src/output/table.c | 2 +- 18 files changed, 33 insertions(+), 38 deletions(-) diff --git a/po/de.po b/po/de.po index aecf07eb..df48c959 100644 --- a/po/de.po +++ b/po/de.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.4.2\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2006-10-19 16:31+0800\n" +"POT-Creation-Date: 2006-10-20 10:21+0800\n" "PO-Revision-Date: 2006-05-26 17:49+0800\n" "Last-Translator: John Darrington \n" "Language-Team: German \n" diff --git a/po/pspp.pot b/po/pspp.pot index ebefd7c0..039670c6 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2006-10-19 16:31+0800\n" +"POT-Creation-Date: 2006-10-20 10:21+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/data/data-in.c b/src/data/data-in.c index 4ee0a4f2..8a62d8fc 100644 --- a/src/data/data-in.c +++ b/src/data/data-in.c @@ -1394,7 +1394,8 @@ data_in (struct data_in *i) } { - static bool (*const handlers[FMT_NUMBER_OF_FORMATS])(struct data_in *) = + typedef bool (*handler_t) (struct data_in *); + static const handler_t handlers[FMT_NUMBER_OF_FORMATS] = { parse_numeric, parse_N, parse_numeric, parse_numeric, parse_numeric, parse_numeric, parse_numeric, @@ -1407,7 +1408,7 @@ data_in (struct data_in *i) parse_WKDAY, parse_MONTH, }; - bool (*handler)(struct data_in *); + handler_t handler; bool success; handler = handlers[i->format.type]; diff --git a/src/data/data-out.c b/src/data/data-out.c index 0585dc2b..6106fc30 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -348,7 +348,7 @@ convert_F_plus (char *dst, const struct fmt_spec *fp, double number) static int convert_Z (char *dst, const struct fmt_spec *fp, double number) { - static int warned = 0; + static bool warned = false; if (!warned) { diff --git a/src/data/format.c b/src/data/format.c index 01a8d317..022b5b18 100644 --- a/src/data/format.c +++ b/src/data/format.c @@ -35,7 +35,7 @@ #define DEFFMT(LABEL, NAME, N_ARGS, IMIN_W, IMAX_W, OMIN_W, OMAX_W, CAT, \ OUTPUT, SPSS_FMT) \ {NAME, N_ARGS, IMIN_W, IMAX_W, OMIN_W, OMAX_W, CAT, OUTPUT, SPSS_FMT}, -struct fmt_desc formats[FMT_NUMBER_OF_FORMATS + 1] = +const struct fmt_desc formats[FMT_NUMBER_OF_FORMATS + 1] = { #include "format.def" {"", -1, -1, -1, -1, -1, 0000, -1, -1}, @@ -85,7 +85,7 @@ fmt_to_string (const struct fmt_spec *f) static bool check_common_specifier (const struct fmt_spec *spec, bool emit_error) { - struct fmt_desc *f ; + const struct fmt_desc *f ; char *str; assert (spec->type < FMT_NUMBER_OF_FORMATS); @@ -125,7 +125,7 @@ check_common_specifier (const struct fmt_spec *spec, bool emit_error) int check_input_specifier (const struct fmt_spec *spec, int emit_error) { - struct fmt_desc *f; + const struct fmt_desc *f; char *str ; if (!check_common_specifier (spec, emit_error)) @@ -165,7 +165,7 @@ check_input_specifier (const struct fmt_spec *spec, int emit_error) int check_output_specifier (const struct fmt_spec *spec, int emit_error) { - struct fmt_desc *f; + const struct fmt_desc *f; char *str ; if (!check_common_specifier (spec, emit_error)) diff --git a/src/data/format.h b/src/data/format.h index e9d5e5e3..b5e7130a 100644 --- a/src/data/format.h +++ b/src/data/format.h @@ -98,7 +98,7 @@ bool alignment_is_valid(enum alignment a); /* Descriptions of all the display formats above. */ -extern struct fmt_desc formats[]; +extern const struct fmt_desc formats[]; union value; diff --git a/src/data/identifier.h b/src/data/identifier.h index 7f4beb74..53be9a76 100644 --- a/src/data/identifier.h +++ b/src/data/identifier.h @@ -68,4 +68,6 @@ bool lex_id_match_len (const char *keyword_string, size_t keyword_len, bool lex_id_match (const char *keyword_string, const char *token_string); int lex_id_to_token (const char *id, size_t len); +extern const char *keywords[T_N_KEYWORDS + 1] ; + #endif /* !lex_def_h */ diff --git a/src/language/control/control-stack.c b/src/language/control/control-stack.c index 72638429..193b52b0 100644 --- a/src/language/control/control-stack.c +++ b/src/language/control/control-stack.c @@ -16,7 +16,7 @@ struct ctl_struct void *private; /* Private data. */ }; -struct ctl_struct *ctl_stack; +static struct ctl_struct *ctl_stack; void ctl_stack_clear (void) diff --git a/src/language/data-io/print-space.c b/src/language/data-io/print-space.c index 86d94cbc..4414bb16 100644 --- a/src/language/data-io/print-space.c +++ b/src/language/data-io/print-space.c @@ -41,8 +41,7 @@ struct print_space_trns { struct dfm_writer *writer; /* Output data file. */ struct expression *expr; /* Number of lines; NULL means 1. */ - } -print_space_trns; + }; static trns_proc_func print_space_trns_proc; static trns_free_func print_space_trns_free; diff --git a/src/language/expressions/optimize.c b/src/language/expressions/optimize.c index 15451792..d80f4069 100644 --- a/src/language/expressions/optimize.c +++ b/src/language/expressions/optimize.c @@ -45,7 +45,7 @@ expr_optimize (union any_node *node, struct expression *e) { int nonconst_cnt = 0; /* Number of nonconstant children. */ int sysmis_cnt = 0; /* Number of system-missing children. */ - struct operation *op; + const struct operation *op; struct composite_node *c; int i; @@ -308,7 +308,7 @@ flatten_atom (union any_node *n, struct expression *e) static void flatten_composite (union any_node *n, struct expression *e) { - struct operation *op = &operations[n->type]; + const struct operation *op = &operations[n->type]; size_t i; for (i = 0; i < n->composite.arg_cnt; i++) diff --git a/src/language/expressions/parse.c b/src/language/expressions/parse.c index 979e756a..43339baa 100644 --- a/src/language/expressions/parse.c +++ b/src/language/expressions/parse.c @@ -894,7 +894,7 @@ parse_vector_element (struct expression *e) /* Individual function parsing. */ -struct operation operations[OP_first + OP_cnt] = { +const struct operation operations[OP_first + OP_cnt] = { #include "parse.inc" }; @@ -953,7 +953,7 @@ lookup_function_helper (const char *name, const struct operation **first, const struct operation **last) { - struct operation *f; + const struct operation *f; for (f = operations + OP_function_first; f <= operations + OP_function_last; f++) @@ -1327,7 +1327,7 @@ expr_allocate_binary (struct expression *e, operation_type op, static bool is_valid_node (union any_node *n) { - struct operation *op; + const struct operation *op; size_t i; assert (n != NULL); diff --git a/src/language/expressions/private.h b/src/language/expressions/private.h index 3fa108d5..a47c2216 100644 --- a/src/language/expressions/private.h +++ b/src/language/expressions/private.h @@ -78,7 +78,7 @@ struct operation int array_granularity; }; -extern struct operation operations[]; +extern const struct operation operations[]; /* Tree structured expressions. */ diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index a8a6cffc..452eb7e7 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -46,11 +46,6 @@ */ -/* Global variables. */ - -extern const char *keywords[T_N_KEYWORDS + 1]; - - /* Current token. */ int token; @@ -859,7 +854,7 @@ lex_token_name (int token) return t; } - return _(""); + NOT_REACHED (); } /* Returns an ASCII representation of the current token as a diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index 211498fc..24ab054b 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -1168,9 +1168,9 @@ dump_full (struct variable *v) const char *s; }; - struct init *p; + const struct init *p; - static struct init vec[] = + static const struct init vec[] = { {4, 0, N_("Valid")}, {5, 0, N_("Cum")}, diff --git a/src/language/stats/means.q b/src/language/stats/means.q index a8739bc2..bc927b47 100644 --- a/src/language/stats/means.q +++ b/src/language/stats/means.q @@ -52,13 +52,12 @@ /* (functions) */ /* TABLES: Variable lists for each dimension. */ -int n_dim; /* Number of dimensions. */ -size_t *nv_dim; /* Number of variables in each dimension. */ -struct variable ***v_dim; /* Variables in each dimension. */ +static int n_dim; /* Number of dimensions. */ +static size_t *nv_dim; /* Number of variables in each dimension. */ +static struct variable ***v_dim; /* Variables in each dimension. */ /* VARIABLES: List of variables. */ -int n_var; -struct variable **v_var; +static struct variable **v_var; /* Parses and executes the T-TEST procedure. */ int diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index 1690abc0..6f9dc6cc 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -84,7 +84,7 @@ static struct cmd_regression cmd; /* Linear regression models. */ -pspp_linreg_cache **models = NULL; +static pspp_linreg_cache **models = NULL; /* Transformations for saving predicted values @@ -110,12 +110,12 @@ static size_t n_variables; File where the model will be saved if the EXPORT subcommand is given. */ -struct file_handle *model_file; +static struct file_handle *model_file; /* Return value for the procedure. */ -int pspp_reg_rc = CMD_SUCCESS; +static int pspp_reg_rc = CMD_SUCCESS; static bool run_regression (const struct ccase *, const struct casefile *, void *); diff --git a/src/output/postscript.c b/src/output/postscript.c index bd7a088a..b658cdf3 100644 --- a/src/output/postscript.c +++ b/src/output/postscript.c @@ -109,8 +109,7 @@ struct ps_driver_ext struct font *fonts[OUTP_FONT_CNT]; int last_font; /* Index of last font set with setfont. */ - } -ps_driver_ext; + }; /* Transform logical y-ordinate Y into a page ordinate. */ #define YT(Y) (this->length - (Y)) diff --git a/src/output/table.c b/src/output/table.c index a7dc4817..461a2d84 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -838,7 +838,7 @@ tab_next_row (struct tab_table *t) static struct tab_table *t; static struct outp_driver *d; -int tab_hit; +static int tab_hit; /* Set the current table to TABLE. */ static void -- 2.30.2