aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorRadek Doulik <rodo@ximian.com>2004-06-09 23:25:03 +0800
committerRadek Doulik <rodo@src.gnome.org>2004-06-09 23:25:03 +0800
commit1189f447ddb146e7dfee42ed623f8cb01ccdacba (patch)
tree313c81a183fd8e1e1c7528398b9352d40e300573 /widgets
parent964fb4ac7aaa2759eb9a0ed71f3b0aa8a8e16466 (diff)
downloadgsoc2013-evolution-1189f447ddb146e7dfee42ed623f8cb01ccdacba.tar
gsoc2013-evolution-1189f447ddb146e7dfee42ed623f8cb01ccdacba.tar.gz
gsoc2013-evolution-1189f447ddb146e7dfee42ed623f8cb01ccdacba.tar.bz2
gsoc2013-evolution-1189f447ddb146e7dfee42ed623f8cb01ccdacba.tar.lz
gsoc2013-evolution-1189f447ddb146e7dfee42ed623f8cb01ccdacba.tar.xz
gsoc2013-evolution-1189f447ddb146e7dfee42ed623f8cb01ccdacba.tar.zst
gsoc2013-evolution-1189f447ddb146e7dfee42ed623f8cb01ccdacba.zip
process only if len > 0
2004-06-09 Radek Doulik <rodo@ximian.com> * gal/e-text/e-text.c (capitalize): process only if len > 0 Fixes #51078 svn path=/trunk/; revision=26270
Diffstat (limited to 'widgets')
-rw-r--r--widgets/text/e-text.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index b9aeadf6bf..3c7ccad68b 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -3118,42 +3118,45 @@ capitalize (EText *text, int start, int end, ETextEventProcessorCaps type)
const char *p = g_utf8_offset_to_pointer (text->text, start);
const char *text_end = g_utf8_offset_to_pointer (text->text, end);
int utf8len = text_end - p;
- char *new_text = g_new0 (char, utf8len * 6);
- char *output = new_text;
- while (p && *p && p < text_end) {
- gunichar unival = g_utf8_get_char (p);
- gunichar newval = unival;
+ if (utf8len > 0) {
+ char *new_text = g_new0 (char, utf8len * 6);
+ char *output = new_text;
- switch (type) {
- case E_TEP_CAPS_UPPER:
- newval = g_unichar_toupper (unival);
- break;
- case E_TEP_CAPS_LOWER:
- newval = g_unichar_tolower (unival);
- break;
- case E_TEP_CAPS_TITLE:
- if (g_unichar_isalpha (unival)) {
- if (first)
- newval = g_unichar_totitle (unival);
- else
- newval = g_unichar_tolower (unival);
- first = FALSE;
- } else {
- first = TRUE;
+ while (p && *p && p < text_end) {
+ gunichar unival = g_utf8_get_char (p);
+ gunichar newval = unival;
+
+ switch (type) {
+ case E_TEP_CAPS_UPPER:
+ newval = g_unichar_toupper (unival);
+ break;
+ case E_TEP_CAPS_LOWER:
+ newval = g_unichar_tolower (unival);
+ break;
+ case E_TEP_CAPS_TITLE:
+ if (g_unichar_isalpha (unival)) {
+ if (first)
+ newval = g_unichar_totitle (unival);
+ else
+ newval = g_unichar_tolower (unival);
+ first = FALSE;
+ } else {
+ first = TRUE;
+ }
+ break;
}
- break;
+ g_unichar_to_utf8 (newval, output);
+ output = g_utf8_next_char (output);
+
+ p = g_utf8_next_char (p);
}
- g_unichar_to_utf8 (newval, output);
- output = g_utf8_next_char (output);
+ *output = 0;
- p = g_utf8_next_char (p);
+ e_text_model_delete (text->model, start, utf8len);
+ e_text_model_insert_length (text->model, start, new_text, utf8len);
+ g_free (new_text);
}
- *output = 0;
-
- e_text_model_delete (text->model, start, utf8len);
- e_text_model_insert_length (text->model, start, new_text, utf8len);
- g_free (new_text);
}
static void