From: Ben Pfaff Date: Wed, 21 Mar 2012 04:29:54 +0000 (-0700) Subject: psppire-dict: Return new var from psppire_dict_insert_variable(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=667d40a8359a4627b84a27cd46de5eaf0f509aba psppire-dict: Return new var from psppire_dict_insert_variable(). An upcoming commit will introduce a user for the return value. --- diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index 1e8beac5e3..04bd3e319c 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 53b09f41a7..4deabcaf8f 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 *,