mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Better call-stack printing.
This commit is contained in:
12
src/main.c
12
src/main.c
@@ -606,16 +606,22 @@ void Eprint(char const *fmt, ...)
|
||||
if (FreshLine && FileName) {
|
||||
FreshLine = 0;
|
||||
if (strcmp(FileName, "-")) {
|
||||
print_callstack(ErrFp);
|
||||
(void) fprintf(ErrFp, "%s(%d): ", FileName, LineNo);
|
||||
if (print_callstack(ErrFp)) {
|
||||
(void) fprintf(ErrFp, ": ");
|
||||
}
|
||||
} else {
|
||||
print_callstack(ErrFp);
|
||||
(void) fprintf(ErrFp, "-stdin-(%d): ", LineNo);
|
||||
if (print_callstack(ErrFp)) {
|
||||
(void) fprintf(ErrFp, ": ");
|
||||
}
|
||||
}
|
||||
if (DebugFlag & DB_PRTLINE) OutputLine(ErrFp);
|
||||
} else if (FileName) {
|
||||
print_callstack(ErrFp);
|
||||
fprintf(ErrFp, " ");
|
||||
if (print_callstack(ErrFp)) {
|
||||
(void) fprintf(ErrFp, ": ");
|
||||
}
|
||||
}
|
||||
|
||||
va_start(argptr, fmt);
|
||||
|
||||
22
src/utils.c
22
src/utils.c
@@ -231,18 +231,24 @@ have_callstack(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
print_callstack_aux(FILE *fp, cs *entry)
|
||||
{
|
||||
if (entry) {
|
||||
print_callstack_aux(fp, entry->next);
|
||||
fprintf(fp, "\n");
|
||||
(void) fprintf(fp, "%s(%d): In function `%s'", entry->filename, entry->lineno, entry->func);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
print_callstack(FILE *fp)
|
||||
{
|
||||
int done = 0;
|
||||
cs *entry = callstack;
|
||||
while(entry) {
|
||||
(void) fprintf(fp, "%s(%d): In function `%s'\n", entry->filename, entry->lineno, entry->func);
|
||||
done = 1;
|
||||
entry = entry->next;
|
||||
}
|
||||
return done;
|
||||
print_callstack_aux(fp, callstack);
|
||||
if (callstack) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
pop_call(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user