From d3cfb6ca2b7378a7f942d7f632b89e4c22cd595a Mon Sep 17 00:00:00 2001 From: Rotem Dan Date: Tue, 9 Apr 2024 18:33:32 +0300 Subject: [PATCH] main : set stdin to binary mode on Windows (#2025) --- examples/common.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/common.cpp b/examples/common.cpp index 9ab162a5..fad9a7c2 100644 --- a/examples/common.cpp +++ b/examples/common.cpp @@ -19,6 +19,11 @@ #pragma warning(disable: 4244 4267) // possible loss of data #endif +#ifdef _WIN32 +#include +#include +#endif + // Function to check if the next argument exists std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) { if (i + 1 < argc && argv[i + 1][0] != '-') { @@ -636,6 +641,10 @@ bool read_wav(const std::string & fname, std::vector& pcmf32, std::vector if (fname == "-") { { + #ifdef _WIN32 + _setmode(_fileno(stdin), _O_BINARY); + #endif + uint8_t buf[1024]; while (true) {