mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-23 01:32:58 +02:00
Introduce "FSET - f(args) expr" syntax to define a function and suppress any "redefined function" warnings.
This commit is contained in:
+12
-1
@@ -5076,7 +5076,18 @@ function, the command fails with an error message and does nothing.
|
|||||||
If you define a user-defined function and then later on redefine it,
|
If you define a user-defined function and then later on redefine it,
|
||||||
\fBRemind\fR will issue a warning. If you do not want this warning,
|
\fBRemind\fR will issue a warning. If you do not want this warning,
|
||||||
then use \fBFUNSET\fR to remove the existing definition before you
|
then use \fBFUNSET\fR to remove the existing definition before you
|
||||||
redefine the function.
|
redefine the function. Alternatively, you can use a "-" token before
|
||||||
|
the function name to suppress "redefined function" warnings, as in the
|
||||||
|
following example:
|
||||||
|
.PP
|
||||||
|
.nf
|
||||||
|
FSET - f(x) 2*x
|
||||||
|
# You must have space before and after the "-"
|
||||||
|
# This will NOT work:
|
||||||
|
# FSET -f(x) 2*x
|
||||||
|
.fi
|
||||||
|
.PP
|
||||||
|
to define a function and suppress any "redefined function" warning.
|
||||||
.PP
|
.PP
|
||||||
.SH PRECISE SCHEDULING
|
.SH PRECISE SCHEDULING
|
||||||
.PP
|
.PP
|
||||||
|
|||||||
+24
-3
@@ -181,12 +181,31 @@ int DoFset(ParsePtr p)
|
|||||||
Var *locals = NULL;
|
Var *locals = NULL;
|
||||||
Var local_array[MAX_FUNC_ARGS];
|
Var local_array[MAX_FUNC_ARGS];
|
||||||
int orig_namelen;
|
int orig_namelen;
|
||||||
|
int suppress_redefined_function_warning = 0;
|
||||||
|
int ch;
|
||||||
|
|
||||||
DynamicBuffer buf;
|
DynamicBuffer buf;
|
||||||
DBufInit(&buf);
|
DBufInit(&buf);
|
||||||
|
|
||||||
|
|
||||||
|
ch = ParseNonSpaceChar(p, &r, 1);
|
||||||
|
if (r) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
if (ch == '-') {
|
||||||
|
r = ParseToken(p, &buf);
|
||||||
|
if (strcmp(DBufValue(&buf), "-")) {
|
||||||
|
DBufFree(&buf);
|
||||||
|
return E_PARSE_ERR;
|
||||||
|
}
|
||||||
|
suppress_redefined_function_warning = 1;
|
||||||
|
DBufFree(&buf);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the function name */
|
/* Get the function name */
|
||||||
if ( (r=ParseIdentifier(p, &buf)) ) return r;
|
if ( (r=ParseIdentifier(p, &buf)) ) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
if (*DBufValue(&buf) == '$') {
|
if (*DBufValue(&buf) == '$') {
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return E_BAD_ID;
|
return E_BAD_ID;
|
||||||
@@ -222,8 +241,10 @@ int DoFset(ParsePtr p)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
/* Warn about redefinition */
|
/* Warn about redefinition */
|
||||||
Wprint(tr("Function `%s' redefined: previously defined at %s(%s)"),
|
if (!suppress_redefined_function_warning) {
|
||||||
existing->name, existing->filename, line_range(existing->lineno_start, existing->lineno));
|
Wprint(tr("Function `%s' redefined: previously defined at %s(%s)"),
|
||||||
|
existing->name, existing->filename, line_range(existing->lineno_start, existing->lineno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should be followed by '(' */
|
/* Should be followed by '(' */
|
||||||
|
|||||||
+1
-2
@@ -800,8 +800,7 @@ Leaving UserFN _ofunc(1991-02-28) => 0
|
|||||||
../tests/test.rem(224): Trig = Thursday, 28 February, 1991
|
../tests/test.rem(224): Trig = Thursday, 28 February, 1991
|
||||||
|
|
||||||
# omitfunc ignores local/global omits
|
# omitfunc ignores local/global omits
|
||||||
fset _ofunc(x) 0
|
fset - _ofunc(x) 0
|
||||||
../tests/test.rem(227): Function `_ofunc' redefined: previously defined at ../tests/test.rem(222)
|
|
||||||
OMIT 1 March
|
OMIT 1 March
|
||||||
OMIT 2 March 1991
|
OMIT 2 March 1991
|
||||||
REM 1 March OMIT Sun OMITFUNC _ofunc AFTER MSG Should trigger 1 March
|
REM 1 March OMIT Sun OMITFUNC _ofunc AFTER MSG Should trigger 1 March
|
||||||
|
|||||||
+1
-1
@@ -224,7 +224,7 @@ REM 1 March OMITFUNC _ofunc AFTER MSG OmitFunc Test
|
|||||||
REM 8 March OMITFUNC _ofunc -1 MSG OmitFunc Test 2
|
REM 8 March OMITFUNC _ofunc -1 MSG OmitFunc Test 2
|
||||||
|
|
||||||
# omitfunc ignores local/global omits
|
# omitfunc ignores local/global omits
|
||||||
fset _ofunc(x) 0
|
fset - _ofunc(x) 0
|
||||||
OMIT 1 March
|
OMIT 1 March
|
||||||
OMIT 2 March 1991
|
OMIT 2 March 1991
|
||||||
REM 1 March OMIT Sun OMITFUNC _ofunc AFTER MSG Should trigger 1 March
|
REM 1 March OMIT Sun OMITFUNC _ofunc AFTER MSG Should trigger 1 March
|
||||||
|
|||||||
Reference in New Issue
Block a user