+Wed Mar 3 20:44:37 2004 Ben Pfaff <blp@gnu.org>
+
+ Fix a lot of "possibly uninitialized variable" warnings. Some of
+ them are even real bugs. A few of them make me wonder how the
+ code ever worked.
+
+ * aggregate.c: (parse_aggregate_functions) Initialize `function.
+
+ * ascii.c: (output_lines) Add default case to switch.
+
+ * crosstabs.q: Remove static variable `expected' and all
+ references to it.
+ (display_crosstabulation) Always calculate expected value.
+ (calc_chisq) Ditto.
+ (output_pivot_table) Initialize `cmp'.
+ (display_crosstabulation) New variable `last_row', which is
+ initialized.
+
+ * data-in.c: (parse_numeric) Always initialize sign. How did this
+ work at all?!
+
+ * data-list.c: (repeating_data_trns_proc) Always initialize code.
+ Always set info.ofs. (How did this work?!)
+
+ * expr-opt.c: (optimize_tree) Always initialize `m'.
+ (evaluate_tree) Always initialize `c'. (How did this work?)
+
+ * frequencies.q: (frq_custom_variables) Always initialize min,
+ max.
+ (frq_custom_grouped) Always initialize `dl'.
+
+ * groff-font.c: (groff_read_font) Always initialize char_set.
+
+ * matrix-data.c: (nr_output_data) Initialize `split'.
+ (wr_read_splits) Remove shadowing split_cnt declaration.
+ (wr_output_data) Initialize `split'.
+
+ * output.c: (tokener) Skip add character on syntax error.
+
+ * pool.c: (pool_strndup) Always set `copy'. (How did this work?!)
+
+ * postscript.c: (read_ps_encodings) Use line.string instead of
+ uninitialized `bp'.
+ (write_text) Add default case to switch.
+ (text) Always initialize multiple variables. Fix bug with
+ ligatures.
+
+ * print.c: (fixed_parse_fortran) Initialize head.
+ (alloc_line) Add default case to switch.
+
+ * recode.c: (parse_dest_spec) Handle case where nothing matches.
+ (recode_trns_proc) Move variable declaration inward. Add default
+ case to switch.
+
+ * sfm-read.c: (read_header) Initialize skip_amt.
+
+ * sysfile-info.c: (display_variables) Always initialize pc.
+
+ * vars-prs.c: Initialized `included'.
+
Wed Mar 3 09:30:09 2004 Ben Pfaff <blp@gnu.org>
* main.c: (main) sigaction()'s sa_flags member was uninitialized.
dest_label = NULL;
n_dest = 0;
src = NULL;
+ function = NULL;
n_src = 0;
arg[0].c = NULL;
arg[1].c = NULL;
ch = *ep;
n_passes = 3;
break;
+ default:
+ assert (0);
}
output_char (this, 1, ch);
n_chars += ep - bp + 1;
/* CELLS. */
static int num_cells; /* Number of cells requested. */
static int cells[8]; /* Cells requested. */
-static int expected; /* Nonzero if expected value is needed. */
/* WRITE. */
static int write; /* One of WR_* that specifies the WRITE style. */
mode = variables ? INTEGER : GENERAL;
/* CELLS. */
- expected = 0;
if (!cmd.sbc_cells)
{
cmd.a_cells[CRS_CL_COUNT] = 1;
cmd.a_cells[CRS_CL_NONE] = 0;
for (num_cells = i = 0; i < CRS_CL_count; i++)
if (cmd.a_cells[i])
- {
- if (i >= CRS_CL_EXPECTED)
- expected = 1;
- cmd.a_cells[num_cells++] = i;
- }
+ cmd.a_cells[num_cells++] = i;
}
/* STATISTICS. */
int tc = pe - pb; /* Table count. */
/* Table entry for header comparison. */
- struct table_entry *cmp;
+ struct table_entry *cmp = NULL;
x = xtab[(*pb)->table];
enum_var_values (pb, pe - pb, COL_VAR, &cols, &n_cols);
tab_hline (table, TAL_1, -1, n_cols, 0);
for (c = 0; c < n_cols; c++)
{
- double expected_value;
-
- if (expected)
- expected_value = row_tot[r] * col_tot[c] / W;
+ double expected_value = row_tot[r] * col_tot[c] / W;
for (i = 0; i < num_cells; i++)
{
double v;
/* Column totals, grand total. */
{
int c, j;
+ int last_row = 0;
if (num_cells > 1)
tab_hline (table, TAL_1, -1, n_cols, 0);
j++;
}
+ last_row = j;
}
- tab_offset (table, -1, tab_row (table) + j);
+ tab_offset (table, -1, tab_row (table) + last_row);
}
tab_offset (table, 0, -1);
const double freq = mat[n_cols * r + c];
const double residual = freq - expected;
- if (expected)
- chisq[0] += residual * residual / expected;
+ chisq[0] += residual * residual / expected;
if (freq)
chisq[1] += freq * log (expected / freq);
}
const double freq = mat[n_cols * r + c];
const double residual = freq - expected;
- if (expected)
- Xp += residual * residual / expected;
+ Xp += residual * residual / expected;
}
}
if (*i->s == '-' || *i->s == '+')
i->s++;
}
+ else
+ sign = 1;
if (type != FMT_DOT)
{
info.len = len;
info.beg = starts_beg;
info.end = starts_end;
+ info.ofs = length;
info.c = c;
info.verify_id = 0;
info.max_occurs = occurs_left;
- code = rpd_parse_record (&info);;
+ code = rpd_parse_record (&info);
if (!code)
return -2;
+ occurs_left -= code;
}
else if (cont_beg == 0)
return -3;
/* Make sure, if some occurrences are left, that we have
continuation records. */
- occurs_left -= code;
- if (occurs_left != 0 && cont_beg == 0)
+ if (occurs_left > 0 && cont_beg == 0)
{
tmsg (SE, RPD_ERR,
_("Number of repetitions specified on OCCURS (%d) "
"exceed number of repetitions available in "
"space on STARTS (%d), and CONTINUED not specified."),
- occurs, code);
+ occurs, (starts_end - starts_beg + 1) / length);
return -2;
}
info.len = len;
info.beg = cont_beg;
info.end = cont_end;
+ info.ofs = length;
info.c = c;
info.verify_id = 1;
info.max_occurs = occurs_left;
int nvar = 0;
/* New node. */
- struct nonterm_node *m;
+ struct nonterm_node *m = NULL;
/* Argument copying counter. */
int c;
case OP_RTRIM:
case OP_RTRIM_OPT:
{
- int c;
+ int c = ' ';
char *cp = s0;
if (n->type == OP_LTRIM_OPT || n->type == OP_RTRIM_OPT)
c = n->type == OP_LTRIM_OPT ? 'L' : 'R';
msg (SE, _("Second argument to %cTRIM() must be at least one "
"character in length."), c);
- c = ' ';
}
else
c = s1[0];
frq_custom_variables (struct cmd_frequencies *cmd UNUSED)
{
int mode;
- int min, max;
+ int min = 0, max = 0;
int old_n_variables = n_variables;
int i;
return 0;
}
}
- else
- nl = 0;
+ else
+ {
+ nl = 0;
+ dl = NULL;
+ }
for (i = 0; i < n; i++)
{
char *key;
/* 0=kernpairs section, 1=charset section. */
- int charset;
+ int charset = 0;
/* Index for previous line. */
int prev_index = -1;
size_t i;
split_cnt = dict_get_split_cnt (default_dict);
+ split = dict_get_split_vars (default_dict);
for (i = 0; i < split_cnt; i++)
temp_case->data[split[i]->fv].f = split_values[i];
}
{
int different = 0;
- size_t split_cnt;
int i;
for (i = 0; i < split_cnt; i++)
size_t i;
split_cnt = dict_get_split_cnt (default_dict);
+ split = dict_get_split_vars (default_dict);
for (i = 0; i < split_cnt; i++)
temp_case->data[split[i]->fv].f = split_values[i];
}
break;
default:
msg (IS, _("Syntax error in string constant."));
+ continue;
}
ds_putchar (&op_tokstr, (unsigned char) c);
}
copy = ((char *) b) + b->ofs;
b->ofs += size;
}
+ else
+ copy = pool_alloc (pool, size);
}
#else
copy = pool_alloc (pool, size);
for (;;)
{
- char *bp;
-
if (!ds_get_config_line (f, &line, &where))
{
if (ferror (f))
break;
}
- add_encoding (this, bp);
+ add_encoding (this, line.string);
}
ds_destroy (&line);
case OUTP_T_JUST_CENTER:
ofs = width_left / 2;
break;
+ default:
+ assert (0);
}
lp = line;
x = t->x;
y = t->y;
}
+ else
+ x = y = 0;
width = width_left = (t->options & OUTP_T_HORZ) ? t->h : INT_MAX;
height_left = (t->options & OUTP_T_VERT) ? t->v : INT_MAX;
max_height = 0;
prev_char = -1;
space_char = NULL;
+ space_buf_loc = NULL;
+ space_width_left = 0;
+
if (!width || !height_left)
goto exit;
/* Set char_name to the name of the character or ligature at
*cp. */
+ local_char_name[0] = *cp;
+ char_name = local_char_name;
if (ext->current->font->ligatures && *cp == 'f')
{
- int lig = 0;
+ int lig;
+ char_name = NULL;
if (cp < end - 1)
switch (cp[1])
local_char_name[0] = *cp++; /* 'f' */
char_name = local_char_name;
}
- else
- cp += strlen (char_name);
}
else if (*cp == '\n')
{
set separate to 1. */
continue;
}
- else
- {
- local_char_name[0] = *cp++;
- char_name = local_char_name;
- }
+ cp += strlen (char_name);
/* Figure out what size this character is, and what kern
adjustment we need. */
static struct fmt_list *
fixed_parse_fortran (void)
{
- struct fmt_list *head;
+ struct fmt_list *head = NULL;
struct fmt_list *fl = NULL;
lex_get (); /* skip opening parenthesis */
pot_w = i->fc + 1;
break;
case PRT_ERROR:
+ default:
assert (0);
- break;
}
if (pot_w > w)
w = pot_w;
v->c = NULL;
}
}
+ else
+ {
+ lex_error (_("expecting output value"));
+ return 0;
+ }
if ((rcd->flags & RCD_DEST_MASK) == RCD_DEST_ERROR)
rcd->flags |= flags;
int case_num UNUSED)
{
struct rcd_var *v;
- struct coding *cp;
for (v = ((struct recode_trns *) t)->codings; v; v = v->next)
{
+ struct coding *cp;
+
switch (v->flags & RCD_SRC_MASK)
{
case RCD_SRC_NUMERIC:
case RCD_SRC_STRING:
cp = find_src_string (v, c);
break;
+ default:
+ assert (0);
}
if (!cp)
continue;
struct sysfile_header hdr; /* Disk buffer. */
struct dictionary *dict; /* File dictionary. */
char prod_name[sizeof hdr.prod_name + 1]; /* Buffer for product name. */
- int skip_amt; /* Amount of product name to omit. */
+ int skip_amt = 0; /* Amount of product name to omit. */
int i;
/* Create the dictionary. */
nr = n + 5;
tab_hline (t, TAL_2, 0, nc - 1, 1);
tab_text (t, 0, 0, TAB_LEFT | TAT_TITLE, _("Variable"));
+ pc = (as == AS_INDEX ? 1 : 3);
if (as != AS_NAMES)
- {
- pc = (as == AS_INDEX ? 1 : 3);
- tab_text (t, pc, 0, TAB_LEFT | TAT_TITLE, _("Position"));
- }
+ tab_text (t, pc, 0, TAB_LEFT | TAT_TITLE, _("Position"));
if (as == AS_DICTIONARY || as == AS_VARIABLES)
tab_joint_text (t, 1, 0, 2, 0, TAB_LEFT | TAT_TITLE, _("Description"));
else if (as == AS_LABELS)
{
size_t vs_var_cnt;
int i;
- char *included;
+ char *included = NULL;
struct variable *v1, *v2;
int count, mv;