William A. Rowe, Jr. wrote:

This is exactly my desired solution. If you would like to
submit your patch to the list (submissions by reference aren't
accepted without extra hassles) I would very much like to adopt it. (Especially as opposed to reinventing it.)

Ok, patch attached.

You can also find the complete file TSVN uses here:
<https://svn.collab.net/repos/tortoisesvn/trunk/ext/apr-iconv_patch/lib/iconv_module.c>

Stefan

--
       ___
  oo  // \\      "De Chelonian Mobile"
 (_,\/ \_/ \     TortoiseSVN
   \ \_/_\_/>    The coolest Interface to (Sub)Version Control
   /_/   \_\     http://tortoisesvn.tigris.org
Index: lib/iconv_module.c
===================================================================
--- lib/iconv_module.c  (revision 159498)
+++ lib/iconv_module.c  (working copy)
@@ -52,10 +52,46 @@
 
 #define APR_ICONV_PATH "APR_ICONV" API_STRINGIFY(API_MAJOR_VERSION) "_PATH"
 
+#ifdef WIN32
+char moduledir1[APR_PATH_MAX] = {0};
+char moduledir2[APR_PATH_MAX] = {0};
+
+BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID lpvReserved)
+{
+       char * dirend;
+       if (fdwReason == DLL_PROCESS_ATTACH)
+       {
+               ZeroMemory(moduledir1, APR_PATH_MAX);
+               ZeroMemory(moduledir2, APR_PATH_MAX);
+               GetModuleFileName(hInst, moduledir1, APR_PATH_MAX);
+               strcpy(moduledir2, moduledir1);
+               dirend = strrchr(moduledir1, '\\');
+               if (dirend)
+               {
+                       *dirend = 0;
+                       strcat(moduledir1, "\\iconv");
+               }
+               dirend = strrchr(moduledir2, '\\');
+               if (dirend)
+               {
+                       *dirend = 0;
+                       dirend = strrchr(moduledir2, '\\');
+                       if (dirend)
+                       {
+                               *dirend = 0;
+                               strcat(moduledir2, "\\iconv");
+                       }
+               }
+       }
+       return TRUE;
+}
+
+#endif
+
 static apr_status_t
 iconv_getpathname(char *buffer, const char *dir, const char *name, apr_pool_t 
*ctx)
 {
-        apr_status_t rv;
+    apr_status_t rv;
        apr_finfo_t sb;
 
        apr_snprintf(buffer, APR_PATH_MAX, "%s/%s.so", dir, name);
@@ -96,7 +132,20 @@
         while (0 != (*ptr++ = apr_tolower(*name++)))
             ;
 
-        if (!apr_env_get(&ptr, APR_ICONV_PATH, subpool)
+#ifdef WIN32
+               if (iconv_getpathname(buf, moduledir2, buffer, subpool) == 0)
+               {
+                       apr_pool_destroy(subpool);
+                       return APR_SUCCESS;
+               }
+               if (iconv_getpathname(buf, moduledir1, buffer, subpool) == 0)
+               {
+                       apr_pool_destroy(subpool);
+                       return APR_SUCCESS;
+               }
+#endif
+
+        if (!apr_env_get(&ptr, "APR_ICONV_PATH", subpool)
             && !apr_filepath_list_split(&pathelts, ptr, subpool))
         {
             int i;

Reply via email to