Skip to content

Commit

Permalink
add tcl_fn to support tcl("tcl command")
Browse files Browse the repository at this point in the history
  • Loading branch information
noyesno committed Dec 16, 2015
1 parent e7ef6d8 commit 68abc7e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions elm-lib/awkatk/awkatk.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,37 @@ tk_fn( a_VARARG *va )
return ret;
}

/*
*----------------------------------------------------------------------
* tcl_fn --
*----------------------------------------------------------------------
*/
a_VAR *
tcl_fn( a_VARARG *va )
{
a_VAR *ret = awka_getstringvar(FALSE);

if (!interp)
_tk_init();

if (!va->used)
{
awka_setd(ret) = AWKATK_TOOFEWARGS;
return ret;
}
if (va->var[0]->type == a_VARNUL || va->var[0]->type == a_VARDBL)
{
awka_setd(ret) = AWKATK_ARGNOTSTRING;
return ret;
}

if (Tcl_Eval(interp, awka_gets(va->var[0])) != TCL_OK)
awka_error("Call to tk(%s) failed\n",va->var[0]->ptr);

awka_strcpy(ret, Tcl_GetStringResult(interp));
return ret;
}

/*
*----------------------------------------------------------------------
*
Expand Down

0 comments on commit 68abc7e

Please sign in to comment.