[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:45:09 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=0f36e04

The following commit has been merged in the master branch:
commit 0f36e0492c9546df3b5b97b7a203baad3ecfe578
Author: Robin Mills <robin at clanmills.com>
Date:   Sat Apr 25 19:04:26 2015 +0000

    #1065.  Fixing thread safety in fileProtocol.  Thank You, Max for reporting this.
---
 include/exiv2/futils.hpp | 10 --------
 src/futils.cpp           | 64 ++++++++++++++++++++++++------------------------
 2 files changed, 32 insertions(+), 42 deletions(-)

diff --git a/include/exiv2/futils.hpp b/include/exiv2/futils.hpp
index 6a9a616..266f36a 100644
--- a/include/exiv2/futils.hpp
+++ b/include/exiv2/futils.hpp
@@ -53,16 +53,6 @@ namespace Exiv2 {
     enum    EnVar       { envHTTPPOST = 0, envTIMEOUT = 1};
     //! the collection of protocols.
     enum    Protocol    { pFile = 0, pHttp, pFtp, pHttps, pSftp, pSsh, pFileUri, pDataUri, pStdin};
-    //! the dictionary type for the protcol identifer strings.
-    typedef std::map<std::string,Protocol>           protDict_t;
-    //! the dictionary iterator for protcol identifer strings.
-    typedef std::map<std::string,Protocol>::iterator protDict_i;
-#ifdef EXV_UNICODE_PATH
-    //! the dictionary type for the protcol identifer strings.
-    typedef std::map<std::wstring,Protocol> wprotDict_t;
-    //! the dictionary iterator for protcol identifer strings.
-    typedef std::map<std::wstring,Protocol>::iterator wprotDict_i;
-#endif
 // *********************************************************************
 // free functions
     /*!
diff --git a/src/futils.cpp b/src/futils.cpp
index 607e835..fefcf11 100644
--- a/src/futils.cpp
+++ b/src/futils.cpp
@@ -240,43 +240,43 @@ namespace Exiv2 {
 
     Protocol fileProtocol(const std::string& path) {
         Protocol result = pFile ;
-        static Exiv2::protDict_t protDict;
-        if (!protDict.size()) {
-             protDict["http://" ]   = pHttp;
-             protDict["ftp://"  ]   = pFtp;
-             protDict["https://"]   = pHttps;
-             protDict["sftp://" ]   = pSftp;
-             protDict["ssh://"  ]   = pSsh;
-             protDict["file://" ]   = pFileUri;
-             protDict["data:"   ]   = pDataUri;
-             protDict["-"       ]   = pStdin;
-        }
-        for (Exiv2::protDict_i it = protDict.begin(); it != protDict.end(); it++) {
-            if (path.find(it->first) == 0)
-                 result = it->second;
-        }
+        struct {
+        	std::string name ;
+        	Protocol    prot ;
+        } prots[] =
+        { { "http://"   ,pHttp     }
+        , { "ftp://"    ,pFtp      }
+        , { "sftp://"   ,pSftp     }
+        , { "ssh://"    ,pSsh      }
+        , { "file://"   ,pFileUri  }
+        , { "data://"   ,pDataUri  }
+        , { "-"         ,pStdin    }
+        };
+        for ( size_t i = 0 ; result == pFile && i < sizeof(prots)/sizeof(prots[0]) ; i ++ )
+        	if ( path.find(prots[i].name) == 0 )
+        		result = prots[i].prot;
+
         return result;
     } // fileProtocol
 #ifdef EXV_UNICODE_PATH
     Protocol fileProtocol(const std::wstring& wpath) {
         Protocol result = pFile ;
-        static wprotDict_t protDict;
-        if (!protDict.size()) {
-             protDict[L"http://"  ]  = pHttp;
-             protDict[L"ftp://"   ]  = pFtp;
-             protDict[L"https://" ]  = pHttps;
-             protDict[L"sftp://"  ]  = pSftp;
-             protDict[L"ssh://"   ]  = pSsh;
-             protDict[L"file:///" ]  = pFileUri;
-             protDict[L"data:"    ]  = pDataUri;
-             protDict[L"-"        ]  = pStdin;
-        }
-        for (wprotDict_i it = protDict.begin(); it != protDict.end(); it++) {
-            if (wpath.find(it->first) == 0) {
-                 result = it->second;
-                 break;
-            }
-        }
+        struct {
+        	std::wstring wname ;
+        	Protocol      prot ;
+        } prots[] =
+        { { L"http://"   ,pHttp     }
+        , { L"ftp://"    ,pFtp      }
+        , { L"sftp://"   ,pSftp     }
+        , { L"ssh://"    ,pSsh      }
+        , { L"file://"   ,pFileUri  }
+        , { L"data://"   ,pDataUri  }
+        , { L"-"         ,pStdin    }
+        };
+        for ( size_t i = 0 ; result == pFile && i < sizeof(prots)/sizeof(prots[0]) ; i ++ )
+        	if ( wpath.find(prots[i].wname) == 0 )
+        		result = prots[i].prot;
+
         return result;
     } // fileProtocol
 #endif

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list