[gnumeric] GUI: Improve blank check for expression entry.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Improve blank check for expression entry.
- Date: Wed, 1 Jun 2011 15:06:45 +0000 (UTC)
commit 4371c59ed5e2b787f4565d0e62dbf9fdb9f36dd0
Author: Morten Welinder <terra gnome org>
Date: Wed Jun 1 11:06:12 2011 -0400
GUI: Improve blank check for expression entry.
src/widgets/ChangeLog | 6 ++++++
src/widgets/gnumeric-expr-entry.c | 19 +++++++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 6e8965f..1d0e798 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-01 Morten Welinder <terra gnome org>
+
+ * gnumeric-expr-entry.c (gnm_expr_entry_is_blank): Move code after
+ preconditions. Make blank-check unicode based and avoid memory
+ allocation.
+
2011-05-31 Andreas J. Guelzow <aguelzow pyrshep ca>
* gnumeric-expr-entry.c (gee_check_tooltip): don't show tooltips in
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 68d016a..3246769 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -2662,21 +2662,24 @@ gnm_expr_entry_is_cell_ref (GnmExprEntry *gee, Sheet *sheet,
gboolean
gnm_expr_entry_is_blank (GnmExprEntry *gee)
{
- GtkEntry *entry = gnm_expr_entry_get_entry (gee);
- char const *text = gtk_entry_get_text (entry);
- char *new_text;
- int len;
+ GtkEntry *entry;
+ char const *text;
g_return_val_if_fail (IS_GNM_EXPR_ENTRY (gee), FALSE);
+ entry = gnm_expr_entry_get_entry (gee);
+
+ text = gtk_entry_get_text (entry);
if (text == NULL)
return TRUE;
- new_text = g_strdup (text);
- len = strlen (g_strstrip(new_text));
- g_free (new_text);
+ while (*text) {
+ if (!g_unichar_isspace (g_utf8_get_char (text)))
+ return FALSE;
+ text = g_utf8_next_char (text);
+ }
- return (len == 0);
+ return TRUE;
}
char *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]