#include <locale.h>
#endif
+#if _WIN32
+#include <io.h> /* for _setmode() */
+#include <fcntl.h> /* for _O_BINARY */
+#endif
+
static int getenv_int(const char *name)
{
char *value, *end;
return 2;
}
+#ifdef _WIN32
+ /* On Windows, set stdout and stderr to binary mode to avoid
+ outputting DOS line terminators */
+ _setmode(_fileno(stdout), _O_BINARY);
+ _setmode(_fileno(stderr), _O_BINARY);
+#endif
+
indent = getenv_int("JSON_INDENT");
if(indent < 0 || indent > 255) {
fprintf(stderr, "invalid value for JSON_INDENT: %d\n", indent);