On Wed, Jun 20, 2007 at 09:44:12AM +0100, José Matos wrote:
> On Wednesday 20 June 2007 00:00:06 Enrico Forestieri wrote:
> > The attached patch fixes it. José, OK to commit?
> 
>   The patch seems right. If you someone to test this and guarantee that it 
> works (no need to be a developer) it can go in.

Here is an updated patch that also cures the following startup error
on *nix/cygwin:

Error returned from iconv
EILSEQ An invalid multibyte sequence has been encountered in the input.
When converting from UTF-8 to UCS-4LE.
Input: 0x2f 0x74 0x6d 0x70 0x2f 0x6f 0x6c 0xe0 0x2f 0x6c 0x79 0x78 0x5f 0x74 
0x6d 0x70 0x64 0x69 0x72 0x32 0x30 0x30 0x30 0x63 0x77 0x73 0x63 0x54 0x6c 0x2f 
0x6c 0x79 0x78 0x73 0x6f 0x63 0x6b 0x65 0x74

and this one on windows:

Error returned from iconv
EINVAL An incomplete multibyte sequence has been encountered in the input.
When converting from UTF-8 to UCS-4LE.
Input: 0x43 0x3a 0x2f 0x63 0x79 0x67 0x77 0x69 0x6e 0x2f 0x74 0x6d 0x70 0x2f 
0x6f 0x6c 0xe0

when the temp dir has nonascii chars. These errors are triggered by the
fact that setEnv() and addName() take utf8 strings as input and they are
instead passed local 8bit encoded strings. I doubt that anyone will test it
(see here: http://article.gmane.org/gmane.editors.lyx.general/39630)
so, José, take your responsibility and make a decision ;-)
I tested the patch and guarantee that it is correct ;-)

-- 
Enrico
Index: src/graphics/GraphicsConverter.cpp
===================================================================
--- src/graphics/GraphicsConverter.cpp  (revision 18837)
+++ src/graphics/GraphicsConverter.cpp  (working copy)
@@ -226,8 +226,8 @@ static string const move_file(string con
                return string();
 
        ostringstream command;
-       command << "fromfile = " << from_file << "\n"
-               << "tofile = "   << to_file << "\n\n"
+       command << "fromfile = utf8ToDefaultEncoding(" << from_file << ")\n"
+               << "tofile = utf8ToDefaultEncoding("   << to_file << ")\n\n"
                << "try:\n"
                << "  os.rename(fromfile, tofile)\n"
                << "except:\n"
@@ -323,7 +323,8 @@ static void build_script(FileName const 
        script << "infile = utf8ToDefaultEncoding("
                        << quoteName(from_file.absFilename(), quote_python)
                        << ")\n"
-                 "outfile = " << quoteName(outfile, quote_python) << "\n"
+                 "outfile = utf8ToDefaultEncoding("
+                       << quoteName(outfile, quote_python) << ")\n"
                  "shutil.copy(infile, outfile)\n";
 
        // Some converters (e.g. lilypond) can only output files to the
@@ -331,15 +332,16 @@ static void build_script(FileName const 
        // This has the added benefit that all other files that may be
        // generated by the converter are deleted when LyX closes and do not
        // clutter the real working directory.
-       script << "os.chdir(" << quoteName(onlyPath(outfile)) << ")\n";
+       script << "os.chdir(utf8ToDefaultEncoding("
+              << quoteName(onlyPath(outfile)) << "))\n";
 
        if (edgepath.empty()) {
                // Either from_format is unknown or we don't have a
                // converter path from from_format to to_format, so we use
                // the default converter.
                script << "infile = outfile\n"
-                      << "outfile = " << quoteName(to_file, quote_python)
-                      << '\n';
+                      << "outfile = utf8ToDefaultEncoding("
+                      << quoteName(to_file, quote_python) << ")\n";
 
                ostringstream os;
                os << support::os::python() << ' '
@@ -379,9 +381,12 @@ static void build_script(FileName const 
                outfile = addExtension(to_base.absFilename(), 
conv.To->extension());
 
                // Store these names in the python script
-               script << "infile = "      << quoteName(infile, quote_python) 
<< "\n"
-                         "infile_base = " << quoteName(infile_base, 
quote_python) << "\n"
-                         "outfile = "     << quoteName(outfile, quote_python) 
<< '\n';
+               script << "infile = utf8ToDefaultEncoding("
+                               << quoteName(infile, quote_python) << ")\n"
+                         "infile_base = utf8ToDefaultEncoding("
+                               << quoteName(infile_base, quote_python) << ")\n"
+                         "outfile = utf8ToDefaultEncoding("
+                               << quoteName(outfile, quote_python) << ")\n";
 
                // See comment about extra " quotes above (although that
                // applies only for the first loop run here).
Index: src/support/tempname.cpp
===================================================================
--- src/support/tempname.cpp    (revision 18837)
+++ src/support/tempname.cpp    (working copy)
@@ -81,9 +81,9 @@ int make_tempfile(char * templ)
 FileName const tempName(FileName const & dir, string const & mask)
 {
        string const tmpdir(dir.empty() ?
-                       package().temp_dir().toFilesystemEncoding() :
-                       dir.toFilesystemEncoding());
-       string tmpfl(addName(tmpdir, mask));
+                       package().temp_dir().absFilename() :
+                       dir.absFilename());
+       string tmpfl(to_filesystem8bit(from_utf8(addName(tmpdir, mask))));
 #if defined (HAVE_GETPID)
        tmpfl += convert<string>(getpid());
 #elif defined (HAVE__GETPID)
Index: src/ServerSocket.cpp
===================================================================
--- src/ServerSocket.cpp        (revision 18837)
+++ src/ServerSocket.cpp        (working copy)
@@ -62,7 +62,7 @@ ServerSocket::ServerSocket(LyXFunc * f, 
        // Needed by xdvi
        support::setEnv("XEDITOR", "lyxclient -g %f %l");
        // Needed by lyxclient
-       support::setEnv("LYXSOCKET", address_.toFilesystemEncoding());
+       support::setEnv("LYXSOCKET", address_.absFilename());
 
        theApp()->registerSocketCallback(
                fd_,

Reply via email to