MCPcopy Create free account
hub / github.com/git/git / vfreportf

Function vfreportf

usage.c:12–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "strbuf.h"
11
12static void vfreportf(FILE *f, const char *prefix, const char *err, va_list params)
13{
14 char msg[4096];
15 char *p, *pend = msg + sizeof(msg);
16 size_t prefix_len = strlen(prefix);
17
18 if (sizeof(msg) <= prefix_len) {
19 fprintf(stderr, "BUG!!! too long a prefix '%s'\n", prefix);
20 abort();
21 }
22 memcpy(msg, prefix, prefix_len);
23 p = msg + prefix_len;
24 if (vsnprintf(p, pend - p, err, params) < 0) {
25 fprintf(stderr, _("error: unable to format message: %s\n"),
26 err);
27 *p = '\0'; /* vsnprintf() failed, clip at prefix */
28 }
29
30 for (; p != pend - 1 && *p; p++) {
31 if (iscntrl(*p) && *p != '\t' && *p != '\n')
32 *p = '?';
33 }
34
35 *(p++) = '\n'; /* we no longer need a NUL */
36 fflush(f);
37 write_in_full(fileno(f), msg, p - msg);
38}
39
40static void vreportf(const char *prefix, const char *err, va_list params)
41{

Callers 2

vreportfFunction · 0.85

Calls 1

write_in_fullFunction · 0.85

Tested by

no test coverage detected