mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-05-06 15:47:55 +02:00
Print call stack if an error occurs in a user-defined function.
This commit is contained in:
@@ -163,6 +163,7 @@ int ReadLine(void)
|
||||
LineNo = CLine->LineNo;
|
||||
CLine = CLine->next;
|
||||
FreshLine = 1;
|
||||
clear_callstack();
|
||||
if (DebugFlag & DB_ECHO_LINE) OutputLine(ErrFp);
|
||||
return OK;
|
||||
}
|
||||
@@ -263,6 +264,7 @@ static int ReadLineFromFile(int use_pclose)
|
||||
}
|
||||
|
||||
FreshLine = 1;
|
||||
clear_callstack();
|
||||
if (DebugFlag & DB_ECHO_LINE) OutputLine(ErrFp);
|
||||
return OK;
|
||||
}
|
||||
@@ -818,6 +820,7 @@ static int IncludeCmd(char const *cmd)
|
||||
int old_flag;
|
||||
|
||||
FreshLine = 1;
|
||||
clear_callstack();
|
||||
if (IStackPtr+1 >= INCLUDE_NEST) return E_NESTED_INCLUDE;
|
||||
i = &IStack[IStackPtr];
|
||||
|
||||
@@ -935,6 +938,7 @@ int IncludeFile(char const *fname)
|
||||
struct stat statbuf;
|
||||
|
||||
FreshLine = 1;
|
||||
clear_callstack();
|
||||
if (IStackPtr+1 >= INCLUDE_NEST) return E_NESTED_INCLUDE;
|
||||
i = &IStack[IStackPtr];
|
||||
|
||||
|
||||
+6
-2
@@ -605,12 +605,16 @@ void Eprint(char const *fmt, ...)
|
||||
|
||||
if (FreshLine && FileName) {
|
||||
FreshLine = 0;
|
||||
if (strcmp(FileName, "-"))
|
||||
if (strcmp(FileName, "-")) {
|
||||
print_callstack(ErrFp);
|
||||
(void) fprintf(ErrFp, "%s(%d): ", FileName, LineNo);
|
||||
else
|
||||
} else {
|
||||
print_callstack(ErrFp);
|
||||
(void) fprintf(ErrFp, "-stdin-(%d): ", LineNo);
|
||||
}
|
||||
if (DebugFlag & DB_PRTLINE) OutputLine(ErrFp);
|
||||
} else if (FileName) {
|
||||
print_callstack(ErrFp);
|
||||
fprintf(ErrFp, " ");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -175,4 +175,4 @@ int push_call(char const *filename, char const *func, int lineno);
|
||||
void clear_callstack(void);
|
||||
int have_callstack(void);
|
||||
int print_callstack(FILE *fp);
|
||||
|
||||
void pop_call(void);
|
||||
|
||||
@@ -316,7 +316,11 @@ int CallUserFunc(char const *name, int nargs, ParsePtr p)
|
||||
/* Skip the opening bracket, if there's one */
|
||||
while (isempty(*s)) s++;
|
||||
if (*s == BEG_OF_EXPR) s++;
|
||||
push_call(f->filename, f->name, f->lineno);
|
||||
h = Evaluate(&s, f->locals, p);
|
||||
if (h == OK) {
|
||||
pop_call();
|
||||
}
|
||||
f->IsActive = 0;
|
||||
DestroyLocalVals(f);
|
||||
if (DebugFlag &DB_PRTEXPR) {
|
||||
|
||||
+10
-1
@@ -237,9 +237,18 @@ print_callstack(FILE *fp)
|
||||
int done = 0;
|
||||
cs *entry = callstack;
|
||||
while(entry) {
|
||||
(void) fprintf(fp, "%s(%d): %s\n", entry->filename, entry->lineno, entry->func);
|
||||
(void) fprintf(fp, "%s(%d): In function `%s'\n", entry->filename, entry->lineno, entry->func);
|
||||
done = 1;
|
||||
entry = entry->next;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
void
|
||||
pop_call(void)
|
||||
{
|
||||
cs *entry = callstack;
|
||||
if (entry) {
|
||||
callstack = entry->next;
|
||||
destroy_cs(entry);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user