context: make error line debug a little better

Make a line to the ^ so that it is more visible. Spell out column
completely. Make the sizes a little smaller to avoid awkward gaps.
This commit is contained in:
Wim Taymans 2024-03-27 16:23:38 +01:00
parent a9fdc6a408
commit a0af514581

View file

@ -35,7 +35,7 @@ struct spa_debug_context {
static inline void spa_debugc_error_location(struct spa_debug_context *c, static inline void spa_debugc_error_location(struct spa_debug_context *c,
struct spa_error_location *loc) struct spa_error_location *loc)
{ {
int i, skip = loc->col > 80 ? loc->col - 40 : 0; int i, skip = loc->col > 80 ? loc->col - 40 : 0, lc = loc->col-skip-1;
char buf[80]; char buf[80];
for (i = 0; (size_t)i < sizeof(buf)-1; i++) { for (i = 0; (size_t)i < sizeof(buf)-1; i++) {
@ -47,8 +47,8 @@ static inline void spa_debugc_error_location(struct spa_debug_context *c,
buf[i] = '\0'; buf[i] = '\0';
spa_debugc(c, "line:%6d | %s%s", loc->line, skip ? "..." : "", buf); spa_debugc(c, "line:%6d | %s%s", loc->line, skip ? "..." : "", buf);
for (i = 0; buf[i]; i++) for (i = 0; buf[i]; i++)
buf[i] = i+skip+1 == loc->col ? '^' : ' '; buf[i] = i < lc ? '-' : i == lc ? '^' : ' ';
spa_debugc(c, "col: %6d | %s%s", loc->col, skip ? " " : "", buf); spa_debugc(c, "column:%4d |-%s%s", loc->col, skip ? "---" : "", buf);
} }
/** /**