mirror of
https://github.com/curl/curl.git
synced 2026-08-25 06:13:31 +03:00
tool_msgs: make errorf() show if --show-error
Assisted-by: Mitchell Blank Jr Ref: #19029 Closes #19035
This commit is contained in:
parent
cde85412d0
commit
56450ce26f
1 changed files with 40 additions and 39 deletions
|
|
@ -43,45 +43,43 @@ 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));
|
||||||
|
size_t len;
|
||||||
|
char *ptr;
|
||||||
|
char *print_buffer;
|
||||||
DEBUGASSERT(!strchr(fmt, '\n'));
|
DEBUGASSERT(!strchr(fmt, '\n'));
|
||||||
if(!global->silent) {
|
|
||||||
size_t len;
|
|
||||||
char *ptr;
|
|
||||||
char *print_buffer;
|
|
||||||
|
|
||||||
print_buffer = curl_mvaprintf(fmt, ap);
|
print_buffer = curl_mvaprintf(fmt, ap);
|
||||||
if(!print_buffer)
|
if(!print_buffer)
|
||||||
return;
|
return;
|
||||||
len = strlen(print_buffer);
|
len = strlen(print_buffer);
|
||||||
|
|
||||||
ptr = print_buffer;
|
ptr = print_buffer;
|
||||||
while(len > 0) {
|
while(len > 0) {
|
||||||
fputs(prefix, tool_stderr);
|
fputs(prefix, tool_stderr);
|
||||||
|
|
||||||
if(len > width) {
|
if(len > width) {
|
||||||
size_t cut = width-1;
|
size_t cut = width-1;
|
||||||
|
|
||||||
while(!ISBLANK(ptr[cut]) && cut) {
|
while(!ISBLANK(ptr[cut]) && cut) {
|
||||||
cut--;
|
cut--;
|
||||||
}
|
|
||||||
if(cut == 0)
|
|
||||||
/* not a single cutting position was found, just cut it at the
|
|
||||||
max text width then! */
|
|
||||||
cut = width-1;
|
|
||||||
|
|
||||||
(void)fwrite(ptr, cut + 1, 1, tool_stderr);
|
|
||||||
fputs("\n", tool_stderr);
|
|
||||||
ptr += cut + 1; /* skip the space too */
|
|
||||||
len -= cut + 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fputs(ptr, tool_stderr);
|
|
||||||
fputs("\n", tool_stderr);
|
|
||||||
len = 0;
|
|
||||||
}
|
}
|
||||||
|
if(cut == 0)
|
||||||
|
/* not a single cutting position was found, just cut it at the
|
||||||
|
max text width then! */
|
||||||
|
cut = width-1;
|
||||||
|
|
||||||
|
(void)fwrite(ptr, cut + 1, 1, tool_stderr);
|
||||||
|
fputs("\n", tool_stderr);
|
||||||
|
ptr += cut + 1; /* skip the space too */
|
||||||
|
len -= cut + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fputs(ptr, tool_stderr);
|
||||||
|
fputs("\n", tool_stderr);
|
||||||
|
len = 0;
|
||||||
}
|
}
|
||||||
curl_free(print_buffer);
|
|
||||||
}
|
}
|
||||||
|
curl_free(print_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -90,11 +88,12 @@ static void voutf(const char *prefix,
|
||||||
*/
|
*/
|
||||||
void notef(const char *fmt, ...)
|
void notef(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
if(global->tracetype) {
|
||||||
va_start(ap, fmt);
|
va_list ap;
|
||||||
if(global->tracetype)
|
va_start(ap, fmt);
|
||||||
voutf(NOTE_PREFIX, fmt, ap);
|
voutf(NOTE_PREFIX, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -103,10 +102,12 @@ void notef(const char *fmt, ...)
|
||||||
*/
|
*/
|
||||||
void warnf(const char *fmt, ...)
|
void warnf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
if(!global->silent) {
|
||||||
va_start(ap, fmt);
|
va_list ap;
|
||||||
voutf(WARN_PREFIX, fmt, ap);
|
va_start(ap, fmt);
|
||||||
va_end(ap);
|
voutf(WARN_PREFIX, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue