Re: [Tuxpaint-devel] Is this warning harmless?
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
|
From: Bill K. <nb...@so...> - 2021-11-04 04:27:47
|
On Tue, Nov 02, 2021 at 09:44:39PM +0900, TOYAMA Shin-ichi wrote: > Hi, > > I think the reason for this warning is that the size of wchar_t is > 4 bytes on linux but 2 bytes on windows. > > I don't know what render_text_w() is doing, so I'm not sure if > this is the problem or not. > > For example, the text circled in red in onscreen_keyboard (see > attached) does not seem to be rendered on windows. > > Does this seem relevant ? Hrm, we have some clues about this in the code from John P. from way back in 2006: https://sourceforge.net/p/tuxpaint/tuxpaint/ci/304f49672/ Specifically, this part of the commit message: Modified the text gadget so that it correctly handles the 16-bit unicode characters that SDL sends. The text buffer is held internally as an array of wchar_t, and makes uses of various wide-character functions. It is converted back into 16-bit unicode characters to satisfy SDL_ttf. Tested on Windows and Linux. And it's this function: // This conversion is required on platforms where Uint16 doesn't match wchar_t. // On Windows, wchar_t is 16-bit, elsewhere it is 32-bit. // Mismatch caused by the use of Uint16 for unicode characters by SDL, SDL_ttf. // I guess wchar_t is really only suitable for internal use ... static Uint16 *wcstou16(const wchar_t *str) ... It is used in exactly one place, within render_text_w(): if (font->typ == FONT_TYPE_TTF) { ustr = wcstou16(str); ret = TTF_RenderUNICODE_Blended(font->ttf_font, ustr, color); free(ustr); } However, we're talking about the bit of code that constructs UTF-8 Unicode within Tux Paint, to deliver it to SDL_Pango. I think it might be worth replacing `wchar` with something like Uint32 for these purposes... I'm digging around the code right now. -bill! > > > TOYAMA Shin-ichi wrote in <617e94b2.5007%sh...@wm...> > >Hi, > > > >Recently, I've been dealing with a lot of bugs in the Windows > >version, and I've noticed that many clue of the bugs had been > >appeared in the compile-time warnings. > > > >So,I checked the warnings again, and the following warning, > >which does not appear when compiling on Linux, caught my > >attention. > > > >------------------------------------------------------------ > >src/tuxpaint.c: In function 'render_text_w': > >src/tuxpaint.c:1685:27: warning: comparison is always true due to limited range > >of data type [-Wtype-limits] > > 1685 | else if (str[i] <= 0x0000FFFF) > >------------------------------------------------------------ > > > >If this warning is correct, it means that the next conditional > >branch (0x00100000 - 001FFFFF) will never be reached. > > > >How can I confirm if it were a problem or not? > > > >Thanks! > > -- > TOYAMA Shin-ichi mailto:sh...@wm... > _______________________________________________ > Tuxpaint-devel mailing list > Tux...@li... > https://lists.sourceforge.net/lists/listinfo/tuxpaint-devel -- -bill! Sent from my computer |