Remove % prefix for builtin commands
This commit is contained in:
@ -99,20 +99,23 @@ void tz_tokenize(Tokenizer *tz) {
|
||||
}
|
||||
|
||||
void tz_classify(Tokenizer *tz) {
|
||||
#define IF_RTCMD(name) if (string_strcmp(tk->str, #name) == 0) { \
|
||||
tk->type = TOK_CMD; \
|
||||
tk->cmd = &rt_ ## name; \
|
||||
}
|
||||
|
||||
Token *tk, *tktmp;
|
||||
LL_FOREACH_SAFE(tz->tokens, tk, tktmp) {
|
||||
if (tk->str[0] == '\'') {
|
||||
tk->type = TOK_STRING;
|
||||
} else if (tk->str[0] == '%') {
|
||||
RtCmd *cmd, *cmdtmp;
|
||||
LL_FOREACH_SAFE(RTCMDS, cmd, cmdtmp) {
|
||||
if (string_strcmp(tk->str, cmd->cmdname) == 0) {
|
||||
tk->type = TOK_CMD;
|
||||
tk->cmd = cmd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else IF_RTCMD(print)
|
||||
else IF_RTCMD(mkalias)
|
||||
else IF_RTCMD(PID)
|
||||
else IF_RTCMD(do)
|
||||
else IF_RTCMD(stackpush)
|
||||
else IF_RTCMD(stackpop)
|
||||
else {
|
||||
tk->type = TOK_MISC;
|
||||
}
|
||||
}
|
||||
@ -184,7 +187,7 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter
|
||||
|
||||
Token *cmdtk = tz.tokens;
|
||||
if (cmdtk->type == TOK_CMD) {
|
||||
ok = cmdtk->cmd->fn(cmdtk->next);
|
||||
ok = cmdtk->cmd(cmdtk->next);
|
||||
if (!ok) {
|
||||
usprintf(RES.errmsg, "cmd %s failed", cmdtk->str);
|
||||
goto next;
|
||||
|
Reference in New Issue
Block a user