<!DOCTYPE html><html dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><head><body><div><div><br><br><blockquote>---- Original Message ----<br>
From: "Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl><br>
To: shawnlandden@gmail.com<br>CC: systemd-devel@lists.freedesktop.org, "Shawn Landden" <shawn@churchofgit.com><br>
Sent: Tue, Sep 10, 2013, 08:59<br>
Subject: Re: [systemd-devel] [PATCH] util, utf8: recognize wide characters in wellipsize_mem()<br><br><br>Hi Shawn,<br>thank you for attacking this, and sorry for the long delay in answering.<br>I think that the approach of copying working code from elsewhere for this<br>is right, but I think it should go into its own file, so that two coding<br>styles are not mixed.</blockquote><blockquote></blockquote><span>The functions come from the same original source however (same two files in glib) so I think they should go together, perhaps the older</span><div><span>take functions should be transfered back to their original style? </span><br><blockquote><br>Also, can those new functions replace normal ellipsize and ellipsize_mem,<br>so that we have support everywhere?</blockquote><blockquote></blockquote><span>renamed old to ascii_* </span><br><blockquote><br>e = new0(char, new_length*4 < old_length ? new_length*4 : old_length);<br><br>→ we have a min macro<br><br></blockquote><span>fixed </span><br><blockquote>There are some compilation warnings:<br><br>../src/shared/utf8.c: In function 'unichar_iswide':<br>../src/shared/utf8.c:435:9: warning: passing argument 1 of 'bsearch' makes pointer from integer without a cast [enabled by default]<br>interval_compare))<br>^<br>In file included from ../src/shared/utf8.c:51:0:<br>/usr/include/stdlib.h:754:14: note: expected 'const void *' but argument is of type 'long int'<br>extern void *bsearch (const void *__key, const void *__base,<br><br></blockquote><span>fixed </span><br><blockquote>../src/shared/util.c: In function 'wellipsize_mem':<br>../src/shared/util.c:3353:9: warning: array subscript has type 'char' [-Wchar-subscripts]<br>for (i = (char *)s;k < x;i = utf8_next_char(i)) {<br>^<br>../src/shared/util.c:3380:17: warning: array subscript has type 'char' [-Wchar-subscripts]<br>i = utf8_next_char(i);<br>^</blockquote><blockquote></blockquote><span>not sure how to fix this,I am iterating over a pointer to char, but i am not evaluating it (it is a warning about signed vs unsigned char.) </span><br><blockquote><br>and valgrind finds some leaks:<br><br>% valgrind --leak-check=full build/.libs/test-wellipsize <br>==19953== <br>==19953== HEAP SUMMARY:<br>==19953== in use at exit: 1,379 bytes in 6 blocks<br>==19953== total heap usage: 6 allocs, 0 frees, 1,379 bytes allocated<br>==19953== <br>==19953== 81 bytes in 1 blocks are definitely lost in loss record 1 of 6<br>==19953== at 0x4A08121: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)<br>==19953== by 0x400F57: ellipsize_mem (util.c:3300)<br>==19953== by 0x401082: wellipsize_mem (util.c:3336)<br>==19953== by 0x40122A: wellipsize (util.c:3388)<br>==19953== by 0x400CFF: test_one (test-wellipsize.c:28)<br>==19953== by 0x400D4C: main (test-wellipsize.c:37)<br>...<br><br></blockquote>I think it was just my lazy test, which I fixed, but I am on ARM, so let me know if this persists on amd64<br><blockquote>On Wed, Aug 28, 2013 at 03:58:29PM -0700, Shawn wrote:<br><blockquote>here is the test runner I am using, doesn't really make sense to add this<br>to the tree as it has to be visually inspected</blockquote><br>I think it is still useful, since we don't have anything better for now. Anyway,<br>we have a bunch of tests which can only be run manually. Your test is certainly<br>good enough for valgrind testing and visual inspection, so it should go in.<br><br></blockquote><span>ok </span><br><blockquote>Zbyszek</blockquote></div></div></div></body></html>