mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-05-16 12:30:09 +02:00
Add warnings if we try to PUSH or FUNSET a built-in function.
This commit is contained in:
@@ -139,7 +139,8 @@
|
||||
#define E_EXPECTING_EOXPR 115
|
||||
#define E_EXPECTING_ATOM 116
|
||||
#define E_BAD_VAL_FOR_SYSVAR 117
|
||||
|
||||
#define E_UNSET_BUILTIN_FUNC 118
|
||||
#define E_PUSH_BUILTIN_FUNC 119
|
||||
#ifdef MK_GLOBALS
|
||||
#undef EXTERN
|
||||
#define EXTERN
|
||||
@@ -274,6 +275,8 @@ EXTERN char *ErrMsg[]
|
||||
/* E_EXPECTING_EOXPR */ "Expecting operator or end-of-expression",
|
||||
/* E_EXPECTING_ATOM */ "Expecting constant, variable, function call or (expression)",
|
||||
/* E_BAD_VAL_FOR_SYSVAR */ "Invalid value for system variable",
|
||||
/* E_UNSET_BUILTIN_FUNC */ "Attempt to unset built-in function",
|
||||
/* E_PUSH_BUILTIN_FUNC */ "Attempt to PUSH built-in function",
|
||||
}
|
||||
#endif /* MK_GLOBALS */
|
||||
;
|
||||
|
||||
@@ -449,6 +449,13 @@ static void DestroyUserFunc(UserFunc *f)
|
||||
/***************************************************************/
|
||||
static void FUnset(char const *name)
|
||||
{
|
||||
if (!Hush) {
|
||||
if (FindBuiltinFunc(name)) {
|
||||
if (warning_level("06.02.06")) {
|
||||
Eprint("%s: `%s'", GetErr(E_UNSET_BUILTIN_FUNC), name);
|
||||
}
|
||||
}
|
||||
}
|
||||
UserFunc *f = FindUserFunc(name);
|
||||
if (f) {
|
||||
hash_table_delete(&FuncHash, f);
|
||||
@@ -715,6 +722,15 @@ int PushUserFuncs(ParsePtr p)
|
||||
return E_BAD_ID;
|
||||
}
|
||||
|
||||
if (FindBuiltinFunc(name)) {
|
||||
if (!Hush) {
|
||||
if (warning_level("06.02.06")) {
|
||||
Eprint("%s: `%s'", GetErr(E_PUSH_BUILTIN_FUNC), name);
|
||||
}
|
||||
}
|
||||
DBufFree(&buf);
|
||||
continue;
|
||||
}
|
||||
r = add_func_to_push(name, pf);
|
||||
|
||||
DBufFree(&buf);
|
||||
|
||||
+6
-1
@@ -16771,7 +16771,10 @@ mbupper("öÖçÇéôñÑÉÊ") => "ÖÖÇÇÉÔÑÑÉÊ"
|
||||
mblower("öÖçÇéôñÑÉÊ") => "ööççéôññéê"
|
||||
upper("öÖçÇéôñÑÉÊ") => "öÖçÇéôñÑÉÊ"
|
||||
lower("öÖçÇéôñÑÉÊ") => "öÖçÇéôñÑÉÊ"
|
||||
DynBuf Mallocs: 1132 mallocs; 31873408 bytes
|
||||
../tests/test.rem(1915): Attempt to redefine built-in function: `max'
|
||||
../tests/test.rem(1916): Attempt to unset built-in function: `max'
|
||||
../tests/test.rem(1917): Attempt to PUSH built-in function: `max'
|
||||
DynBuf Mallocs: 1134 mallocs; 31873536 bytes
|
||||
Variable hash table statistics:
|
||||
Entries: 100146; Buckets: 87719; Non-empty Buckets: 66303
|
||||
Maxlen: 5; Minlen: 0; Avglen: 1.142; Stddev: 0.878; Avg nonempty len: 1.510
|
||||
@@ -25201,6 +25204,8 @@ TRANSLATE "Maximum expression complexity exceeded" ""
|
||||
TRANSLATE "Expecting operator or end-of-expression" ""
|
||||
TRANSLATE "Expecting constant, variable, function call or (expression)" ""
|
||||
TRANSLATE "Invalid value for system variable" ""
|
||||
TRANSLATE "Attempt to unset built-in function" ""
|
||||
TRANSLATE "Attempt to PUSH built-in function" ""
|
||||
|
||||
# Other Messages
|
||||
TRANSLATE "%s function `%s' defined at %s(%s) does not use its argument" ""
|
||||
|
||||
@@ -1911,6 +1911,12 @@ SET a upper("öÖçÇéôñÑÉÊ")
|
||||
SET a lower("öÖçÇéôñÑÉÊ")
|
||||
DEBUG -x
|
||||
|
||||
# Warnings about defining/unsetting/pushing built-in functions
|
||||
FSET max(x) x*2
|
||||
FUNSET max
|
||||
PUSH-FUNCS max a b c
|
||||
POP-FUNCS
|
||||
|
||||
# Don't want Remind to queue reminders
|
||||
EXIT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user