avoid direct strncmp calls.

Before this change, bison would accept either .tab and _tab equivalently,
whatever the current platform.  Besides, it was not obeying everywhere
to the possible definition of TAB_EXT to something else than .tab.

For consistency, handle only TAB_EXT (".tab" on non DJGPP platforms).
Support for "_tab" is neither documented, nor tested.

	* src/system.h (STRNCMP_LIT): New.
	From Jim Meyering.
	(STRPREFIX_LIT): New.
	* src/files.c, src/getargs.c: Use it.
This commit is contained in:
Akim Demaille
2012-02-23 20:14:42 +01:00
parent 2a55930762
commit 4663cb4d0c
3 changed files with 12 additions and 4 deletions

View File

@@ -102,7 +102,7 @@ flags_argmatch (const char *option,
args = strtok (args, ",");
while (args)
{
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
int no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
int value = XARGMATCH (option, args + no, keys, values);
if (value == 0)
{