Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/tclmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,29 @@ static int tcl_utimer STDVAR
Tcl_AppendResult(irp, x, NULL);
return TCL_OK;
}
static int tcl_timerexists STDVAR
{
BADARGS(2, 2, " timerName");

if (find_timer(timer, argv[1])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tcl_AppendResult() is deprecated. Use Tcl_SetResult() if you can. You could do a one-liner, something like:

Tcl_SetResult(interp, find_timer(timer, argv[1]) ? "1" : "0", TCL_STATIC);

Tcl_AppendResult(irp, "1", NULL);
} else {
Tcl_AppendResult(irp, "0", NULL);
}
return TCL_OK;
}

static int tcl_utimerexists STDVAR
{
BADARGS(2, 2, " utimerName");

if (find_timer(utimer, argv[1])) {
Tcl_AppendResult(irp, "1", NULL);
} else {
Tcl_AppendResult(irp, "0", NULL);
}
return TCL_OK;
}

static int tcl_killtimer STDVAR
{
Expand Down Expand Up @@ -822,6 +845,8 @@ tcl_cmds tclmisc_cmds[] = {
{"putloglev", tcl_putloglev},
{"timer", tcl_timer},
{"utimer", tcl_utimer},
{"timerexists", tcl_timerexists},
{"utimerexists", tcl_utimerexists},
{"killtimer", tcl_killtimer},
{"killutimer", tcl_killutimer},
{"timers", tcl_timers},
Expand Down
Loading