]> git.lyx.org Git - lyx.git/blobdiff - src/client/client.cpp
Fix bug #12561
[lyx.git] / src / client / client.cpp
index 4d7eea53f6678f0f303ae40f43d18865951516c4..0a80107009020a7a8e1d6dba4392cc23d4583817 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <config.h>
 
+#include "LyXRC.h"
+
 #include "support/ConsoleApplication.h"
 #include "support/debug.h"
 #include "support/FileName.h"
@@ -19,8 +21,7 @@
 #include "support/lstrings.h"
 #include "support/Messages.h"
 #include "support/unicode.h"
-
-#include <boost/scoped_ptr.hpp>
+#include "support/unique_ptr.h"
 
 // getpid(), getppid()
 #ifdef HAVE_SYS_TYPES_H
 #include <map>
 #include <iostream>
 
+
 using namespace std;
 using namespace lyx::support;
 
-using ::boost::scoped_ptr;
-
 namespace lyx {
 
-// Dummy LyXRC support
-struct LyXRC {
-       string icon_set;
-} lyxrc;
+// Required global variables
+bool verbose = false;
+LyXRC lyxrc;
 
 // Keep the linker happy on Windows
 void lyx_exit(int)
@@ -94,14 +93,6 @@ Messages const & getMessages(string const &)
 
 namespace support {
 
-string itoa(unsigned int i)
-{
-       char buf[20];
-       sprintf(buf, "%d", i);
-       return buf;
-}
-
-
 /// Returns the absolute pathnames of all lyx local sockets in
 /// file system encoding.
 /// Parts stolen from lyx::support::DirList().
@@ -349,10 +340,10 @@ void LyXDataSocket::writeln(string const & line)
        string linen(line + '\n');
        int size = linen.size();
        int written = ::write(fd_, linen.c_str(), size);
-       if (written < size) { // Allways mean end of connection.
+       if (written < size) { // Always mean end of connection.
                if ((written == -1) && (errno == EPIPE)) {
                        // The program will also receive a SIGPIPE
-                       // that must be catched
+                       // that must be caught
                        cerr << "lyxclient: connection closed while writing."
                             << endl;
                } else {
@@ -426,7 +417,7 @@ bool CmdLineParser::parse(int argc, char * argv[])
 
 namespace cmdline {
 
-    docstring mainTmp(from_ascii("/tmp"));
+docstring mainTmp(from_ascii("/tmp"));
 
 
 class StopException : public exception
@@ -456,8 +447,8 @@ void usage()
          "lyxclient will connect only to a lyx with the specified pid. Options -c and -g\n"
          "cannot be set simultaneoulsly. If no -c or -g options are given, lyxclient\n"
          "will read commands from standard input and disconnect when command read is BYE:\n"
-      "\n"
-      "System directory is: " << to_utf8(cmdline::mainTmp)
+         "\n"
+         "System directory is: " << to_utf8(cmdline::mainTmp)
           << endl;
 }
 
@@ -470,7 +461,7 @@ int h(vector<docstring> const &)
 
 
 docstring clientName =
-       from_ascii(itoa(::getppid()) + ">" + itoa(::getpid()));
+       from_ascii(to_string(::getppid()) + ">" + to_string(::getpid()));
 
 int n(vector<docstring> const & arg)
 {
@@ -506,9 +497,11 @@ int g(vector<docstring> const & arg)
                     << endl;
                return -1;
        }
-       singleCommand = "LYXCMD:server-goto-file-row "
-               + arg[0] + ' '
-               + arg[1];
+       singleCommand = "LYXCMD:command-sequence "
+               "server-goto-file-row "
+                       + arg[0] + ' '
+                       + arg[1] + "; " +
+               "lyx-activate";
        return 2;
 }
 
@@ -524,7 +517,7 @@ int a(vector<docstring> const & arg)
                     << endl;
                return -1;
        }
-       // -a supercedes LYXSOCKET environment variable
+       // -a supersedes LYXSOCKET environment variable
        serverAddress = arg[0];
        return 1;
 }
@@ -618,7 +611,7 @@ int LyXClientApp::run()
                return EXIT_FAILURE;
        }
 
-       scoped_ptr<LyXDataSocket> server;
+       unique_ptr<LyXDataSocket> server;
 
        if (!cmdline::serverAddress.empty()) {
                server.reset(new LyXDataSocket(FileName(to_utf8(cmdline::serverAddress))));
@@ -723,13 +716,3 @@ int main(int argc, char * argv[])
        return app.exec();
 }
 
-
-namespace boost {
-
-void assertion_failed(char const* a, char const* b, char const* c, long d)
-{
-       lyx::lyxerr << "Assertion failed: " << a << ' ' << b << ' ' << c << ' '
-               << d << '\n';
-}
-
-} // namespace boost