#define pychar wchar_t
static wchar_t *wconv(const char *s)
{
- size_t outlen = mbstowcs(NULL, s, 0);
+ size_t outlen = s ? mbstowcs(NULL, s, 0) : 0;
wchar_t *out = malloc((outlen + 1) * sizeof(wchar_t));
- mbstowcs(out, s, outlen + 1);
+
+ if (outlen > 0)
+ mbstowcs(out, s, outlen);
out[outlen] = 0;
return out;
}
*cr = ' ';
fprintf(stderr, "clippy interactive shell\n(Python %s)\n", ver);
free(ver);
- PyRun_SimpleString("import rlcompleter, readline\n"
- "readline.parse_and_bind('tab: complete')");
+ PyRun_SimpleString(
+ "import rlcompleter, readline\n"
+ "readline.parse_and_bind('tab: complete')");
}
if (PyRun_AnyFile(fp, pyfile)) {
printf("unknown python failure (?)\n");
return 1;
}
- Py_Finalize();
+ Py_Finalize();
#if PY_MAJOR_VERSION >= 3
for (int i = 1; i < argc; i++)
#include "log.h"
#include "zassert.h"
-#define ZLOG_FUNC(FUNCNAME) \
-void FUNCNAME(const char *format, ...) \
-{ \
- va_list args; \
- va_start(args, format); \
- vfprintf (stderr, format, args); \
- fputs ("\n", stderr); \
- va_end(args); \
-}
+#define ZLOG_FUNC(FUNCNAME) \
+ void FUNCNAME(const char *format, ...) \
+ { \
+ va_list args; \
+ va_start(args, format); \
+ vfprintf(stderr, format, args); \
+ fputs("\n", stderr); \
+ va_end(args); \
+ }
ZLOG_FUNC(zlog_err)
ZLOG_FUNC(zlog_warn)
ZLOG_FUNC(zlog_notice)
ZLOG_FUNC(zlog_debug)
-void
-_zlog_assert_failed (const char *assertion, const char *file,
- unsigned int line, const char *function)
+void _zlog_assert_failed(const char *assertion, const char *file,
+ unsigned int line, const char *function)
{
- fprintf(stderr, "Assertion `%s' failed in file %s, line %u, function %s",
+ fprintf(stderr,
+ "Assertion `%s' failed in file %s, line %u, function %s",
assertion, file, line, (function ? function : "?"));
abort();
}
-void memory_oom (size_t size, const char *name)
+void memory_oom(size_t size, const char *name)
{
abort();
}