projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0b535a3
)
dialog: Avoid assumption that enum val_type can have negative value.
20140218030509/pspp
author
Ben Pfaff
<blp@cs.stanford.edu>
Tue, 18 Feb 2014 01:57:46 +0000
(17:57 -0800)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Tue, 18 Feb 2014 02:00:38 +0000
(18:00 -0800)
Reported by Clang.
src/ui/gui/dialog-common.c
patch
|
blob
|
history
diff --git
a/src/ui/gui/dialog-common.c
b/src/ui/gui/dialog-common.c
index 9e97923e3f977188d305e791d3f3ad9c1ad887cc..7472b5708fa99294de1a102ae541572b1669f2c2 100644
(file)
--- a/
src/ui/gui/dialog-common.c
+++ b/
src/ui/gui/dialog-common.c
@@
-1,5
+1,5
@@
/* PSPPIRE - a graphical user interface for PSPP.
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007 Free Software Foundation
+ Copyright (C) 2007
, 2014
Free Software Foundation
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
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
@@
-43,8
+43,9
@@
homogeneous_types (GtkWidget *source, GtkWidget *dest)
PsppireDict *dict;
GtkTreeSelection *selection;
PsppireDict *dict;
GtkTreeSelection *selection;
- enum val_type type
= -1
;
+ enum val_type type;
GList *list, *l;
GList *list, *l;
+ bool have_type;
while (GTK_IS_TREE_MODEL_FILTER (model))
{
while (GTK_IS_TREE_MODEL_FILTER (model))
{
@@
-58,6
+59,7
@@
homogeneous_types (GtkWidget *source, GtkWidget *dest)
list = gtk_tree_selection_get_selected_rows (selection, &model);
/* Iterate through the selection of the source treeview */
list = gtk_tree_selection_get_selected_rows (selection, &model);
/* Iterate through the selection of the source treeview */
+ have_type = false;
for (l = list; l ; l = l->next)
{
GtkTreePath *path = l->data;
for (l = list; l ; l = l->next)
{
GtkTreePath *path = l->data;
@@
-71,16
+73,14
@@
homogeneous_types (GtkWidget *source, GtkWidget *dest)
gtk_tree_path_free (fpath);
gtk_tree_path_free (fpath);
- if ( type != -1 )
- {
- if ( var_get_type (v) != type )
- {
- retval = FALSE;
- break;
- }
- }
+ if (have_type && var_get_type (v) != type)
+ {
+ retval = FALSE;
+ break;
+ }
type = var_get_type (v);
type = var_get_type (v);
+ have_type = true;
}
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
}
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
@@
-99,16
+99,14
@@
homogeneous_types (GtkWidget *source, GtkWidget *dest)
const struct variable *v;
gtk_tree_model_get (model, &iter, 0, &v, -1);
const struct variable *v;
gtk_tree_model_get (model, &iter, 0, &v, -1);
- if ( type != -1 )
- {
- if ( var_get_type (v) != type )
- {
- retval = FALSE;
- break;
- }
- }
+ if ( have_type && var_get_type (v) != type )
+ {
+ retval = FALSE;
+ break;
+ }
type = var_get_type (v);
type = var_get_type (v);
+ have_type = true;
}
return retval;
}
return retval;