tool_msgs: make errorf() show if --show-error
No binary (build failed)
—
(log yok)
| @@ -43,45 +43,43 @@ static void voutf(const char *prefix, | |
| va_list ap) | |
| { | |
| size_t width = (get_terminal_columns() - strlen(prefix)); | |
| + | size_t len; |
| + | char *ptr; |
| + | char *print_buffer; |
| DEBUGASSERT(!strchr(fmt, '\n')); | |
| - | if(!global->silent) { |
| - | size_t len; |
| - | char *ptr; |
| - | char *print_buffer; |
| - | |
| - | print_buffer = curl_mvaprintf(fmt, ap); |
| - | if(!print_buffer) |
| - | return; |
| - | len = strlen(print_buffer); |
| - | ptr = print_buffer; |
| - | while(len > 0) { |
| - | fputs(prefix, tool_stderr); |
| + | print_buffer = curl_mvaprintf(fmt, ap); |
| + | if(!print_buffer) |
| + | return; |
| + | len = strlen(print_buffer); |
| - | if(len > width) { |
| - | size_t cut = width-1; |
| + | ptr = print_buffer; |
| + | while(len > 0) { |
| + | fputs(prefix, tool_stderr); |
| - | while(!ISBLANK(ptr[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; |
| + | if(len > width) { |
| + | size_t 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; |
| + | while(!ISBLANK(ptr[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; |
| } | |
| - | curl_free(print_buffer); |
| } | |
| + | curl_free(print_buffer); |
| } | |
| /* | |
| @@ -90,11 +88,12 @@ static void voutf(const char *prefix, | |
| */ | |
| void notef(const char *fmt, ...) | |
| { | |
| - | va_list ap; |
| - | va_start(ap, fmt); |
| - | if(global->tracetype) |
| + | if(global->tracetype) { |
| + | va_list ap; |
| + | va_start(ap, fmt); |
| 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, ...) | |
| { | |
| - | va_list ap; |
| - | va_start(ap, fmt); |
| - | voutf(WARN_PREFIX, fmt, ap); |
| - | va_end(ap); |
| + | if(!global->silent) { |
| + | va_list ap; |
| + | va_start(ap, fmt); |
| + | voutf(WARN_PREFIX, fmt, ap); |
| + | va_end(ap); |
| + | } |
| } | |
| /* | |