[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src data/format.c data/format.h data/sys-f...
From: |
John Darrington |
Subject: |
[Pspp-cvs] pspp/src data/format.c data/format.h data/sys-f... |
Date: |
Wed, 31 May 2006 07:38:03 +0000 |
CVSROOT: /sources/pspp
Module name: pspp
Branch:
Changes by: John Darrington <address@hidden> 06/05/31 07:38:03
Modified files:
src/data : format.c format.h sys-file-reader.c
src/libpspp : i18n.c
src/ui/gui : menu-actions.c psppire-var-store.c
val-labs-dialog.c var-sheet.c var-sheet.h
Log message:
Fixed minor memory leak.
Character set conversion in value label dialog box.
Made more robust in the presence of bad alignment and measure
parameters.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/format.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/format.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/sys-file-reader.c.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/libpspp/i18n.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/menu-actions.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/psppire-var-store.c.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/val-labs-dialog.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/var-sheet.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/var-sheet.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: pspp/src/data/format.c
diff -u pspp/src/data/format.c:1.3 pspp/src/data/format.c:1.4
--- pspp/src/data/format.c:1.3 Wed Mar 15 03:29:10 2006
+++ pspp/src/data/format.c Wed May 31 07:38:03 2006
@@ -372,3 +372,20 @@
assert (check_output_specifier (&f, 0));
return f;
}
+
+
+bool
+measure_is_valid(enum measure m)
+{
+ if ( m <= 0 ) return false;
+ if ( m >= n_MEASURES) false;
+ return true;
+}
+
+bool
+alignment_is_valid(enum alignment a)
+{
+ if ( a < 0 ) return false;
+ if ( a >= n_ALIGN) return false;
+ return true;
+}
Index: pspp/src/data/format.h
diff -u pspp/src/data/format.h:1.2 pspp/src/data/format.h:1.3
--- pspp/src/data/format.h:1.2 Tue May 2 03:51:43 2006
+++ pspp/src/data/format.h Wed May 31 07:38:03 2006
@@ -76,7 +76,8 @@
{
ALIGN_LEFT = 0,
ALIGN_RIGHT = 1,
- ALIGN_CENTRE = 2
+ ALIGN_CENTRE = 2,
+ n_ALIGN
};
@@ -84,9 +85,12 @@
{
MEASURE_NOMINAL=1,
MEASURE_ORDINAL=2,
- MEASURE_SCALE=3
+ MEASURE_SCALE=3,
+ n_MEASURES
};
+bool measure_is_valid(enum measure m);
+bool alignment_is_valid(enum alignment a);
/* Descriptions of all the display formats above. */
Index: pspp/src/data/sys-file-reader.c
diff -u pspp/src/data/sys-file-reader.c:1.17
pspp/src/data/sys-file-reader.c:1.18
--- pspp/src/data/sys-file-reader.c:1.17 Sun May 7 10:11:51 2006
+++ pspp/src/data/sys-file-reader.c Wed May 31 07:38:03 2006
@@ -510,6 +510,16 @@
assertive_buf_read (r, ¶ms, sizeof(params), 0);
+ if ( ! measure_is_valid(params.measure)
+ ||
+ ! alignment_is_valid(params.align))
+ {
+ msg(MW,
+ _("Invalid variable display parameters. Default
parameters substituted."),
+ fh_get_file_name(r->fh));
+ continue;
+ }
+
v = dict_get_var(*dict, i);
v->measure = params.measure;
Index: pspp/src/libpspp/i18n.c
diff -u pspp/src/libpspp/i18n.c:1.1 pspp/src/libpspp/i18n.c:1.2
--- pspp/src/libpspp/i18n.c:1.1 Tue May 30 12:01:33 2006
+++ pspp/src/libpspp/i18n.c Wed May 31 07:38:03 2006
@@ -54,6 +54,9 @@
/* FIXME: Need to ensure that this char is valid in the target encoding */
const char fallbackchar = '?';
+ if ( text == NULL )
+ return NULL;
+
if ( length == -1 )
length = strlen(text);
@@ -71,8 +74,6 @@
inbytes = length;
do {
-
-
result = iconv(convertor[how], &ip, &inbytes,
&op, &outbytes);
@@ -108,11 +109,17 @@
}
}
-
} while ( -1 == result );
+ if (outbytes == 0 )
+ {
+ char *const oldaddr = outbuf;
+ outbuf = xrealloc(outbuf, outbufferlength + 1);
+
+ op += (outbuf - oldaddr) ;
+ }
+
*op = '\0';
-
return outbuf;
}
Index: pspp/src/ui/gui/menu-actions.c
diff -u pspp/src/ui/gui/menu-actions.c:1.8 pspp/src/ui/gui/menu-actions.c:1.9
--- pspp/src/ui/gui/menu-actions.c:1.8 Tue May 30 12:01:33 2006
+++ pspp/src/ui/gui/menu-actions.c Wed May 31 07:38:03 2006
@@ -71,6 +71,8 @@
gchar *title = g_strdup_printf("%s --- %s", text, gettext(window_title));
gtk_window_set_title(GTK_WINDOW(data_editor), title);
+
+ g_free(title);
}
Index: pspp/src/ui/gui/psppire-var-store.c
diff -u pspp/src/ui/gui/psppire-var-store.c:1.9
pspp/src/ui/gui/psppire-var-store.c:1.10
--- pspp/src/ui/gui/psppire-var-store.c:1.9 Tue May 30 12:01:33 2006
+++ pspp/src/ui/gui/psppire-var-store.c Wed May 31 07:38:03 2006
@@ -617,14 +617,21 @@
}
break;
case COL_ALIGN:
- return
g_locale_to_utf8(gettext(alignments[psppire_variable_get_alignment(pv)]),
- -1, -0, 0, err);
+ {
+ const gint align = psppire_variable_get_alignment(pv);
+
+ g_assert(align < n_ALIGNMENTS);
+ return g_locale_to_utf8(gettext(alignments[align]),-1, -0, 0, err);
+ }
break;
case COL_MEASURE:
- return
g_locale_to_utf8(gettext(measures[psppire_variable_get_measure(pv)]),
- -1, -0, 0, err);
- break;
+ {
+ const gint measure = psppire_variable_get_measure(pv);
+ g_assert(measure < n_MEASURES);
+ return g_locale_to_utf8(gettext(measures[measure]), -1, -0, 0, err);
+ }
+ break;
}
return 0;
}
Index: pspp/src/ui/gui/val-labs-dialog.c
diff -u pspp/src/ui/gui/val-labs-dialog.c:1.3
pspp/src/ui/gui/val-labs-dialog.c:1.4
--- pspp/src/ui/gui/val-labs-dialog.c:1.3 Tue Apr 4 12:43:22 2006
+++ pspp/src/ui/gui/val-labs-dialog.c Wed May 31 07:38:03 2006
@@ -271,6 +271,7 @@
on_select_row (GtkTreeView *treeview,
gpointer data)
{
+ gchar *labeltext;
struct val_labs_dialog *dialog = data;
struct val_lab * vl = get_selected_tuple(dialog);
@@ -290,8 +291,10 @@
g_signal_handler_block(GTK_ENTRY(dialog->label_entry),
dialog->change_handler_id);
+ labeltext = pspp_locale_to_utf8(vl->label, -1, 0);
gtk_entry_set_text(GTK_ENTRY(dialog->label_entry),
- vl->label);
+ labeltext);
+ g_free(labeltext);
g_signal_handler_unblock(GTK_ENTRY(dialog->label_entry),
dialog->change_handler_id);
@@ -412,21 +415,25 @@
vl;
vl = val_labs_next(dialog->labs, &vli))
{
+
gchar *const vstr =
value_to_text(vl->value,
*psppire_variable_get_write_spec(dialog->pv));
+ gchar *labeltext =
+ pspp_locale_to_utf8(vl->label, -1, 0);
-
gchar *const text = g_strdup_printf("%s = \"%s\"",
- vstr, vl->label);
-
+ vstr, labeltext);
+
+
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
0, text,
1, vl->value.f,
-1);
+ g_free(labeltext);
g_free(text);
g_free(vstr);
}
Index: pspp/src/ui/gui/var-sheet.c
diff -u pspp/src/ui/gui/var-sheet.c:1.5 pspp/src/ui/gui/var-sheet.c:1.6
--- pspp/src/ui/gui/var-sheet.c:1.5 Sat May 27 08:36:10 2006
+++ pspp/src/ui/gui/var-sheet.c Wed May 31 07:38:03 2006
@@ -98,14 +98,14 @@
-const gchar *alignments[]={
+const gchar *alignments[n_ALIGNMENTS + 1]={
N_("Left"),
N_("Right"),
N_("Centre"),
0
};
-const gchar *measures[]={
+const gchar *measures[n_MEASURES + 1]={
N_("Nominal"),
N_("Ordinal"),
N_("Scale"),
Index: pspp/src/ui/gui/var-sheet.h
diff -u pspp/src/ui/gui/var-sheet.h:1.2 pspp/src/ui/gui/var-sheet.h:1.3
--- pspp/src/ui/gui/var-sheet.h:1.2 Wed Mar 15 03:29:11 2006
+++ pspp/src/ui/gui/var-sheet.h Wed May 31 07:38:03 2006
@@ -50,10 +50,13 @@
gchar *string2,
gint int1, gint int2);
+#define n_ALIGNMENTS 3
-extern const gchar *alignments[];
+extern const gchar *alignments[n_ALIGNMENTS + 1];
-extern const gchar *measures[];
+#define n_MEASURES 3
+
+extern const gchar *measures[n_MEASURES + 1];
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/src data/format.c data/format.h data/sys-f...,
John Darrington <=