Try fixing non-ASCII parameters in llama-cli on Windows
This commit is contained in:
parent
785a710085
commit
d57f289264
|
|
@ -45,6 +45,7 @@
|
|||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <shellapi.h>
|
||||
#else
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -60,6 +61,39 @@
|
|||
#pragma warning(disable: 4244 4267) // possible loss of data
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
void common_init_args(int & argc, char ** & argv) {
|
||||
int wargc;
|
||||
static std::vector<char*> argv_utf8;
|
||||
static std::vector<std::string> args_utf8;
|
||||
LPWSTR * wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);
|
||||
if (!wargv) return;
|
||||
|
||||
args_utf8.resize(wargc);
|
||||
argv_utf8.resize(wargc + 1);
|
||||
|
||||
for (int i = 0; i < wargc; ++i) {
|
||||
int size = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
|
||||
if (size > 0) {
|
||||
args_utf8[i].resize(size);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, &args_utf8[i][0], size, NULL, NULL);
|
||||
args_utf8[i].resize(size - 1);
|
||||
argv_utf8[i] = &args_utf8[i][0];
|
||||
}
|
||||
}
|
||||
argv_utf8[wargc] = nullptr;
|
||||
|
||||
argc = wargc;
|
||||
argv = argv_utf8.data();
|
||||
|
||||
LocalFree(wargv);
|
||||
}
|
||||
#else
|
||||
void common_init_args(int &, char ** &) {
|
||||
// no-op on non-Windows
|
||||
}
|
||||
#endif
|
||||
|
||||
common_time_meas::common_time_meas(int64_t & t_acc, bool disable) : t_start_us(disable ? -1 : ggml_time_us()), t_acc(t_acc) {}
|
||||
|
||||
common_time_meas::~common_time_meas() {
|
||||
|
|
|
|||
|
|
@ -582,6 +582,8 @@ struct common_params {
|
|||
// initializes the logging system and prints info about the build
|
||||
void common_init();
|
||||
|
||||
void common_init_args(int & argc, char **& argv);
|
||||
|
||||
std::string common_params_get_system_info(const common_params & params);
|
||||
|
||||
bool parse_cpu_range(const std::string & range, bool(&boolmask)[GGML_MAX_N_THREADS]);
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ struct cli_context {
|
|||
};
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
common_init_args(argc, argv);
|
||||
|
||||
common_params params;
|
||||
|
||||
params.verbosity = LOG_LEVEL_ERROR; // by default, less verbose logs
|
||||
|
|
|
|||
Loading…
Reference in New Issue