Fix currency display in locale with non utf8 charset

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Fix currency display in locale with non utf8 charset

Didier Vidal
This should fix one of the problems that Neil reported in en_GB locale.
Do you see other pango-related problems, Neil ?

Didier.

_______________________________________________
gnucash-patches mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-patches

currency-utf8.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fix currency display in locale with non utf8 charset

Neil Williams-2
On Wednesday 19 October 2005 10:42 pm, Didier Vidal wrote:
> This should fix one of the problems that Neil reported in en_GB locale.
> Do you see other pango-related problems, Neil ?

Not with this patch. I get no pango errors and there's no need to fiddle with
LANG or other environment settings.

The currency symbols and number displays work as expected - thanks, Didier, it
looks like that his fixed the pango problems.

I'll commit the patch later.

--

Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/


_______________________________________________
gnucash-patches mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-patches

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fix currency display in locale with non utf8 charset

Christian Stimming
In reply to this post by Didier Vidal
Hi,

Didier Vidal schrieb:
> This should fix one of the problems that Neil reported in en_GB locale.
> Do you see other pango-related problems, Neil ?

it's great that this fixes the pango problems. However --

>    if ((value == NULL) || (value[0] == 0))
>      *p_value = default_value;
>  
> +  *p_value = g_locale_to_utf8 (*p_value, -1, NULL, NULL, NULL);
> +  // FIXME: Do we really need to make a copy here ?
>    *p_value = g_strdup (*p_value);
>  }

-- IMHO the g_strdup shouldn't be used here, because g_locale_to_utf8
returns a "gchar*" which IMHO means that this is an already newly
allocated string. Unfortunately the documentation of g_locale_to_utf8
doesn't clearly say this, but since it isn't a "const gchar*" I could
only guess that the returned string is already newly allocated. So the
g_strdup line should simply be removed.

Christian
_______________________________________________
gnucash-patches mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-patches
Reply | Threaded
Open this post in threaded view
|

Re: Fix currency display in locale with non utf8 charset

Didier Vidal
I was not sure about the copy, especially if the string is already utf8
before we call g_locale_to_utf8. I prefered to risk a small leak than a
crash.
But if someone knows what happens behind the cover, he could remove the
strdup...


Didier.


Le jeu 20/10/2005 à 11:19, Christian Stimming a écrit :

> Hi,
>
> Didier Vidal schrieb:
> > This should fix one of the problems that Neil reported in en_GB locale.
> > Do you see other pango-related problems, Neil ?
>
> it's great that this fixes the pango problems. However --
>
> >    if ((value == NULL) || (value[0] == 0))
> >      *p_value = default_value;
> >  
> > +  *p_value = g_locale_to_utf8 (*p_value, -1, NULL, NULL, NULL);
> > +  // FIXME: Do we really need to make a copy here ?
> >    *p_value = g_strdup (*p_value);
> >  }
>
> -- IMHO the g_strdup shouldn't be used here, because g_locale_to_utf8
> returns a "gchar*" which IMHO means that this is an already newly
> allocated string. Unfortunately the documentation of g_locale_to_utf8
> doesn't clearly say this, but since it isn't a "const gchar*" I could
> only guess that the returned string is already newly allocated. So the
> g_strdup line should simply be removed.
>
> Christian
> _______________________________________________
> gnucash-patches mailing list
> [hidden email]
> https://lists.gnucash.org/mailman/listinfo/gnucash-patches

_______________________________________________
gnucash-patches mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-patches
Reply | Threaded
Open this post in threaded view
|

Re: Fix currency display in locale with non utf8 charset

David Hampton-2
On Thu, 2005-10-20 at 13:14 +0200, Didier Vidal wrote:
> I was not sure about the copy, especially if the string is already utf8
> before we call g_locale_to_utf8. I prefered to risk a small leak than a
> crash.
> But if someone knows what happens behind the cover, he could remove the
> strdup...

Internally g_locale_to_utf8() calls either strdup_len() or g_convert().
Each of these functions is defined to return a newly allocated string,
or NULL.  The call to strdup should be removed.

David


_______________________________________________
gnucash-patches mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-patches
Reply | Threaded
Open this post in threaded view
|

Re: Fix currency display in locale with non utf8 charset

Neil Williams-2
On Thursday 20 October 2005 8:44 pm, David Hampton wrote:
> Internally g_locale_to_utf8() calls either strdup_len() or g_convert().
> Each of these functions is defined to return a newly allocated string,
> or NULL.  The call to strdup should be removed.

Thanks for that, David. It's commented out at the moment in CVS. I'll remove
the comment in due course.

--

Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/


_______________________________________________
gnucash-patches mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-patches

attachment0 (196 bytes) Download Attachment