[148469] trunk/dports/net/libproxy

jeremyhu at macports.org jeremyhu at macports.org
Mon May 9 23:35:49 PDT 2016


Revision: 148469
          https://trac.macports.org/changeset/148469
Author:   jeremyhu at macports.org
Date:     2016-05-09 23:35:49 -0700 (Mon, 09 May 2016)
Log Message:
-----------
libproxy: Fix build failures on systems without C++11 (#51309)

Modified Paths:
--------------
    trunk/dports/net/libproxy/Portfile

Added Paths:
-----------
    trunk/dports/net/libproxy/files/patch-libproxy-modules-config_kde.cpp.diff

Modified: trunk/dports/net/libproxy/Portfile
===================================================================
--- trunk/dports/net/libproxy/Portfile	2016-05-10 05:48:48 UTC (rev 148468)
+++ trunk/dports/net/libproxy/Portfile	2016-05-10 06:35:49 UTC (rev 148469)
@@ -10,6 +10,7 @@
 github.setup        libproxy libproxy 0.4.13
 name                libproxy
 epoch               1
+revision            2
 categories          net
 maintainers         devans openmaintainer
 platforms           darwin
@@ -28,7 +29,8 @@
 
 patchfiles          patch-libproxy-cmake.diff \
                     patch-libproxy-test-CMakeLists.txt.diff \
-                    patch-bindings-perl-src-CMakeLists.txt.diff
+                    patch-bindings-perl-src-CMakeLists.txt.diff \
+                    patch-libproxy-modules-config_kde.cpp.diff
 
 depends_build-append \
                     port:pkgconfig

Added: trunk/dports/net/libproxy/files/patch-libproxy-modules-config_kde.cpp.diff
===================================================================
--- trunk/dports/net/libproxy/files/patch-libproxy-modules-config_kde.cpp.diff	                        (rev 0)
+++ trunk/dports/net/libproxy/files/patch-libproxy-modules-config_kde.cpp.diff	2016-05-10 06:35:49 UTC (rev 148469)
@@ -0,0 +1,170 @@
+From f557862be9de724eac1ec37e711221feb28fc4d7 Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
+Date: Mon, 9 May 2016 23:29:51 -0700
+Subject: [PATCH] Revert "config_kde: Add a basic cache and invalidation"
+
+https://github.com/libproxy/libproxy/issues/29
+https://trac.macports.org/ticket/51309
+
+This reverts commit 28620c7aeb3d1b54c83caf84778df8e095490820.
+---
+ libproxy/modules/config_kde.cpp | 98 +++++------------------------------------
+ 1 file changed, 10 insertions(+), 88 deletions(-)
+
+diff --git libproxy/modules/config_kde.cpp libproxy/modules/config_kde.cpp
+index 515aaac..2211487 100644
+--- libproxy/modules/config_kde.cpp
++++ libproxy/modules/config_kde.cpp
+@@ -18,13 +18,9 @@
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ******************************************************************************/
+ 
+-#include <sys/stat.h>
+-#include <unistd.h>
+-
+ #include <algorithm>
+ #include <cstdlib>
+ #include <cstdio>
+-#include <sstream>
+ 
+ #include "../extension_config.hpp"
+ using namespace libproxy;
+@@ -32,18 +28,11 @@ using namespace libproxy;
+ class kde_config_extension : public config_extension {
+ public:
+     kde_config_extension()
+-        : cache_time(0)
+     {
+         try {
+             // Try the KF5 one first
+             command = "kreadconfig5";
+-            command_output("kreadconfig5 --key nonexistant");
+-
+-            try {
+-                parse_dir_list(command_output("qtpaths --paths GenericConfigLocation"));
+-            }
+-            catch(...) {}
+-
++            kde_config_val("proxyType", "-1");
+             return; // Worked
+         }
+         catch(...) {}
+@@ -51,13 +40,7 @@ public:
+         try {
+             // The KDE4 one next
+             command = "kreadconfig";
+-            command_output(command);
+-
+-            try {
+-                parse_dir_list(command_output("kde4-config --path config"));
+-            }
+-            catch(...) {}
+-
++            kde_config_val("proxyType", "-1");
+             return; // Worked
+         }
+         catch(...) {}
+@@ -134,7 +117,11 @@ public:
+ 	}
+ 
+ private:
+-    string command_output(const string &cmdline) throw (runtime_error) {
++    // Neither key nor def must contain '
++    string kde_config_val(const string &key, const string &def) throw (runtime_error) {
++        string cmdline =
++                command + " --file kioslaverc --group 'Proxy Settings' --key '" + key + "' --default '" + def + "'";
++
+         FILE *pipe = popen(cmdline.c_str(), "r");
+         if (!pipe)
+             throw runtime_error("Unable to run command");
+@@ -142,84 +129,19 @@ private:
+         char buffer[128];
+         string result = "";
+         while (!feof(pipe)) {
+-            if (fgets(buffer, 128, pipe) != NULL)
+-                result += buffer; // TODO: If this throws bad_alloc, pipe is leaked
++         if (fgets(buffer, 128, pipe) != NULL)
++             result += buffer; // TODO: If this throws bad_alloc, pipe is leaked
+         }
+ 
+-        if(pclose(pipe) != 0)
+-            throw runtime_error("Command failed");
++        pclose(pipe);
+ 
+         // Trim newlines and whitespace at end
+         result.erase(result.begin() + (result.find_last_not_of(" \n\t")+1), result.end());
+-
+         return result;
+     }
+ 
+-    // Neither key nor def must contain '
+-    string kde_config_val(const string &key, const string &def) throw (runtime_error) {
+-        if (cache_needs_refresh())
+-            cache.clear();
+-        else
+-            try {
+-                // Already in cache?
+-                return cache.at(key);
+-            } catch(...) {} // Not in cache
+-
+-        string result = command_output(
+-                command + " --file kioslaverc --group 'Proxy Settings' --key '" + key + "' --default '" + def + "'");
+-
+-        // Add result to cache
+-        cache[key] = result;
+-
+-        return result;
+-    }
+-
+-    // Used for cache invalidation
+-    struct configfile {
+-        string path;
+-        time_t mtime; // 0 means it doesn't exist
+-    };
+-
+-    // Parses output of qtpaths/kde4-config to fill config_locs
+-    void parse_dir_list(const string &dirs) {
+-        string config_path;
+-        stringstream config_paths_stream(dirs);
+-
+-        // Try each of the listed folders, seperated by ':'
+-        while (getline(config_paths_stream, config_path, ':')) {
+-            configfile config_loc; config_loc.path = config_path + "/kioslaverc";
+-            config_locs.push_back(config_loc);
+-        }
+-    }
+-
+-    // If any of the locations in config_locs changed (different mtime),
+-    // update config_locs and return true.
+-    bool cache_needs_refresh() {
+-        // Play safe here, if we can't determine the location,
+-        // don't cache at all.
+-        bool needs_refresh = config_locs.empty();
+-        struct stat config_info;
+-
+-        for (unsigned int i = 0; i < config_locs.size(); ++i) {
+-            configfile &config = config_locs[i];
+-            time_t current_mtime = stat(config.path.c_str(), &config_info) == 0 ? config_info.st_mtime : 0;
+-            if (config.mtime != current_mtime) {
+-                config.mtime = current_mtime;
+-                needs_refresh = true;
+-            }
+-        }
+-
+-        return needs_refresh;
+-    }
+-
+     // Whether to use kreadconfig or kreadconfig5
+     string command;
+-    // When the cache was flushed last
+-    time_t cache_time;
+-    // Cache for config values
+-    map<string, string> cache;
+-    // State of the config files at the time of the last cache flush
+-    vector<configfile> config_locs;
+ };
+ 
+ MM_MODULE_INIT_EZ(kde_config_extension, getenv("KDE_FULL_SESSION"), NULL, NULL);
+-- 
+2.8.2
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160509/028c5cea/attachment.html>


More information about the macports-changes mailing list