Re: [ft-devel] Re: meddlesome compiler warns against for( ...; ...;...) ;
On Wed, 15 Oct 2008 00:42:36 +0900 [EMAIL PROTECTED] wrote: Turner has post easier-to-eye fix, I will commit within 24 hours. Sorry for my lated action. The FreeType2 tree in my Macintosh is too messed to check an atomic test. http://lists.nongnu.org/archive/html/freetype-devel/2008-10/msg00030.html Just I've committed to CVS. Thank you everybody! Regards, mpsuzuki ___ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] Re: meddlesome compiler warns against for( ...; ...;...) ;
On 10/11/08 8:00 AM, Werner LEMBERG said: Yes, probably, which means we've just a formatting `error'. George? Er, the point of the loop is to test if coords is the same as blend-normalizedcoords. If the two arrays are the same then nothing has changed. I've reformatted it. Thanks to all. I didn't look how you formatted it, but note that in C++ (which I realize freetype is not written in) gcc 4.2 will warn for code like this: for (i = 0; i 10; i++); But it will not warn if you do: for (i = 0; i 10; i++) ; or for (i = 0; i 10; i++) {} Oddly, the warning only applies to C++ and not C. Just something to consider... -- Sean McBride, B. Eng [EMAIL PROTECTED] Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] Re: meddlesome compiler warns against for( ...; ...;...) ;
On Tue, 14 Oct 2008 10:59:24 -0400 Sean McBride [EMAIL PROTECTED] wrote: On 10/11/08 8:00 AM, Werner LEMBERG said: Yes, probably, which means we've just a formatting `error'. George? Er, the point of the loop is to test if coords is the same as blend-normalizedcoords. If the two arrays are the same then nothing has changed. I've reformatted it. Thanks to all. I didn't look how you formatted it, but note that in C++ (which I realize freetype is not written in) gcc 4.2 will warn for code like this: for (i = 0; i 10; i++); But it will not warn if you do: for (i = 0; i 10; i++) ; or for (i = 0; i 10; i++) {} Oddly, the warning only applies to C++ and not C. Just something to consider... Thank you for information. Turner has post easier-to-eye fix, I will commit within 24 hours. Sorry for my lated action. The FreeType2 tree in my Macintosh is too messed to check an atomic test. http://lists.nongnu.org/archive/html/freetype-devel/2008-10/msg00030.html Regards, mpsuzuki ___ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] Re: meddlesome compiler warns against for( ...; ...;...) ;
Yes, probably, which means we've just a formatting `error'. George? Er, the point of the loop is to test if coords is the same as blend-normalizedcoords. If the two arrays are the same then nothing has changed. I've reformatted it. Thanks to all. Werner ___ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] Re: meddlesome compiler warns against for( ...; ...;...) ;
I think, your comment proposes to remove the ; at the end of line 910. Um, yes, but it seems that I'm wrong. It looks like very strange. So, I guessed the original intention by the author was for ( i = 0; i num_coords blend-normalizedcoords[i] == coords[i]; ++i ) { } Yes, probably, which means we've just a formatting `error'. George? Er, the point of the loop is to test if coords is the same as blend-normalizedcoords. If the two arrays are the same then nothing has changed. So nothing should be done inside the loop. If you prefer using {} to represent a null statement, that's fine with me. I tend to use ; myself, but if freetype's conventions are different I apologize. ___ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel
RE: [ft-devel] Re: meddlesome compiler warns against for( ...; ...; ...) ;
However, the logic is correct, is it not? It looks as if the code is checking whether all of the items in the array fulfil a condition. So it should be fixed as originally suggested by mpsuzuki, without changing the logic, but preventing the warning. Graham -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Werner LEMBERG Sent: 09 October 2008 13:28 To: [EMAIL PROTECTED] Cc: freetype-devel@nongnu.org Subject: [ft-devel] Re: meddlesome compiler warns against for( ...; ...;...) ; During the play with legacy CodeWarrior and MPW, I found these legacy C compilers warn the coding style like for ( i = 0 ; i N ; i++ ) ; ... They guess ; is a mistake (by the author) and the procedure ... is expected (by the author) to be looped. Of course it's a mistake! Please fix it as you prefer. Werner ___ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel ___ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] Re: meddlesome compiler warns against for( ...; ...;...) ;
Dear Werner, I'm too stupid to close this issue, I'm quite sorry for keeping this thread. I don't have good sample font to test the logic is right /or not, so I want to be sure about the original intention of the author. Here I quote the current code in src/truetype/ttgxvar.c. 907 { 908for ( i = 0; 909 i num_coords blend-normalizedcoords[i] == coords[i]; 910 ++i ); 911 if ( i == num_coords ) 912manageCvt = mcvt_retain; 913 else 914manageCvt = mcvt_load; 915 916/* If we don't change the blend coords then we don't need to do */ 917/* anything to the cvt table. It will be correct. Otherwise we */ 918/* no longer have the original cvt (it was modified when we set */ 919/* the blend last time), so we must reload and then modify it. */ 920 } I think, your comment proposes to remove the ; at the end of line 910. It changes the current logic to another one. The changed logic would be: for ( i = 0; i num_coords blend-normalizedcoords[i] == coords[i]; ++i ) { if ( i == num_coords ) manageCvt = mcvt_retain; else manageCvt = mcvt_load; } But, if ( i == num_coords ) manageCvt = mcvt_retain; would not be executed, because the for loop already restricts i as i num_coords. Therefore, the executed procedure would be simplified aslike: for ( i = 0; i num_coords blend-normalizedcoords[i] == coords[i]; ++i ) { manageCvt = mcvt_load; } During the loop, manageCvt is not used at all, and, the variable i is not used in following part of the function, so, it would be further simplified aslike: manageCvt = mcvt_load; It looks like very strange. So, I guessed the original intention by the author was for ( i = 0; i num_coords blend-normalizedcoords[i] == coords[i]; ++i ) { } if ( i == num_coords ) manageCvt = mcvt_retain; else manageCvt = mcvt_load; Using { } instead of ; looks ugly, so I divided the looping restriction into giving max of i and coods[i] comparison, aslike: for ( i = 0; i num_coords; ++i ) if ( blend-normalizedcoords[i] != coords[i] ) break; if ( i == num_coords ) manageCvt = mcvt_retain; else manageCvt = mcvt_load; Werner, my proposal in above is right? Or, simple removing ; from the end of for loop is right? Regards, mpsuzuki On Thu, 09 Oct 2008 20:13:18 +0200 (CEST) Werner LEMBERG [EMAIL PROTECTED] wrote: However, the logic is correct, is it not? It looks as if the code is checking whether all of the items in the array fulfil a condition. So it should be fixed as originally suggested by mpsuzuki, without changing the logic, but preventing the warning. I mean that the `;' in the same line as the `for' command is a mistake. Sorry for being unclear. Werner ___ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel