WIP 2
This commit is contained in:
@ -16,32 +16,31 @@ RtAlias *RTALIASES = NULL;
|
||||
} while(0)
|
||||
|
||||
bool rt_print(Token *tks) {
|
||||
Token *tk = tks;
|
||||
while (tk) {
|
||||
uprintf("%.*s", (int)tk->len, tk->ptr);
|
||||
Token *tk, *tktmp;
|
||||
LL_FOREACH_SAFE(tks, tk, tktmp) {
|
||||
writefmt("{s}", tk->str);
|
||||
if (tk->next != NULL) {
|
||||
uprintf(" ");
|
||||
writefmt(" ");
|
||||
}
|
||||
tk = tk->next;
|
||||
}
|
||||
uprintf("\n");
|
||||
writefmt("\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rt_mkalias(Token *tks) {
|
||||
RtAlias *alias = dlmalloc(sizeof(*alias));
|
||||
string_memset(alias, 0, sizeof(*alias));
|
||||
Token *tk = tks;
|
||||
size_t i = 0;
|
||||
while (tk) {
|
||||
|
||||
size_t i;
|
||||
Token *tk, *tktmp;
|
||||
LL_FOREACH_SAFE_IDX(tks, tk, tktmp, i) {
|
||||
if (i == 0) {
|
||||
usprintf(alias->namebuf, "%.*s", (int)tk->len, tk->ptr);
|
||||
string_memcpy(alias->namebuf, tk->str, MIN(string_len(tk->str), RTALIAS_NAMEBUF_MAX));
|
||||
} else if (i == 1) {
|
||||
usprintf(alias->valbuf, "%.*s", (int)tk->len, tk->ptr);
|
||||
string_memcpy(alias->valbuf, tk->str, MIN(string_len(tk->str), RTALIAS_VALBUF_MAX));
|
||||
}
|
||||
i++;
|
||||
tk = tk->next;
|
||||
}
|
||||
|
||||
LL_APPEND(RTALIASES, alias);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user