* Fix a bug on the xpath query. It was talking all nodes, even the one from 71/8571/2
Sylvestre Ledru [Mon, 6 Aug 2012 15:50:31 +0000 (17:50 +0200)]
other operating systems

Change-Id: I8431aa7487c05f95c358e2d07485fcf53dc27a45

scilab/modules/core/includes/getos.h
scilab/modules/jvm/src/c/getJvmOptions.c

index 33ceccd..b8b243f 100644 (file)
@@ -1,37 +1,37 @@
 /*
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2009 - DIGITEO - Allan CORNET
-* 
+*
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
-* are also available at    
+* are also available at
 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 *
 */
 
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #ifndef __GETOS_H__
 #define __GETOS_H__
 
 #ifdef OSNAME
-       #undef OSNAME
+#undef OSNAME
 #endif
 
 #ifdef __APPLE__
-       #define OSNAME macosx
+#define OSNAME "macosx"
+#else
+#ifdef __linux__
+#define OSNAME "linux"
+#else
+#ifdef _MSC_VER
+#define OSNAME "windows"
 #else
-       #ifdef __linux__
-               #define OSNAME linux
-       #else
-               #ifdef _MSC_VER
-                       #define OSNAME windows
-               #else
-                       #define OSNAME other
-               #endif
-       #endif
+#define OSNAME "other"
+#endif
+#endif
 #endif
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 
 /**
 * get OS Full name based on uname
 char *getOSFullName(void);
 
 /**
-* get OS Release Info 
+* get OS Release Info
 * @return a string
 */
 char *getOSRelease(void);
 
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #endif /* __GETOS_H__ */
index 61de569..f142f07 100644 (file)
@@ -48,7 +48,8 @@ JavaVMOption * getJvmOptions(char *SCI_PATH, char *filename_xml_conf, int *size_
             xmlXPathContextPtr xpathCtxt = NULL;
             xmlXPathObjectPtr xpathObj = NULL;
             char *jvm_option_string = NULL;
-            char * heapSize = getJavaHeapSize();
+            char *xpath_query = NULL;
+            char *heapSize = getJavaHeapSize();
 
             int indice = 0;
             {
@@ -76,8 +77,14 @@ JavaVMOption * getJvmOptions(char *SCI_PATH, char *filename_xml_conf, int *size_
             }
 
             xpathCtxt = xmlXPathNewContext(doc);
-            xpathObj = xmlXPathEval((const xmlChar*)"//jvm_options/option | //jvm_options/option[@os='OSNAME']", xpathCtxt);
+            /* Retrieve all nodes without the os tag + only the one from our operating system */
+#define XPATH_QUERY "//jvm_options/option[not(@os)] | //jvm_options/option[@os='%s']"
 
+            xpath_query = (char *)MALLOC(sizeof(char) * ((int)strlen(XPATH_QUERY) + (int)strlen(OSNAME) + 1));
+            sprintf(xpath_query, XPATH_QUERY, OSNAME);
+
+            xpathObj = xmlXPathEval((const xmlChar*)xpath_query, xpathCtxt);
+            FREE(xpath_query);
             if (xpathObj && xpathObj->nodesetval->nodeMax)
             {
                 /* the Xpath has been understood and there are node */