[gnumeric] Parser: don't make undefined names when the name is invalid.



commit c1fb36627bd36c79a7041b9eff77a07138bab227
Author: Morten Welinder <terra gnome org>
Date:   Wed Oct 27 09:04:07 2010 -0400

    Parser: don't make undefined names when the name is invalid.

 ChangeLog       |    8 ++++++++
 NEWS            |    1 +
 src/expr-name.c |   11 +++++++----
 src/parser.y    |    8 +++++++-
 4 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 61c78f3..a3ab213 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-10-27  Morten Welinder  <terra gnome org>
+
+	* src/parser.y (parser_simple_val_or_name): Check whether a name
+	is valid before defining it.  See bug #633140.
+
+	* src/expr-name.c (expr_name_validate): Improve check for clash
+	with boolean constants.  Also check untranslated.
+
 2010-10-20  Morten Welinder  <terra gnome org>
 
 	* src/gui-util.c (gnm_xml_get_widget): Elminate.  Change all
diff --git a/NEWS b/NEWS
index 1b1cd77..c61e29c 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ Morten:
 	* Fix crash related to broken xls.  [#632050]
 	* Fix print area problem from broken xls.
 	* Fix printing crash.  [#632439]
+	* Partially fix problem with undefined names.  [#633140]
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.11
diff --git a/src/expr-name.c b/src/expr-name.c
index b91760f..605e987 100644
--- a/src/expr-name.c
+++ b/src/expr-name.c
@@ -83,17 +83,20 @@ gboolean
 expr_name_validate (const char *name)
 {
 	const char *p;
+	GnmValue *v;
 
 	g_return_val_if_fail (name != NULL, FALSE);
 
 	if (name[0] == 0)
 		return FALSE;
 
-	/* What about other locales.  */
-	if (strcmp (name, go_locale_boolean_name (TRUE)) == 0 ||
-	    strcmp (name, go_locale_boolean_name (FALSE)) == 0)
+	v = value_new_from_string (VALUE_BOOLEAN, name, NULL, TRUE);
+	if (!v)
+		v = value_new_from_string (VALUE_BOOLEAN, name, NULL, FALSE);
+	if (v) {
+		value_release (v);
 		return FALSE;
-
+	}
 
 	/* Hmm...   Now what?  */
 	if (!g_unichar_isalpha (g_utf8_get_char (name)) &&
diff --git a/src/parser.y b/src/parser.y
index 4c7c811..35b33b2 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -511,12 +511,18 @@ parser_simple_val_or_name (GnmExpr *str_expr)
 				res = NULL;
 			} else if (state->flags & GNM_EXPR_PARSE_UNKNOWN_NAMES_ARE_STRINGS) {
 				res = gnm_expr_new_constant (value_new_string (str));
-			} else {
+			} else if (expr_name_validate (str)) {
 				GnmParsePos pp = *state->pos;
 				pp.sheet = NULL;
 				/* Create a place holder */
 				nexpr = expr_name_add (&pp, str, NULL, NULL, TRUE, NULL);
 				res = gnm_expr_new_name (nexpr, NULL, NULL);
+			} else {
+				report_err (state, g_error_new (1, PERR_UNKNOWN_NAME,
+								_("'%s' cannot be used as a name"),
+								str),
+					    state->ptr, 0);
+				res = NULL;
 			}
 		} else
 			res = gnm_expr_new_name (nexpr, NULL, NULL);



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