On 05.07.2012 16:47, Nikita Egorov wrote:
> Hi all!
> Several months ago I opened STR 2726 (Debug assertion failed window in 
> fluid). The problem was in sign extension of character before calling 
> isspace().
> - if (!nostrip) while (isspace(*n)) n++;
>
> MSDN tells: "When used with a debug CRT library, isspace will display a CRT 
> assert if passed a parameter that is not EOF or in the range of 0 through 
> 0xFF".
>
>   Thus in order to avoid this assertion (in case of symbols within 128..255) 
> we have to cast char to unsigned char or mask low eight bits of int value. 
> Matthias did the job and fluid worked fine.
> - if (!nostrip) while (isspace((unsigned char)*n)) n++;
>
>   But last week I updated my FLTK and found out that in April Fabien changed 
> it back (via cast to int), commited and this STR marked as closed.
> - if (!nostrip) while (isspace((int) *n)) n++;
>
>   Of course, at the moment the debug assert window appears again. I wrote my 
> thoughts to Fabien, but I had no answer.
>
> Guys, is there someone who can reopen the STR and restore right behavior of 
> fluid? Or explain why it is impossible to do? It is not very important bug, 
> but annoying one.

I reopened the STR and fixed the issue (hopefully) in svn r 9635 by
using *both* casts, just in case a pickier compiler might "want" an
int cast.

> PS. For instance, Scott Meyers in his book Effective STL (Item 35) uses the 
> same method - casting symbol to unsigned char before calling some character 
> function.
> - int Ic1 = tolower(static_cast<unsigned char>(c1));

I think that this should be okay, and the cast to int should be
done implicitly, but as said above, just in case...

Please confirm in the STR form if this solves the issue.
http://www.fltk.org/str.php?L2726

-- 

Albrecht


_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to