mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 14:59:20 +02:00
Allow ord(n) to be overridden with user-defined function ordx(n)
Lets language packs customize ord.
This commit is contained in:
28
src/funcs.c
28
src/funcs.c
@@ -1150,6 +1150,7 @@ static int FAmpm(func_info *info)
|
||||
/***************************************************************/
|
||||
static int FOrd(func_info *info)
|
||||
{
|
||||
static int in_ford = 0;
|
||||
int t, u, v;
|
||||
char const *s;
|
||||
|
||||
@@ -1157,6 +1158,33 @@ static int FOrd(func_info *info)
|
||||
|
||||
ASSERT_TYPE(0, INT_TYPE);
|
||||
|
||||
if (!in_ford && UserFuncExists("ordx") == 1) {
|
||||
expr_node *n;
|
||||
int r;
|
||||
char const *e = buf;
|
||||
Value val;
|
||||
int nonconst;
|
||||
|
||||
val.type = ERR_TYPE;
|
||||
snprintf(buf, sizeof(buf), "ordx(%d)", ARGV(0));
|
||||
n = parse_expression(&e, &r, NULL);
|
||||
if (r == OK) {
|
||||
in_ford = 1;
|
||||
r = evaluate_expr_node(n, NULL, &val, &nonconst);
|
||||
in_ford = 0;
|
||||
if (r == OK) {
|
||||
if (nonconst) info->nonconst = nonconst;
|
||||
r = DoCoerce(STR_TYPE, &val);
|
||||
if (r == OK) {
|
||||
DCOPYVAL(RetVal, val);
|
||||
return r;
|
||||
}
|
||||
DestroyValue(val);
|
||||
}
|
||||
free_expr_tree(n);
|
||||
}
|
||||
}
|
||||
|
||||
v = ARGV(0);
|
||||
if (v < 0) {
|
||||
t = (-v) % 100;
|
||||
|
||||
Reference in New Issue
Block a user