Main.cpp (getdp-3.4.0-source.tgz) | : | Main.cpp (getdp-3.5.0-source.tgz) | ||
---|---|---|---|---|
// GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege | // GetDP - Copyright (C) 1997-2022 P. Dular and C. Geuzaine, University of Liege | |||
// | // | |||
// See the LICENSE.txt file for license information. Please report all | // See the LICENSE.txt file for license information. Please report all | |||
// issues on https://gitlab.onelab.info/getdp/getdp/issues. | // issues on https://gitlab.onelab.info/getdp/getdp/issues. | |||
#include <stdio.h> | #include <stdio.h> | |||
#include "MainKernel.h" | #include "MainKernel.h" | |||
#include "Message.h" | #include "Message.h" | |||
#include "GetDPConfig.h" | #include "GetDPConfig.h" | |||
#include "ProData.h" | #include "ProData.h" | |||
#include "getdp.h" | #include "getdp.h" | |||
skipping to change at line 28 | skipping to change at line 28 | |||
// using wmain() with the mingw compilers requires adding the "-municode" linker | // using wmain() with the mingw compilers requires adding the "-municode" linker | |||
// flag | // flag | |||
#include <windows.h> | #include <windows.h> | |||
#include <wchar.h> | #include <wchar.h> | |||
static char *toUTF8(wchar_t *src) | static char *toUTF8(wchar_t *src) | |||
{ | { | |||
if(!src) return nullptr; | if(!src) return nullptr; | |||
size_t srclen = wcslen(src); | size_t srclen = wcslen(src); | |||
int len = WideCharToMultiByte(CP_UTF8, 0, src, srclen, 0, 0, nullptr, nullptr) | int len = | |||
; | WideCharToMultiByte(CP_UTF8, 0, src, srclen, 0, 0, nullptr, nullptr); | |||
char *out = new char[len + 1]; | char *out = new char[len + 1]; | |||
if(out) { | if(out) { | |||
WideCharToMultiByte(CP_UTF8, 0, src, srclen, out, len, nullptr, nullptr); | WideCharToMultiByte(CP_UTF8, 0, src, srclen, out, len, nullptr, nullptr); | |||
out[len] = '\0'; | out[len] = '\0'; | |||
} | } | |||
return out; | return out; | |||
} | } | |||
int wmain(int argc, wchar_t *wargv[], wchar_t *envp[]) | int wmain(int argc, wchar_t *wargv[], wchar_t *envp[]) | |||
{ | { | |||
char **argv = new char*[argc + 1]; | char **argv = new char *[argc + 1]; | |||
for(int i = 0; i < argc; i++) | for(int i = 0; i < argc; i++) argv[i] = toUTF8(wargv[i]); | |||
argv[i] = toUTF8(wargv[i]); | ||||
argv[argc] = nullptr; | argv[argc] = nullptr; | |||
#else | #else | |||
int main(int argc, char **argv) | int main(int argc, char **argv) | |||
{ | { | |||
#endif | #endif | |||
#if defined(HAVE_KERNEL) | #if defined(HAVE_KERNEL) | |||
Message::SetExitOnError(1); | Message::SetExitOnError(1); | |||
return MainKernel(argc, argv); | return MainKernel(argc, argv); | |||
#else | #else | |||
Init_ProblemStructure(); | Init_ProblemStructure(); | |||
Read_ProblemPreamble(); | Read_ProblemPreamble(); | |||
if(argc > 1) | if(argc > 1) Read_ProblemStructure(argv[1]); | |||
Read_ProblemStructure(argv[1]); | ||||
Finalize_ProblemStructure(); | Finalize_ProblemStructure(); | |||
Print_ProblemStructure(); | Print_ProblemStructure(); | |||
#endif | #endif | |||
#if 0 // debug memory leaks | #if 0 // debug memory leaks | |||
for(int i = 0; i < 100; i++){ | for(int i = 0; i < 100; i++){ | |||
printf("solving problem %d\n", i); | printf("solving problem %d\n", i); | |||
MainKernel(argc, argv); | MainKernel(argc, argv); | |||
} | } | |||
#endif | #endif | |||
End of changes. 4 change blocks. | ||||
8 lines changed or deleted | 6 lines changed or added |