[RFC PATCH 05/28] cli: lil: Rename some functions to be more like TCL

Sean Anderson
2021-07-01T06:17:22Z

Several functions have different names than they do in TCL. To make things
easier for those familiar with TCL, rename them to their TCL equivalents.
At the moment, this is only done for functions not used by LIL_FULL. Some
functions need more substantive work to conform them to TCL. For example,
in TCL, there is a `string` function with a subcommand of `compare`, which
is the same as the top-level function `compare`. Several functions also
have no TCL equivalent. Do we need these?

TODO: do this for all functions

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

common/cli_lil.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/common/cli_lil.c b/common/cli_lil.c
index a2e5cdf35a..a6c77ee19c 100644
--- a/common/cli_lil.c
+++ b/common/cli_lil.c
@@ -1829,10 +1829,10 @@ static struct lil_value *fnc_reflect(struct lil *lil, size_t argc,
return lil_clone_value(func->code);
}

- if (!strcmp(type, "func-count"))
+ if (!strcmp(type, "proc-count"))
return lil_alloc_integer(lil->cmds);

- if (!strcmp(type, "funcs")) {
+ if (!strcmp(type, "procs")) {
struct lil_list *funcs = lil_alloc_list();

for (i = 0; i < lil->cmds; i++)
@@ -1878,7 +1878,7 @@ static struct lil_value *fnc_reflect(struct lil *lil, size_t argc,
return r;
}

- if (!strcmp(type, "has-func")) {
+ if (!strcmp(type, "has-proc")) {
const char *target;

if (argc == 1)
@@ -1948,7 +1948,7 @@ static struct lil_value *fnc_reflect(struct lil *lil, size_t argc,
return NULL;
}

-static struct lil_value *fnc_func(struct lil *lil, size_t argc,
+static struct lil_value *fnc_proc(struct lil *lil, size_t argc,
struct lil_value **argv)
{
struct lil_value *name;
@@ -2472,8 +2472,8 @@ static struct lil_value *real_inc(struct lil *lil, const char *varname,
return pv;
}

-static struct lil_value *fnc_inc(struct lil *lil, size_t argc,
- struct lil_value **argv)
+static struct lil_value *fnc_incr(struct lil *lil, size_t argc,
+ struct lil_value **argv)
{
if (argc < 1)
return NULL;
@@ -2482,8 +2482,8 @@ static struct lil_value *fnc_inc(struct lil *lil, size_t argc,
argc > 1 ? lil_to_integer(argv[1]) : 1);
}

-static struct lil_value *fnc_dec(struct lil *lil, size_t argc,
- struct lil_value **argv)
+static struct lil_value *fnc_decr(struct lil *lil, size_t argc,
+ struct lil_value **argv)
{
if (argc < 1)
return NULL;
@@ -2786,8 +2786,8 @@ static struct lil_value *fnc_rtrim(struct lil *lil, size_t argc,
return real_trim(lil_to_string(argv[0]), chars, 0, 1);
}

-static struct lil_value *fnc_strcmp(struct lil *lil, size_t argc,
- struct lil_value **argv)
+static struct lil_value *fnc_compare(struct lil *lil, size_t argc,
+ struct lil_value **argv)
{
if (argc < 2)
return NULL;
@@ -2940,18 +2940,18 @@ static struct lil_value *fnc_lmap(struct lil *lil, size_t argc,

static void register_stdcmds(struct lil *lil)
{
- lil_register(lil, "dec", fnc_dec);
+ lil_register(lil, "decr", fnc_decr);
lil_register(lil, "eval", fnc_eval);
lil_register(lil, "expr", fnc_expr);
lil_register(lil, "for", fnc_for);
lil_register(lil, "foreach", fnc_foreach);
- lil_register(lil, "func", fnc_func);
+ lil_register(lil, "proc", fnc_proc);
lil_register(lil, "if", fnc_if);
- lil_register(lil, "inc", fnc_inc);
+ lil_register(lil, "incr", fnc_incr);
lil_register(lil, "local", fnc_local);
lil_register(lil, "return", fnc_return);
lil_register(lil, "set", fnc_set);
- lil_register(lil, "strcmp", fnc_strcmp);
+ lil_register(lil, "compare", fnc_compare);
lil_register(lil, "try", fnc_try);
lil_register(lil, "while", fnc_while);

--
2.32.0