]> git.lyx.org Git - lyx.git/blobdiff - src/support/filetools.cpp
tiger support on mac snow leopard, include Qt4 frameworks, smart build script with...
[lyx.git] / src / support / filetools.cpp
index ae9437f5296bb5abf578a468cb996d1b885f904b..7f00ebfb8cb1fbae95a0ee1b6d55feb5f7463d95 100644 (file)
@@ -130,21 +130,26 @@ string const quoteName(string const & name, quote_style style)
 {
        switch(style) {
        case quote_shell:
-               // This does not work for filenames containing " (windows)
-               // or ' (all other OSes). This can't be changed easily, since
-               // we would need to adapt the command line parser in
-               // Forkedcall::generateChild. Therefore we don't pass user
-               // filenames to child processes if possible. We store them in
-               // a python script instead, where we don't have these
-               // limitations.
+               // This does not work on native Windows for filenames
+               // containing the following characters < > : " / \ | ? *
+               // Moreover, it can't be made to work, as, according to
+               // http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
+               // those are reserved characters, and thus are forbidden.
+               // Please, also note that the command-line parser in
+               // ForkedCall::generateChild cannot deal with filenames
+               // containing " or ', therefore we don't pass user filenames
+               // to child processes if possible. We store them in a python
+               // script instead, where we don't have these limitations.
 #ifndef USE_QPROCESS
                return (os::shell() == os::UNIX) ?
-                       '\'' + name + '\'':
+                       '\'' + subst(name, "'", "\'\\\'\'") + '\'' :
                        '"' + name + '"';
 #else
                // According to the QProcess parser, a single double
                // quote is represented by three consecutive ones.
-               return '"' + subst(name, "\"", "\"\"\"") + '"';
+               // Here we simply escape the double quote and let our
+               // simple parser in Systemcall.cpp do the substitution.
+               return '"' + subst(name, "\"", "\\\"") + '"';
 #endif
        case quote_python:
                return "\"" + subst(subst(name, "\\", "\\\\"), "\"", "\\\"")
@@ -734,8 +739,7 @@ docstring const makeDisplayPath(string const & path, unsigned int threshold)
 bool readLink(FileName const & file, FileName & link)
 {
 #ifdef HAVE_READLINK
-       char linkbuffer[512];
-       // Should be PATH_MAX but that needs autconf support
+       char linkbuffer[PATH_MAX + 1];
        string const encoded = file.toFilesystemEncoding();
        int const nRead = ::readlink(encoded.c_str(),
                                     linkbuffer, sizeof(linkbuffer) - 1);