Introduce strbegins() macro and replace all open-coded instances
This test is done quite a bit across the tree, and the open-coded variants make it easy to have an accidental mismatch between the length of the prefix being tested and the length actually passed to strncmp(). This fixes an issue of that type comparing the server version against the prefix "u2.10", where the old code used an incorrect length of 4.
This commit is contained in:
@@ -1615,7 +1615,7 @@ char s[80];
|
||||
int tcl_killtimer STDVAR
|
||||
{
|
||||
BADARGS(2,2," timerID");
|
||||
if (strncmp(argv[1],"timer",5)!=0)
|
||||
if (!strbegins(argv[1],"timer"))
|
||||
{
|
||||
Tcl_AppendResult(irp,"argument is not a timerID",NULL);
|
||||
return TCL_ERROR;
|
||||
@@ -1629,7 +1629,7 @@ int tcl_killtimer STDVAR
|
||||
int tcl_killutimer STDVAR
|
||||
{
|
||||
BADARGS(2,2," timerID");
|
||||
if (strncmp(argv[1],"timer",5)!=0)
|
||||
if (!strbegins(argv[1],"timer"))
|
||||
{
|
||||
Tcl_AppendResult(irp,"argument is not a timerID",NULL);
|
||||
return TCL_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user