Re: [Nautilus-list] PATCH: linefeed problem for librsvg



On Saturday, July 21, 2001, at 10:45  AM, Havoc Pennington wrote:

Darin Adler <darin bentspoon com> writes:
On Thursday, July 19, 2001, at 12:55  AM, Akira TAGOH wrote:
 	/* Alloc max length of wide char */
 	wcstr = g_new0 (wchar_t, length);
-	wclength = mbstowcs (wcstr, str, length);
+	tmpstr = g_strndup (str, length);
+	wclength = mbstowcs (wcstr, tmpstr, length);

Could you please explain why making a truncated copy of str (in
tmpstr) is helpful and necessary? I'd like to understand this fix
before I commit it.

IIRC the bug report was that text was "doubled" in the sidebar (so if
the text was supposed to be "foo" it was "foofoo" in multibyte
locales).  I haven't looked at the patch but maybe this helps figure
it out. Perhaps the doubling was just a random phenomenon and really
there was memory junk or something.

I see the problem now. The length passed in to mbstowcs limits the number of wide characters that are written out. It does not limit the number of bytes read from the source string. I can fix it with a smaller change than the suggested patch, and I will.

    -- Darin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]