mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
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:
@@ -215,10 +215,9 @@ file_name_split (const char *file_name,
|
||||
if (*ext)
|
||||
{
|
||||
size_t baselen = *ext - *base;
|
||||
size_t dottablen = 4;
|
||||
size_t dottablen = sizeof (TAB_EXT) - 1;
|
||||
if (dottablen < baselen
|
||||
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|
||||
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
|
||||
&& STRPREFIX_LIT (TAB_EXT, *ext - dottablen))
|
||||
*tab = *ext - dottablen;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user