Skip to content
Permalink
Browse files
Merge pull request #2373 from dscho/fix-t5516-flakiness
Fix t5516 flakiness in MSVC builds
  • Loading branch information
dscho committed Oct 30, 2019
2 parents 578744f + f6d6c81 commit e96e0b4be65f8c162ebf805bf7267c0563ab91cc
Showing with 16 additions and 4 deletions.
  1. +16 −4 usage.c
20 usage.c
@@ -9,14 +9,26 @@
void vreportf(const char *prefix, const char *err, va_list params)
{
char msg[4096];
char *p;
char *p, *pend = msg + sizeof(msg);
size_t prefix_len = strlen(prefix);

vsnprintf(msg, sizeof(msg), err, params);
for (p = msg; *p; p++) {
if (sizeof(msg) <= prefix_len) {
fprintf(stderr, "BUG!!! too long a prefix '%s'\n", prefix);
abort();
}
memcpy(msg, prefix, prefix_len);
p = msg + prefix_len;
if (vsnprintf(p, pend - p, err, params) < 0)
*p = '\0'; /* vsnprintf() failed, clip at prefix */

for (; p != pend - 1 && *p; p++) {
if (iscntrl(*p) && *p != '\t' && *p != '\n')
*p = '?';
}
fprintf(stderr, "%s%s\n", prefix, msg);

*(p++) = '\n'; /* we no longer need a NUL */
fflush(stderr);
write_in_full(2, msg, p - msg);
}

static NORETURN void usage_builtin(const char *err, va_list params)

0 comments on commit e96e0b4

Please sign in to comment.