C++ PATCH to fix thinko

Manfred Hollstein manfred.h@gmx.net
Mon May 15 22:40:00 GMT 2000


On Mon, 15 May 2000, 21:25:03 +0200, gdr@codesourcery.com wrote:

   Zack Weinberg <zack@wolery.cumb.org> writes:
   
   | On Mon, May 15, 2000 at 08:44:50PM +0200, Gabriel Dos Reis wrote:
   | > Manfred Hollstein <manfred.h@gmx.net> writes:
   | > 
   | > | I believe, using constants as the length argument to strncmp
   | > | is error prone; I'd suggest to use this instead:
   | > | 
   | > |    else if (!strncmp (p, "diagnostics-show-location=",
   | > | 		      sizeof ("diagnostics-show-location=") - 1))
   | > 
   | > 100% agreed.
   | 
   | I like to go a bit farther:
   
   But then let's go much farther :-)
   
   How about 
   
   #define match(PTR, STRING) (!strncmp (PTR, STRING, sizeof (STRING) -1))
   
   used as:
   
     else if (match (p, "diagnostics-show-location="))
   
   ?

That's fine.

manfred
   
   -- Gaby
   CodeSourcery, LLC                             http://www.codesourcery.com
   



More information about the Gcc-patches mailing list