diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
index 42b95a9b5169125fac7bde3caabb15f4cb6a351d..d015e436d57472bf9560a6f604705f52938c9f19 100644 (file)
--- a/compat/win32/syslog.c
+++ b/compat/win32/syslog.c
#include "../../git-compat-util.h"
#include "../../git-compat-util.h"
-#include "../../strbuf.h"
static HANDLE ms_eventlog;
static HANDLE ms_eventlog;
void syslog(int priority, const char *fmt, ...)
{
void syslog(int priority, const char *fmt, ...)
{
- struct strbuf sb = STRBUF_INIT;
- struct strbuf_expand_dict_entry dict[] = {
- {"1", "% 1"},
- {NULL, NULL}
- };
WORD logtype;
WORD logtype;
- char *str;
+ char *str, *pos;
int str_len;
va_list ap;
int str_len;
va_list ap;
}
str = malloc(str_len + 1);
}
str = malloc(str_len + 1);
+ if (!str) {
+ warning("malloc failed: '%s'", strerror(errno));
+ return;
+ }
+
va_start(ap, fmt);
vsnprintf(str, str_len + 1, fmt, ap);
va_end(ap);
va_start(ap, fmt);
vsnprintf(str, str_len + 1, fmt, ap);
va_end(ap);
- strbuf_expand(&sb, str, strbuf_expand_dict_cb, &dict);
- free(str);
+
+ while ((pos = strstr(str, "%1")) != NULL) {
+ str = realloc(str, ++str_len + 1);
+ if (!str) {
+ warning("realloc failed: '%s'", strerror(errno));
+ return;
+ }
+ memmove(pos + 2, pos + 1, strlen(pos));
+ pos[1] = ' ';
+ }
switch (priority) {
case LOG_EMERG:
switch (priority) {
case LOG_EMERG:
}
ReportEventA(ms_eventlog, logtype, 0, 0, NULL, 1, 0,
}
ReportEventA(ms_eventlog, logtype, 0, 0, NULL, 1, 0,
- (const char **)&sb.buf, NULL);
-
- strbuf_release(&sb);
+ (const char **)&str, NULL);
+ free(str);
}
}