diff --git a/src/main.cpp b/src/main.cpp index b72725372b..5c4fb46845 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,7 +35,7 @@ int main(int argc, char * argv[]) // early as possible. lyx::lyxerr.setStream(cerr); - lyx::support::os::init(argc, argv); + lyx::support::os::init(argc, &argv); lyx::LyX the_lyx_instance; diff --git a/src/support/os.h b/src/support/os.h index 73eb86d7f3..9b38e4e44e 100644 --- a/src/support/os.h +++ b/src/support/os.h @@ -38,7 +38,7 @@ enum file_access { }; /// Do some work just once. -void init(int argc, char * argv[]); +void init(int argc, char ** argv[]); /// Returns the i-th program argument in utf8 encoding. std::string utf8_argv(int i); diff --git a/src/support/os_cygwin.cpp b/src/support/os_cygwin.cpp index 3464c04d78..0d30f5b17d 100644 --- a/src/support/os_cygwin.cpp +++ b/src/support/os_cygwin.cpp @@ -210,10 +210,10 @@ BOOL terminate_handler(DWORD event) } // namespace anon -void init(int argc, char * argv[]) +void init(int argc, char ** argv[]) { argc_ = argc; - argv_ = argv; + argv_ = *argv; // Set environment's default locale setlocale(LC_ALL, ""); diff --git a/src/support/os_unix.cpp b/src/support/os_unix.cpp index 9109fbb586..7afa5db48e 100644 --- a/src/support/os_unix.cpp +++ b/src/support/os_unix.cpp @@ -45,10 +45,10 @@ char ** argv_ = 0; } // namespace anon -void init(int argc, char * argv[]) +void init(int argc, char ** argv[]) { argc_ = argc; - argv_ = argv; + argv_ = *argv; // Set environment's default locale setlocale(LC_ALL, ""); diff --git a/src/support/os_win32.cpp b/src/support/os_win32.cpp index 292555d6c7..e54c95926f 100644 --- a/src/support/os_win32.cpp +++ b/src/support/os_win32.cpp @@ -99,7 +99,7 @@ BOOL terminate_handler(DWORD event) } // namespace anon -void init(int argc, char * argv[]) +void init(int argc, char ** argv[]) { /* Note from Angus, 17 Jan 2005: * @@ -158,6 +158,22 @@ void init(int argc, char * argv[]) */ +#if defined(_MSC_VER) && (_MSC_VER >= 1900) + // Removing an argument from argv leads to an assertion on Windows + // when compiling with MSVC 2015 in debug mode (see bug #10440). + // To avoid this we make a copy of the array of pointers. + char ** newargv = (char **) malloc((argc + 1) * sizeof(char *)); + if (newargv) { + memcpy(newargv, *argv, (argc + 1) * sizeof(char *)); + *argv = newargv; + } else { + lyxerr << "LyX warning: Cannot make a copy of " + "command line arguments!" + << endl; + } +#endif + + // Get the wide program arguments array #if defined(_MSC_VER) && (_MSC_VER >= 1900) argv_ = CommandLineToArgvW(GetCommandLineW(), &argc_); diff --git a/src/tests/check_layout.cpp b/src/tests/check_layout.cpp index 318ae4863f..45d019de0f 100644 --- a/src/tests/check_layout.cpp +++ b/src/tests/check_layout.cpp @@ -115,7 +115,7 @@ bool test_Layout(string const & input, string const & output) int main(int argc, char * argv[]) { - os::init(argc, argv); + os::init(argc, &argv); lyxerr.setStream(cerr); if (argc < 2 || argc > 3) { cerr << "Usage: " << argv[0] << " []\n"; diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp index 7a6bbb0412..1e56c44bf9 100644 --- a/src/tex2lyx/tex2lyx.cpp +++ b/src/tex2lyx/tex2lyx.cpp @@ -1178,7 +1178,7 @@ int main(int argc, char * argv[]) lyx::lyxerr.setStream(cerr); - os::init(argc, argv); + os::init(argc, &argv); lyx::TeX2LyXApp app(argc, argv); return app.exec(); diff --git a/status.22x b/status.22x index d7a5bb9136..1151319ec5 100644 --- a/status.22x +++ b/status.22x @@ -96,6 +96,9 @@ What's new * DOCUMENT INPUT/OUTPUT +- Conversion of files using the command line (e.g. for batch processing) is + again possible on Windows (bug 10440). + - Fix nested language handling with polyglossia (bug 9633). - Fix usage of multiple varieties of the same polyglossia language.