Add support for the "subst_#x" functions to simplify language customization.

This commit is contained in:
Dianne Skoll
2022-03-23 11:52:51 -04:00
parent 4fdf7b706b
commit 0641a6f8f1
2 changed files with 26 additions and 5 deletions
+21
View File
@@ -284,6 +284,27 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
}
}
if (!done) {
snprintf(uf, sizeof(uf), "subst_%cx", c);
if (UserFuncExists(uf) == 3) {
snprintf(s, sizeof(s), "subst_%cx(%d, '%04d-%02d-%02d', %02d:%02d)",
c, altmode ? 1 : 0, y, m+1, d, h, min);
expr = (char const *) s;
r = EvalExpr(&expr, &v, NULL);
if (r == OK) {
if (!DoCoerce(STR_TYPE, &v)) {
if (DBufPuts(dbuf, v.v.str) != OK) {
DestroyValue(v);
return E_NO_MEM;
}
}
DestroyValue(v);
continue;
}
}
}
if (!done) switch(UPPER(c)) {
case 'A':
#ifdef L_A_OVER