hi Bruno,

Le 23 févr. 2012 à 21:00, Bruno Haible a écrit :

>> I use STRNCMP_LIT defined in coreutils/src/system.h:
>> 
>>    /* Just like strncmp, but the second argument must be a literal string
>>       and you don't specify the length.  */
>>    #define STRNCMP_LIT(s, literal) \
>>      strncmp (s, "" literal "", sizeof (literal) - 1)
> 
> This comment is not clear enough. If someone writes
>  STRNCMP_LIT (s, "foobar")
> will it return true for s = "foobarbaz"? Will it return true for s = "foo"?
> 
> How about reformulating the comment?
> 
>  /* STRNCMP_LIT(S, PREFIX) returns true if the string S starts with the
>     prefix string PREFIX.  PREFIX must be a literal string.  */

There is no '== 0' in STRNCMP_LIT, you probably refer to another
macro, say

  /* Whether Literal is a prefix of S.  */
  #define STRPREFIX_LIT(Literal, S)               \
    (STRNCMP_LIT (S, Literal) == 0)


Reply via email to