[vlc-devel] Checking for __STDC_ISO_10646__ in Qt4 module
Juho Vähä-Herttua
juhovh at iki.fi
Wed Nov 3 21:36:50 CET 2010
Hi,
The code with slight portability issues in customwidgets.cpp is as follows:
if( qtk <= 0xff )
/* VLC and X11 use lowercase whereas Qt uses uppercase */
#if defined( __STDC_ISO_10646__ ) || defined( _WIN32 ) || defined( __APPLE__ )
i_vlck = towlower( qtk );
#else
# error FIXME
#endif
else
{
...
This means that towlower is only called for qtk values smaller or equal to 255. I wrote a small test to check for the functionality of towlower with these values:
#include <stdio.h>
#include <wctype.h>
#ifndef __STDC_ISO_10646__
#error FIXME
#endif
main(i,c) {
for (i=0; i<256; i++) {
c = (i >= 'A' && i <= 'Z') ? i+32 : i;
if (towlower(i) != c) printf("mismatch: %d\n", i);
}
}
The result of this test was that it compiled fine on a linux machine and didn't print any output. This means that only characters [A-Z] are changed to lower case by the standard compliant towlower function, even though with a quick look code points between 0xC0 and 0xDE (excluding 0x0xD7) should be changed as well.
To avoid any change in VLC functionality, I would therefore rewrite the original code as follows:
if( qtk <= 0xff )
/* VLC and X11 use lowercase whereas Qt uses uppercase */
i_vlck = (i >= 'A' && i <= 'Z') ? qtk+32 : qtk;
else
{
...
Any objections?
It feels funny now that I wasted hours debating about this issue just to find that only ASCII characters were affected in the first place.
Juho
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4258 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20101103/b1a01ece/attachment.bin>
More information about the vlc-devel
mailing list