Re: [evolution-patches] Fix for bug#306986 [gtkhtml]
- From: Tor Lillqvist <tml novell com>
- To: evolution-patches gnome org
- Subject: Re: [evolution-patches] Fix for bug#306986 [gtkhtml]
- Date: Wed, 21 Dec 2005 09:13:37 +0000
on 2005-12-21 klockan 10:49 +0530 skrev Rohini:
> +
> + /* remove ' at both ends of word*/
> + if (text->str[0] == '\'' && text->str[text->len - 1] == '\'') {
> + text->str[0]=text->str[text->len-1]=' ';
> + text->str=g_strchomp (text->str);
> + text->str=g_strchug (text->str);
> + text->len-=2;
> + }
I don't understand why you are so keen on using g_strchomp() and
g_strchug() here. It seems so totally artificial to explicitly change
the quotes to spaces just so that g_strchomp() and g_strchug() will then
remove the spaces. Also, as g_strchomp() and g_strchug() modify the
string passed to them, assigning their return value (which is the same
as their argument) is unnecessary and might trick the reader into
thinking they return a newly allocated string (and then wondering what
happens to the old one).
Anyway, as text is a GString, why not use GString API to remove the
quote characters instead of poking inside the GString?
if (text->str[0] == '\'' && text->str[text->len - 1] == '\'') {
g_string_erase (text, 0, 1);
g_string_erase (text, text->len - 1, 1);
}
(not tested, there might be some braino in the above code)
--tml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]