tool_msgs: make errorf() show if --show-error

Assisted-by: Mitchell Blank Jr
Ref: #19029
Closes #19035
This commit is contained in:
Daniel Stenberg 2025-10-12 23:48:14 +02:00
parent cde85412d0
commit 56450ce26f
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -43,11 +43,10 @@ static void voutf(const char *prefix,
va_list ap) va_list ap)
{ {
size_t width = (get_terminal_columns() - strlen(prefix)); size_t width = (get_terminal_columns() - strlen(prefix));
DEBUGASSERT(!strchr(fmt, '\n'));
if(!global->silent) {
size_t len; size_t len;
char *ptr; char *ptr;
char *print_buffer; char *print_buffer;
DEBUGASSERT(!strchr(fmt, '\n'));
print_buffer = curl_mvaprintf(fmt, ap); print_buffer = curl_mvaprintf(fmt, ap);
if(!print_buffer) if(!print_buffer)
@ -82,7 +81,6 @@ static void voutf(const char *prefix,
} }
curl_free(print_buffer); curl_free(print_buffer);
} }
}
/* /*
* Emit 'note' formatted message on configured 'errors' stream, if verbose was * Emit 'note' formatted message on configured 'errors' stream, if verbose was
@ -90,12 +88,13 @@ static void voutf(const char *prefix,
*/ */
void notef(const char *fmt, ...) void notef(const char *fmt, ...)
{ {
if(global->tracetype) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
if(global->tracetype)
voutf(NOTE_PREFIX, fmt, ap); voutf(NOTE_PREFIX, fmt, ap);
va_end(ap); va_end(ap);
} }
}
/* /*
* Emit warning formatted message on configured 'errors' stream unless * Emit warning formatted message on configured 'errors' stream unless
@ -103,11 +102,13 @@ void notef(const char *fmt, ...)
*/ */
void warnf(const char *fmt, ...) void warnf(const char *fmt, ...)
{ {
if(!global->silent) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
voutf(WARN_PREFIX, fmt, ap); voutf(WARN_PREFIX, fmt, ap);
va_end(ap); va_end(ap);
} }
}
/* /*
* Emit help formatted message on given stream. This is for errors with or * Emit help formatted message on given stream. This is for errors with or