← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug1058231 into lp:zorba

 

Rodolfo Ochoa has proposed merging lp:~zorba-coders/zorba/bug1058231 into lp:zorba.

Commit message:
The problem was in the path from the process, instead of using the path of zorba_simplestore.dll Zorba gather the path of the main EXE.

This problem is not only from WinXP.

Requested reviews:
  Cezar Andrei (cezar-andrei)
  Chris Hillery (ceejatec)
Related bugs:
  Bug #1058231 in Zorba: "Can´t get Zorba Java API to work under Win XP"
  https://bugs.launchpad.net/zorba/+bug/1058231

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug1058231/+merge/129531

The problem was in the path from the process, instead of using the path of zorba_simplestore.dll Zorba gather the path of the main EXE.

This problem is not only from WinXP.

-- 
https://code.launchpad.net/~zorba-coders/zorba/bug1058231/+merge/129531
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/expression/pragma.cpp'
--- src/compiler/expression/pragma.cpp	2012-06-29 17:19:26 +0000
+++ src/compiler/expression/pragma.cpp	2012-10-12 22:54:28 +0000
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include "stdafx.h"
 #include "pragma.h"
 #include "zorbatypes/rchandle.h"
 #include "store/api/item.h"

=== modified file 'src/context/root_static_context.cpp'
--- src/context/root_static_context.cpp	2012-10-08 12:09:36 +0000
+++ src/context/root_static_context.cpp	2012-10-12 22:54:28 +0000
@@ -130,10 +130,12 @@
   std::vector<zstring> lRootURIPath;
   std::vector<zstring> lRootLibPath;
 #ifdef WIN32
+  #define MAX_VAR_SIZE 32767
   // compute the relative path to zorba_simplestore.dll (this dll)
   WCHAR  wdll_path[1024];
   DWORD dll_path_size;
-  dll_path_size = GetModuleFileNameW(NULL,
+  HMODULE h_module = GetModuleHandleW (L"zorba_simplestore");
+  dll_path_size = GetModuleFileNameW(h_module,
                                      wdll_path,
                                      sizeof(wdll_path)/sizeof(wdll_path[0]));
   if(dll_path_size)
@@ -166,7 +168,65 @@
       }
     }
   }
+
+  // get a relative path from the environment for URI
+  wchar_t env_var[MAX_VAR_SIZE];
+  DWORD path_size = GetEnvironmentVariableW (L"ZORBA_URI_DIRS", 
+                                             env_var,
+                                             MAX_VAR_SIZE );
+  if (path_size)
+  {
+    char  dll_path[MAX_VAR_SIZE];
+    WideCharToMultiByte(CP_UTF8,
+                        0,
+                        env_var,
+                        -1,
+                        dll_path,
+                        MAX_VAR_SIZE,
+                        NULL,
+                        NULL);
+    char * str_env = std::strtok(dll_path, ";");
+    while (str_env !=NULL) {
+      zstring zorba_env_dir(str_env);
+      if (str_env[strlen(str_env)-1] != '\\')
+      {
+        zorba_env_dir.append("\\");
+      }
+      append_to_path(lRootURIPath, zorba_env_dir, zstring(ZORBA_CORE_URI_DIR));
+      append_to_path(lRootURIPath, zorba_env_dir, zstring(ZORBA_NONCORE_URI_DIR));
+      str_env = std::strtok(NULL, ";");
+    }
+  }
+
+  // get a relative path from the environment for LIB
+  path_size = GetEnvironmentVariableW (L"ZORBA_LIB_DIRS", 
+                                       env_var,
+                                       MAX_VAR_SIZE );
+  if (path_size)
+  {
+    char  dll_path[MAX_VAR_SIZE];
+    WideCharToMultiByte(CP_UTF8,
+                        0,
+                        env_var,
+                        -1,
+                        dll_path,
+                        MAX_VAR_SIZE,
+                        NULL,
+                        NULL);
+    char * str_env = std::strtok(dll_path, ";");
+    while (str_env !=NULL) {
+      zstring zorba_env_dir(str_env);
+      if (str_env[strlen(str_env)-1] != '\\')
+      {
+        zorba_env_dir.append("\\");
+      }
+      append_to_path(lRootLibPath, zorba_env_dir, zstring(ZORBA_CORE_LIB_DIR));
+      append_to_path(lRootLibPath, zorba_env_dir, zstring(ZORBA_NONCORE_LIB_DIR));
+      str_env = std::strtok(NULL, ";");
+    }
+  }
 #endif
+
   const char ** lURIPathIter = get_builtin_uri_path();
   for (; *lURIPathIter != 0; ++lURIPathIter)
   {

=== modified file 'src/functions/func_schema_impl.cpp'
--- src/functions/func_schema_impl.cpp	2012-09-30 09:46:56 +0000
+++ src/functions/func_schema_impl.cpp	2012-10-12 22:54:28 +0000
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include "stdafx.h"
 #include "functions/func_schema.h"
 
 #include "compiler/expression/expr_base.h"


Follow ups