pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp/src/ui/gui psppire-dict.c psppire-dict.h p...


From: John Darrington
Subject: [Pspp-cvs] pspp/src/ui/gui psppire-dict.c psppire-dict.h p...
Date: Fri, 26 Jan 2007 10:57:15 +0000

CVSROOT:        /sources/pspp
Module name:    pspp
Changes by:     John Darrington <jmd>   07/01/26 10:57:15

Modified files:
        src/ui/gui     : psppire-dict.c psppire-dict.h 
                         psppire-var-store.c 

Log message:
        Fixed bug which crashed gui if it attempted to enter invalid variable 
names.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-dict.c?cvsroot=pspp&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-dict.h?cvsroot=pspp&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-var-store.c?cvsroot=pspp&r1=1.21&r2=1.22

Patches:
Index: psppire-dict.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-dict.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- psppire-dict.c      26 Jan 2007 07:35:04 -0000      1.26
+++ psppire-dict.c      26 Jan 2007 10:57:15 -0000      1.27
@@ -343,13 +343,15 @@
 }
 
 
-void
+gboolean
 psppire_dict_set_name (PsppireDict* d, gint idx, const gchar *name)
 {
   struct variable *var;
   g_assert (d);
   g_assert (PSPPIRE_IS_DICT (d));
 
+  if ( ! var_is_valid_name (name, false))
+    return FALSE;
 
   if ( idx < dict_get_var_cnt (d->dict))
     {
@@ -362,6 +364,8 @@
       /* new variable */
       dict_create_var (d->dict, name, 0);
     }
+
+  return TRUE;
 }
 
 
@@ -735,11 +739,16 @@
 }
 
 
-void
+gboolean
 psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
-                        const gchar *text)
+                        const gchar *name)
 {
-  dict_rename_var (dict->dict, v, text);
+  if ( ! var_is_valid_name (name, false))
+    return FALSE;
+  
+  dict_rename_var (dict->dict, v, name);
+
+  return TRUE;
 }
 
 

Index: psppire-dict.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-dict.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- psppire-dict.h      26 Jan 2007 07:35:04 -0000      1.16
+++ psppire-dict.h      26 Jan 2007 10:57:15 -0000      1.17
@@ -67,7 +67,7 @@
 /* -- PsppireDict --- */
 GType          psppire_dict_get_type (void);
 PsppireDict*     psppire_dict_new_from_dict (struct dictionary *d);
-void           psppire_dict_set_name (PsppireDict* s, gint idx, const gchar 
*name);
+gboolean       psppire_dict_set_name (PsppireDict* s, gint idx, const gchar 
*name);
 void           psppire_dict_delete_var (PsppireDict *s, gint idx);
 
 /* Return the number of variables in the dictionary */
@@ -99,7 +99,7 @@
 
 gint psppire_dict_get_next_value_idx (const PsppireDict *dict);
 
-void psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
+gboolean psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
                              const gchar *text);
 
 void psppire_dict_replace_dictionary (PsppireDict *, struct dictionary *);

Index: psppire-var-store.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-var-store.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- psppire-var-store.c 28 Dec 2006 04:21:08 -0000      1.21
+++ psppire-var-store.c 26 Jan 2007 10:57:15 -0000      1.22
@@ -394,8 +394,7 @@
   switch (col)
     {
     case COL_NAME:
-      psppire_dict_rename_var (var_store->dict, pv, text);
-      return TRUE;
+      return psppire_dict_rename_var (var_store->dict, pv, text);
       break;
     case COL_COLUMNS:
       if ( ! text) return FALSE;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]