pspp-dev
[Top][All Lists]
Advanced

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

[PATCH 10/11] psppire-dict: Return new var from psppire_dict_insert_vari


From: Ben Pfaff
Subject: [PATCH 10/11] psppire-dict: Return new var from psppire_dict_insert_variable().
Date: Sun, 15 Apr 2012 16:58:32 -0700

An upcoming commit will introduce a user for the return value.
---
 src/ui/gui/psppire-dict.c |   19 +++++++++++--------
 src/ui/gui/psppire-dict.h |    3 ++-
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c
index 1e8beac..04bd3e3 100644
--- a/src/ui/gui/psppire-dict.c
+++ b/src/ui/gui/psppire-dict.c
@@ -379,23 +379,24 @@ psppire_dict_generate_name (const PsppireDict *dict, char 
*name, size_t size)
   return name;
 }
 
-/* Insert a new variable at posn IDX, with the name NAME.
+/* Insert a new variable at posn IDX, with the name NAME, and return the
+   new variable.
    If NAME is null, then a name will be automatically assigned.
 */
-void
+struct variable *
 psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar *name)
 {
-  struct variable *var ;
+  struct variable *var;
   char tmpname[64];
 
-  g_return_if_fail (idx >= 0);
-  g_return_if_fail (d);
-  g_return_if_fail (PSPPIRE_IS_DICT (d));
+  g_return_val_if_fail (idx >= 0, NULL);
+  g_return_val_if_fail (d, NULL);
+  g_return_val_if_fail (PSPPIRE_IS_DICT (d), NULL);
 
-  if ( ! name )
+  if (name == NULL)
     {
       if (!psppire_dict_generate_name (d, tmpname, sizeof tmpname))
-        g_return_if_reached ();
+        g_return_val_if_reached (NULL);
 
       name = tmpname;
     }
@@ -409,6 +410,8 @@ psppire_dict_insert_variable (PsppireDict *d, gint idx, 
const gchar *name)
   d->disable_insert_signal = FALSE;
 
   g_signal_emit (d, signals[VARIABLE_INSERTED], 0, idx);
+
+  return var;
 }
 
 /* Delete N variables beginning at FIRST */
diff --git a/src/ui/gui/psppire-dict.h b/src/ui/gui/psppire-dict.h
index 53b09f4..4deabca 100644
--- a/src/ui/gui/psppire-dict.h
+++ b/src/ui/gui/psppire-dict.h
@@ -90,7 +90,8 @@ struct variable * psppire_dict_get_variable (const 
PsppireDict *d, gint idx);
 void psppire_dict_delete_variables (PsppireDict *d, gint first, gint n);
 
 /* Insert a new variable at posn IDX */
-void psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar 
*name);
+struct variable *psppire_dict_insert_variable (PsppireDict *d, gint idx,
+                                               const gchar *name);
 
 void psppire_dict_resize_variable (PsppireDict *,
                                  const struct variable *,
-- 
1.7.2.5




reply via email to

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