]> git.lyx.org Git - features.git/commitdiff
backport fix for bug #10440
authorUwe Stöhr <uwestoehr@lyx.org>
Thu, 20 Apr 2017 20:20:50 +0000 (22:20 +0200)
committerUwe Stöhr <uwestoehr@lyx.org>
Thu, 20 Apr 2017 20:20:50 +0000 (22:20 +0200)
thanks Enrico!

src/main.cpp
src/support/os.h
src/support/os_cygwin.cpp
src/support/os_unix.cpp
src/support/os_win32.cpp
src/tests/check_layout.cpp
src/tex2lyx/tex2lyx.cpp
status.22x

index b72725372be83e04874a17570fae7441fc19ef84..5c4fb468459dbc3fa2a7ab12bbf418d1b6f7674e 100644 (file)
@@ -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;
 
index 73eb86d7f331c51853fb5e972d5cb9cea038d6f5..9b38e4e44ee0272de8b5caf9be74e195ccc6ec5a 100644 (file)
@@ -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);
index 3464c04d785142fd4a4db3e10f686747addceef8..0d30f5b17d01904a47e3d7fdee0cbbfc966139c4 100644 (file)
@@ -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, "");
index 9109fbb58648c0d9cb3e945446718070be939b81..7afa5db48e5594c41b4de0bc7d6ee889cd294cd8 100644 (file)
@@ -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, "");
index 292555d6c744bb55046699832922fce1027ba093..e54c95926f885bbb53e5492e39e7bb02e54449c9 100644 (file)
@@ -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_);
index 318ae4863f9837503ca236391156c52db43c76fa..45d019de0febb90cc0e1fa3689393add59bf3793 100644 (file)
@@ -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] << " <input layout file> [<output layout file>]\n";
index 7a6bbb0412f0eba80c8c0f692869865f8460d1fc..1e56c44bf9d6e460cf0357b8f8cd03eb4a63d03a 100644 (file)
@@ -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();
index d7a5bb91364368cec52c8bab7aa779aa65780a7f..1151319ec56fd8e3fa951011f27e145b44357193 100644 (file)
@@ -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.