[gnumeric] Avoid warnings when defining names.



commit b2e56a90c9521940303f0e539f7e3084158da831
Author: Morten Welinder <terra gnome org>
Date:   Thu Apr 23 19:15:36 2009 -0400

    Avoid warnings when defining names.
---
 ChangeLog                         |    3 +++
 src/commands.c                    |   10 ++++++----
 src/dialogs/dialog-define-names.c |    2 +-
 src/expr-name.c                   |    5 ++---
 src/expr-name.h                   |    2 +-
 5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f6ba8fc..ee38a85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-04-23  Morten Welinder  <terra gnome org>
 
+	* src/expr-name.c (expr_name_validate): Take sheet argument for
+	checks.  All callers changed.
+
 	* src/sheet.c (gnm_sheet_resize_main): Resize styles too.
 	(gnm_sheet_constructor): Check row count sanity here.
 
diff --git a/src/commands.c b/src/commands.c
index ea8bfec..b00e08e 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -5801,14 +5801,16 @@ cmd_define_name (WorkbookControl *wbc, char const *name,
 		 GnmParsePos const *pp, GnmExprTop const *texpr,
 		 char const *descriptor)
 {
-	CmdDefineName	*me;
-	GnmNamedExpr    *nexpr;
+	CmdDefineName *me;
+	GnmNamedExpr *nexpr;
+	Sheet *sheet;
 
 	g_return_val_if_fail (name != NULL, TRUE);
 	g_return_val_if_fail (pp != NULL, TRUE);
 	g_return_val_if_fail (texpr != NULL, TRUE);
 
-	if (!expr_name_validate (name)) {
+	sheet = wb_control_cur_sheet (wbc);
+	if (!expr_name_validate (name, sheet)) {
 		go_cmd_context_error_invalid (GO_CMD_CONTEXT (wbc), name,
 					_("is not allowed as defined name"));
 		gnm_expr_top_unref (texpr);
@@ -5833,7 +5835,7 @@ cmd_define_name (WorkbookControl *wbc, char const *name,
 	me->pp = *pp;
 	me->texpr = texpr;
 
-	me->cmd.sheet = wb_control_cur_sheet (wbc);
+	me->cmd.sheet = sheet;
 	me->cmd.size = 1;
 
 	if (descriptor == NULL) {
diff --git a/src/dialogs/dialog-define-names.c b/src/dialogs/dialog-define-names.c
index 6f9ca4d..531be90 100644
--- a/src/dialogs/dialog-define-names.c
+++ b/src/dialogs/dialog-define-names.c
@@ -394,7 +394,7 @@ name_guru_add (NameGuruState *state)
 		return TRUE;
 	}
 
-	if (!expr_name_validate (name)) {
+	if (!expr_name_validate (name, state->sheet)) {
 		go_gtk_notice_dialog (GTK_WINDOW (state->dialog),
 				      GTK_MESSAGE_ERROR,
 				      _("Invalid name"));
diff --git a/src/expr-name.c b/src/expr-name.c
index 2c807ce..44b4b67 100644
--- a/src/expr-name.c
+++ b/src/expr-name.c
@@ -36,7 +36,7 @@
  * returns TRUE if the given name is valid, FALSE otherwise.
  */
 gboolean
-expr_name_validate (const char *name)
+expr_name_validate (const char *name, Sheet *sheet)
 {
 	GnmCellPos cp;
 	const char *p;
@@ -52,8 +52,7 @@ expr_name_validate (const char *name)
 		return FALSE;
 
 	/* What about R1C1?  */
-#warning "We cannot use NULL here"
-	if (cellpos_parse (name, NULL, &cp, TRUE))
+	if (cellpos_parse (name, sheet, &cp, TRUE))
 		return FALSE;
 
 	/* Hmm...   Now what?  */
diff --git a/src/expr-name.h b/src/expr-name.h
index 151e623..ffec6e6 100644
--- a/src/expr-name.h
+++ b/src/expr-name.h
@@ -23,7 +23,7 @@ struct _GnmNamedExpr {
 	gboolean    is_editable;
 };
 
-gboolean expr_name_validate (const char *name);
+gboolean expr_name_validate (const char *name, Sheet *sheet);
 
 GnmNamedExpr *expr_name_lookup (GnmParsePos const *pos, char const *name);
 GnmNamedExpr *expr_name_add    (GnmParsePos const *pp, char const *name,



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