Commit 8d7523b9 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Note, that 'B' accepts errors too. (function_call_with_list): Fix last

2005-12-08  Morten Welinder  <terra@gnome.org>

	* src/func.c (function_def_get_arg_type_string): Note, that 'B'
	accepts errors too.
	(function_call_with_list): Fix last fix.

	* src/parse-util.c (sheetref_parse): Handle sheet names starting
	with digits.

	* src/sheet.c (sheet_name_quote): Simplify and handle non-initial
	dot.
parent b73a2de3
2005-12-08 Morten Welinder <terra@gnome.org>
* src/func.c (function_def_get_arg_type_string): Note, that 'B'
accepts errors too.
(function_call_with_list): Fix last fix.
* src/parse-util.c (sheetref_parse): Handle sheet names starting
with digits.
* src/sheet.c (sheet_name_quote): Simplify and handle non-initial
dot.
2005-11-30 Morten Welinder <terra@gnome.org> 2005-11-30 Morten Welinder <terra@gnome.org>
* src/func.c (function_call_with_list): Fix handling of strings * src/func.c (function_call_with_list): Fix handling of strings
......
...@@ -8,6 +8,7 @@ Morten: ...@@ -8,6 +8,7 @@ Morten:
* Fix TRIM for non-ASCII case with spaces at end. * Fix TRIM for non-ASCII case with spaces at end.
* Fix TYPE crash. [#323128] * Fix TYPE crash. [#323128]
* Plug leak. * Plug leak.
* Fix sheet quoting problem. [#323546]
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Gnumeric 1.6.1 Gnumeric 1.6.1
......
2005-12-08 Morten Welinder <terra@gnome.org>
* src/func.c (function_def_get_arg_type_string): Note, that 'B'
accepts errors too.
(function_call_with_list): Fix last fix.
* src/parse-util.c (sheetref_parse): Handle sheet names starting
with digits.
* src/sheet.c (sheet_name_quote): Simplify and handle non-initial
dot.
2005-11-30 Morten Welinder <terra@gnome.org> 2005-11-30 Morten Welinder <terra@gnome.org>
* src/func.c (function_call_with_list): Fix handling of strings * src/func.c (function_call_with_list): Fix handling of strings
......
...@@ -939,12 +939,13 @@ function_def_get_arg_type_string (GnmFunc const *fn_def, ...@@ -939,12 +939,13 @@ function_def_get_arg_type_string (GnmFunc const *fn_def,
case 'A': case 'A':
return _("Area"); return _("Area");
case 'B': case 'B':
return _("Scalar or Blank"); return _("Scalar, Blank, or Error");
case 'E': case 'E':
return _("Scalar or Error"); return _("Scalar or Error");
case 'S': case 'S':
return _("Scalar"); return _("Scalar");
case '?': case '?':
/* Missing values will be NULL. */
return _("Any"); return _("Any");
default: default:
...@@ -1112,7 +1113,7 @@ function_call_with_list (FunctionEvalInfo *ei, GnmExprList *l, ...@@ -1112,7 +1113,7 @@ function_call_with_list (FunctionEvalInfo *ei, GnmExprList *l,
} }
} else { } else {
if (iter_count < 0) { if (iter_count < 0) {
g_warning ("Damn I though this was impossible"); g_warning ("Damn I thought this was impossible");
iter_count = 0; iter_count = 0;
} }
iter_item = g_alloca (sizeof (int) * argc); iter_item = g_alloca (sizeof (int) * argc);
...@@ -1130,7 +1131,7 @@ function_call_with_list (FunctionEvalInfo *ei, GnmExprList *l, ...@@ -1130,7 +1131,7 @@ function_call_with_list (FunctionEvalInfo *ei, GnmExprList *l,
case 'b': case 'b':
if (tmp->type == VALUE_STRING) { if (tmp->type == VALUE_STRING) {
gboolean err; gboolean err;
gboolean b = value_get_as_bool (value_peek_string (tmp), &err); gboolean b = value_get_as_bool (tmp, &err);
if (err) { if (err) {
free_values (args, i + 1); free_values (args, i + 1);
return value_new_error_VALUE (ei->pos); return value_new_error_VALUE (ei->pos);
......
...@@ -849,10 +849,47 @@ sheetref_parse (char const *start, Sheet **sheet, Workbook const *wb, ...@@ -849,10 +849,47 @@ sheetref_parse (char const *start, Sheet **sheet, Workbook const *wb,
return start; return start;
} }
} else { } else {
for (end = start; gboolean only_digits = TRUE;
g_unichar_isalnum (g_utf8_get_char (end)); end = start;
end = g_utf8_next_char (end))
; /* Nothing */ /*
* Valid: Normal!a1
* Valid: x.y!a1
* Invalid: .y!a1
*
* Some names starting with digits are actually valid, but
* unparse quoted. Things are quite tricky: most sheet names
* starting with a digit are ok, but not those starting with
* "[0-9]*\." or "[0-9]+[eE]".
*
* Valid: 42!a1
* Valid: 4x!a1
* Invalid: 1.!a1
* Invalid: 1e!a1
*/
while (1) {
gunichar uc = g_utf8_get_char (end);
if (g_unichar_isalpha (uc)) {
if (only_digits && end != start &&
(uc == 'e' || uc == 'E')) {
end = start;
break;
}
only_digits = FALSE;
end = g_utf8_next_char (end);
} else if (g_unichar_isdigit (uc)) {
end = g_utf8_next_char (end);
} else if (uc == '.') {
/* Valid, except after only digits. */
if (only_digits) {
end = start;
break;
}
end++;
} else
break;
}
if (*end != '!' && (!allow_3d || *end != ':')) if (*end != '!' && (!allow_3d || *end != ':'))
return start; return start;
......
...@@ -3360,36 +3360,31 @@ sheet_clear_region (Sheet *sheet, ...@@ -3360,36 +3360,31 @@ sheet_clear_region (Sheet *sheet,
GString * GString *
sheet_name_quote (char const *name_unquoted) sheet_name_quote (char const *name_unquoted)
{ {
char const *ptr; GString *res;
int quotes_embedded = 0; gboolean have_quotes = FALSE;
gboolean needs_quotes;
g_return_val_if_fail (name_unquoted != NULL, NULL); g_return_val_if_fail (name_unquoted != NULL, NULL);
g_return_val_if_fail (name_unquoted[0] != 0, NULL); g_return_val_if_fail (name_unquoted[0] != 0, NULL);
/* count number of embedded quotes and see if we need to quote */ res = g_string_sized_new (20);
needs_quotes = !g_unichar_isalpha (g_utf8_get_char (name_unquoted)); while (*name_unquoted) {
for (ptr = name_unquoted; *ptr; ptr = g_utf8_next_char (ptr)) { gunichar uc = g_utf8_get_char (name_unquoted);
gunichar c = g_utf8_get_char (ptr); name_unquoted = g_utf8_next_char (name_unquoted);
if (!g_unichar_isalnum (c))
needs_quotes = TRUE;
if (c == '\'' || c == '\\')
quotes_embedded++;
}
if (needs_quotes) { if (!have_quotes &&
GString *res = g_string_sized_new ((ptr - name_unquoted) + quotes_embedded + 3); !g_unichar_isalnum (uc) &&
g_string_append_c (res, '\''); (uc != '.' || res->len == 0)) {
for (ptr = name_unquoted; *ptr; ptr = g_utf8_next_char (ptr)) { g_string_prepend_c (res, '\'');
gunichar c = g_utf8_get_char (ptr); have_quotes = TRUE;
if (c == '\'' || c == '\\')
g_string_append_c (res, '\\');
g_string_append_unichar (res, c);
} }
if (uc == '\'' || uc == '\\')
g_string_append_c (res, '\\');
g_string_append_unichar (res, uc);
}
if (have_quotes)
g_string_append_c (res, '\''); g_string_append_c (res, '\'');
return res;
} else return res;
return g_string_new_len (name_unquoted, (ptr - name_unquoted));
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment