From 3441298ed44e1a00f2c71b73a582755d7bda7cd5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 15 Feb 2013 14:12:46 +0100 Subject: Better fix for Bug #911146 (Inkscape reads .eps files from /tmp instead of the current directory) by Michael Karcher. (bzr r12127) --- src/extension/implementation/script.cpp | 9 ++++++++- src/extension/system.cpp | 34 --------------------------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index d3aeace55..4af778e04 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -956,7 +956,14 @@ int Script::execute (const std::list &in_command, // assemble the rest of argv std::copy(in_params.begin(), in_params.end(), std::back_inserter(argv)); if (!filein.empty()) { - argv.push_back(filein); + if(Glib::path_is_absolute(filein)) + argv.push_back(filein); + else { + std::vector buildargs; + buildargs.push_back(Glib::get_current_dir()); + buildargs.push_back(filein); + argv.push_back(Glib::build_filename(buildargs)); + } } int stdout_pipe, stderr_pipe; diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 60cd21d71..a9ca5c456 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -69,34 +69,6 @@ static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementatio */ SPDocument *open(Extension *key, gchar const *filename) { - // Convert to absolute pathname to tolerate chdir(). - bool relpath = (filename[0] != '/'); -#ifdef WIN32 - relpath &= (filename[0] != '\\') && !(isalpha(filename[0]) && (filename[1] == ':')); -#endif - - // Do not consider an URI as a relative path. - if (relpath) { - gchar const * cp = filename; - - while (isalpha(*cp) || isdigit(*cp) || *cp == '+' || *cp == '-' || *cp == '.') - cp++; - - relpath = *cp != ':' || cp[1] != '/' || cp[2] != '/'; - } - - if (relpath) { - gchar * curdir = NULL; -#ifndef WIN32 - curdir = getcwd(NULL, 0); -#else - curdir = _getcwd(NULL, 0); -#endif - - filename = g_build_filename(curdir, filename, NULL); - free(curdir); - } - Input *imod = NULL; if (key == NULL) { @@ -138,9 +110,6 @@ SPDocument *open(Extension *key, gchar const *filename) } if (!imod->prefs(filename)) { - if (relpath){ - free((void *) filename); - } return NULL; } @@ -163,9 +132,6 @@ SPDocument *open(Extension *key, gchar const *filename) imod->set_gui(true); } - if (relpath){ - free((void *) filename); - } return doc; } -- cgit v1.2.3