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>
* src/func.c (function_call_with_list): Fix handling of strings
......
......@@ -8,6 +8,7 @@ Morten:
* Fix TRIM for non-ASCII case with spaces at end.
* Fix TYPE crash. [#323128]
* Plug leak.
* Fix sheet quoting problem. [#323546]
--------------------------------------------------------------------------
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>
* 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,
case 'A':
return _("Area");
case 'B':
return _("Scalar or Blank");
return _("Scalar, Blank, or Error");
case 'E':
return _("Scalar or Error");
case 'S':
return _("Scalar");
case '?':
/* Missing values will be NULL. */
return _("Any");
default:
......@@ -1112,7 +1113,7 @@ function_call_with_list (FunctionEvalInfo *ei, GnmExprList *l,
}
} else {
if (iter_count < 0) {
g_warning ("Damn I though this was impossible");
g_warning ("Damn I thought this was impossible");
iter_count = 0;
}
iter_item = g_alloca (sizeof (int) * argc);
......@@ -1130,7 +1131,7 @@ function_call_with_list (FunctionEvalInfo *ei, GnmExprList *l,
case 'b':
if (tmp->type == VALUE_STRING) {
gboolean err;
gboolean b = value_get_as_bool (value_peek_string (tmp), &err);
gboolean b = value_get_as_bool (tmp, &err);
if (err) {
free_values (args, i + 1);
return value_new_error_VALUE (ei->pos);
......
......@@ -849,10 +849,47 @@ sheetref_parse (char const *start, Sheet **sheet, Workbook const *wb,
return start;
}
} else {
for (end = start;
g_unichar_isalnum (g_utf8_get_char (end));
end = g_utf8_next_char (end))
; /* Nothing */
gboolean only_digits = TRUE;
end = start;
/*
* 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 != ':'))
return start;
......
......@@ -3360,36 +3360,31 @@ sheet_clear_region (Sheet *sheet,
GString *
sheet_name_quote (char const *name_unquoted)
{
char const *ptr;
int quotes_embedded = 0;
gboolean needs_quotes;
GString *res;
gboolean have_quotes = FALSE;
g_return_val_if_fail (name_unquoted != NULL, NULL);
g_return_val_if_fail (name_unquoted[0] != 0, NULL);
/* count number of embedded quotes and see if we need to quote */
needs_quotes = !g_unichar_isalpha (g_utf8_get_char (name_unquoted));
for (ptr = name_unquoted; *ptr; ptr = g_utf8_next_char (ptr)) {
gunichar c = g_utf8_get_char (ptr);
if (!g_unichar_isalnum (c))
needs_quotes = TRUE;
if (c == '\'' || c == '\\')
quotes_embedded++;
}
res = g_string_sized_new (20);
while (*name_unquoted) {
gunichar uc = g_utf8_get_char (name_unquoted);
name_unquoted = g_utf8_next_char (name_unquoted);
if (needs_quotes) {
GString *res = g_string_sized_new ((ptr - name_unquoted) + quotes_embedded + 3);
g_string_append_c (res, '\'');
for (ptr = name_unquoted; *ptr; ptr = g_utf8_next_char (ptr)) {
gunichar c = g_utf8_get_char (ptr);
if (c == '\'' || c == '\\')
if (!have_quotes &&
!g_unichar_isalnum (uc) &&
(uc != '.' || res->len == 0)) {
g_string_prepend_c (res, '\'');
have_quotes = TRUE;
}
if (uc == '\'' || uc == '\\')
g_string_append_c (res, '\\');
g_string_append_unichar (res, c);
g_string_append_unichar (res, uc);
}
if (have_quotes)
g_string_append_c (res, '\'');
return res;
} else
return g_string_new_len (name_unquoted, (ptr - name_unquoted));
}
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