Hi Jim,
> That gnulib has two definitions is unfortunate, but I will not
> volunteer to change the STREQ that I've been using ;-)
> I don't see much value in streq.h, either, and hence, don't use it.
The value of streq.h is an optimized definition which is used in a few
places. I agree that your STREQ is more generally useful, especially to
avoid thinkos, therefore I wouldn't want to rename yours.
Akim suggests to rename STREQ in lib/streq.h; what name would you suggest?
> 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. */
And given this specification, STRNCMP_LIT is an odd name. How about
STR_HAS_PREFIX or STR_STARTS_WITH?
Bruno