This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2goclient. from 3772ad2 src/onmainwindow.cpp: add (default) MacPorts prefix, /usr/local/bin and /opt/X11/bin to x2goclient's environment and child environments before starting xmodmap. Fixes: #1019. new 864a093 src/x2goutils.{cpp,h}: add new function add_to_path () to add multiple entries to a PATH-like string if they do not exist in there yet. new 2ace014 src/onmainwindow.cpp: replace old code to modify the PATH value with the new add_to_path () function. The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: debian/changelog | 4 +++ src/onmainwindow.cpp | 44 ++++--------------------- src/x2goutils.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/x2goutils.h | 12 +++++++ 4 files changed, 110 insertions(+), 38 deletions(-) -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 864a0938551d993397adc1d0f27c4a8ca421a771 Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Apr 9 08:36:40 2016 +0200 src/x2goutils.{cpp,h}: add new function add_to_path () to add multiple entries to a PATH-like string if they do not exist in there yet. --- debian/changelog | 2 ++ src/x2goutils.cpp | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/x2goutils.h | 12 ++++++++ 3 files changed, 102 insertions(+) diff --git a/debian/changelog b/debian/changelog index c058a99..6b16560 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium /opt/X11/bin to x2goclient's environment and child environments before starting xmodmap. Fixes: #1019. Requires a re-release of X2Go Client for OS X. + - src/x2goutils.{cpp,h}: add new function add_to_path () to add multiple + entries to a PATH-like string if they do not exist in there yet. [ Mike DePaulo ] * New upstream release (4.0.5.2): diff --git a/src/x2goutils.cpp b/src/x2goutils.cpp index 4a45102..31ac3ac 100644 --- a/src/x2goutils.cpp +++ b/src/x2goutils.cpp @@ -194,4 +194,92 @@ void show_XQuartz_generic_error (const QString &main_error, const QString &addit "or\n" "<center><b>/Applications/Utilities/XQuartz.app</b></center>")); } + +QString add_to_path (const QString &orig_path, const QStringList &add, const bool back) { + QString ret = orig_path; + std::vector<bool> found; + + QStringList orig_path_list = orig_path.split (":"); + + /* + * Clean up add list. We want to make sure no entry ends in a slash + * and skip empty entries. + */ + QStringList tmp_clean_add; + for (int i = 0; i < add.size (); ++i) { + if (!(add[i].isEmpty ())) { + if (add[i].right (1) == "/") { + QString tmp_elem = add[i].right (1); + + if (!(tmp_elem.isEmpty ())) { + tmp_clean_add.append (tmp_elem); + } + } + else { + tmp_clean_add.append (add[i]); + } + } + } + + /* Nothing to add, really... */ + if (tmp_clean_add.isEmpty ()) { + return (ret); + } + + /* Create unique array. */ + QStringList clean_add; + { + QStringList::const_iterator begin = tmp_clean_add.constBegin (), + end = tmp_clean_add.constEnd (); + for (QStringList::const_iterator cit = begin; cit != end; ++cit) { + bool tmp_found = false; + + for (QStringList::const_iterator cit2 = cit + 1; cit2 != end; ++cit2) { + if (*cit == *cit) { + tmp_found = true; + break; + } + } + + if (!tmp_found) { + clean_add.append (*cit); + } + } + } + + /* Nothing to add. */ + if (clean_add.isEmpty ()) { + return (ret); + } + + found.resize (clean_add.size (), false); + + for (int i = 0; i < orig_path_list.length (); ++i) { + for (int y = 0; y < clean_add.size (); ++y) { + if (!found[y]) { + if ((orig_path_list[i] == QString (clean_add[y])) || (orig_path_list[i] == QString (clean_add[y] + '/'))) { + found[y] = true; + break; + } + } + } + } + + if (back) { + for (int i = 0; i < clean_add.size (); ++i) { + if (!found[i]) { + ret.append (QString (":" + clean_add[i])); + } + } + } + else { + for (int i = (clean_add.size () - 1); i > 0; --i) { + if (!found[i]) { + ret.prepend (QString (clean_add[i] + ":")); + } + } + } + + return (ret); +} #endif /* defined (Q_OS_DARWIN) */ diff --git a/src/x2goutils.h b/src/x2goutils.h index af65663..e36203e 100644 --- a/src/x2goutils.h +++ b/src/x2goutils.h @@ -45,6 +45,18 @@ bool font_is_monospaced (const QFont &font); void show_XQuartz_not_found_error (); void show_XQuartz_start_error (); void show_XQuartz_generic_error (const QString &main_error, const QString &additional_info); + +/* + * Add a list of strings to a PATH value. + * + * If back is true (the default), each entry is (potentially) appended to the original + * PATH value, if not already existing within the original PATH value. + * Ex.: <orig_path>:<add_entry1>:<add_entry2>:... + * + * Otherwise, each entry is prepended to the original PATH value, if not already existing. + * Ex.: <add_entry1>:<add_entry2>:...:<orig_path> + */ +QString add_to_path (const QString &orig_path, const QStringList &add, const bool back = true); #endif /* defined (Q_OS_DARWIN) */ #endif /* !defined (X2GOUTILS_H) */ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 2ace014ccfdb7a16a956d4f1bb98b6eb8a284b8d Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Apr 9 08:38:30 2016 +0200 src/onmainwindow.cpp: replace old code to modify the PATH value with the new add_to_path () function. --- debian/changelog | 2 ++ src/onmainwindow.cpp | 44 ++++++-------------------------------------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6b16560..80d3c80 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium OS X. - src/x2goutils.{cpp,h}: add new function add_to_path () to add multiple entries to a PATH-like string if they do not exist in there yet. + - src/onmainwindow.cpp: replace old code to modify the PATH value with the + new add_to_path () function. [ Mike DePaulo ] * New upstream release (4.0.5.2): diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 4a48157..c7fffd7 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -5624,45 +5624,13 @@ void ONMainWindow::slotSetModMap() tmp_env.insert ("PATH", path_val); } else { - /* FIXME: split/clean this up. */ - /* Search for and add /opt/X11/bin if necessary. */ - QStringList tmp_path = path_val.split (":"); - bool xquartz_found = false, - macports_found = false, - local_found = false; - for (int i = 0; i < tmp_path.length (); ++i) { - if ((tmp_path[i] == QString ("/opt/X11/bin")) || (tmp_path[i] == QString ("/opt/X11/bin/"))) { - xquartz_found = true; - continue; - } - - if ((tmp_path[i] == QString ("/opt/local/bin")) || (tmp_path[i] == QString ("/opt/local/bin/"))) { - macports_found = true; - continue; - } - + /* Search for and add specific directories to the PATH value, if necessary. */ + QStringList to_back, to_front; + to_back << "/opt/X11/bin"; + to_front << "/opt/local/bin" << "/usr/local/bin"; - if ((tmp_path[i] == QString ("/usr/local/bin")) || (tmp_path[i] == QString ("/usr/local/bin/"))) { - local_found = true; - continue; - } - - if (xquartz_found && macports_found && local_found) { - break; - } - } - - if (!xquartz_found) { - path_val.append (":/opt/X11/bin"); - } - - if (!local_found) { - path_val.prepend ("/usr/local/bin:"); - } - - if (!macports_found) { - path_val.prepend ("/opt/local/bin:"); - } + path_val = add_to_path (path_val, to_back); + path_val = add_to_path (path_val, to_front, false); /* Insert will overwrite the value automatically. */ tmp_env.insert ("PATH", path_val); -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git