Better error-reporting.

This commit is contained in:
Dianne Skoll
2026-05-14 10:21:07 -04:00
parent 6c9d685eca
commit aee054281e
2 changed files with 23 additions and 16 deletions
+2 -2
View File
@@ -68,7 +68,7 @@
as a REM statement, also. */
#define E_CANT_MODIFY 45
#define E_MKTIME_PROBLEM 46
#define E_REDEF_FUNC 47
#define E_REDEF_BUILTIN_FUNC 47
#define E_CANTNEST_FDEF 48
#define E_REP_FULSPEC 49
#define E_YR_TWICE 50
@@ -204,7 +204,7 @@ EXTERN char *ErrMsg[]
/* E_PARSE_AS_REM */ "",
/* E_CANT_MODIFY */ "Cannot modify system variable",
/* E_MKTIME_PROBLEM */ "C library function can't represent date/time",
/* E_REDEF_FUNC */ "Attempt to redefine built-in function",
/* E_REDEF_BUILTIN_FUNC */ "Attempt to redefine built-in function",
/* E_CANTNEST_FDEF */ "Can't nest function definition in expression",
/* E_REP_FULSPEC */ "Must fully specify date to use repeat factor",
/* E_YR_TWICE */ "Year specified twice",
+21 -14
View File
@@ -117,16 +117,16 @@ int DoFrename(ParsePtr p)
return r;
}
if (FindBuiltinFunc(DBufValue(&newbuf))) {
Eprint("%s: `%s'", GetErr(E_REDEF_FUNC), DBufValue(&newbuf));
Eprint("%s: `%s'", GetErr(E_REDEF_BUILTIN_FUNC), DBufValue(&newbuf));
DBufFree(&oldbuf);
DBufFree(&newbuf);
return E_REDEF_FUNC;
return E_REDEF_BUILTIN_FUNC;
}
if (FindBuiltinFunc(DBufValue(&oldbuf))) {
Eprint("%s: `%s'", GetErr(E_REDEF_FUNC), DBufValue(&oldbuf));
Eprint("%s: `%s'", GetErr(E_REDEF_BUILTIN_FUNC), DBufValue(&oldbuf));
DBufFree(&oldbuf);
DBufFree(&newbuf);
return E_REDEF_FUNC;
return E_REDEF_BUILTIN_FUNC;
}
RenameUserFunc(DBufValue(&oldbuf), DBufValue(&newbuf));
DBufFree(&oldbuf);
@@ -288,23 +288,29 @@ int DoFset(ParsePtr p)
nonconst_debug(0, tr("Function definition considered non-constant because of context"));
func->is_constant = 0;
}
StrnCpy(func->name, DBufValue(&buf), VAR_NAME_LEN);
DBufFree(&buf);
if (!Hush) {
if (FindBuiltinFunc(func->name)) {
if (warning_level("03.00.04")) {
Eprint("%s: `%s'", GetErr(E_REDEF_FUNC), func->name);
}
}
}
func->node = NULL;
func->nargs = 0;
func->args = NULL;
StrnCpy(func->name, DBufValue(&buf), VAR_NAME_LEN);
DBufFree(&buf);
if (FindBuiltinFunc(func->name)) {
if (!Hush) {
if (warning_level("03.00.04")) {
Eprint("%s: `%s'", GetErr(E_REDEF_BUILTIN_FUNC), func->name);
}
}
DestroyUserFunc(func);
return E_REDEF_BUILTIN_FUNC;
}
/* Get the local variables */
c=ParseNonSpaceChar(p, &r, 1);
if (r) return r;
if (r) {
DestroyUserFunc(func);
return r;
}
if (c == ')') {
(void) ParseNonSpaceChar(p, &r, 0);
} else {
@@ -726,6 +732,7 @@ int PushUserFuncs(ParsePtr p)
if (!Hush) {
if (warning_level("06.02.06")) {
Eprint("%s: `%s'", GetErr(E_PUSH_BUILTIN_FUNC), name);
FreshLine = 1;
}
}
DBufFree(&buf);