Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.executable/.cproject12
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipse.c75
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseUtil.c97
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseUtil.h8
4 files changed, 149 insertions, 43 deletions
diff --git a/bundles/org.eclipse.equinox.executable/.cproject b/bundles/org.eclipse.equinox.executable/.cproject
index f43ce5ca0..4a4c06651 100644
--- a/bundles/org.eclipse.equinox.executable/.cproject
+++ b/bundles/org.eclipse.equinox.executable/.cproject
@@ -54,22 +54,10 @@
</storageModule>
<storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="converted.config.1797282818" moduleId="org.eclipse.cdt.core.settings" name="convertedConfig">
-
-
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser">
-<attribute key="addr2line" value="addr2line"/>
-<attribute key="c++filt" value="c++filt"/>
-</extension>
-<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser">
-<attribute key="addr2line" value="addr2line"/>
-<attribute key="cygpath" value="cygpath"/>
-<attribute key="nm" value="nm"/>
-<attribute key="c++filt" value="c++filt"/>
-</extension>
<extension id="org.eclipse.cdt.core.MachO" point="org.eclipse.cdt.core.BinaryParser">
<attribute key="c++filt" value="c++filt"/>
</extension>
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipse.c b/bundles/org.eclipse.equinox.executable/library/eclipse.c
index d7d011d4b..8f5081e71 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipse.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipse.c
@@ -266,6 +266,10 @@ typedef struct
#define OPTIONAL_VALUE 2 /* value is optional, if next arg does not start with '-', */
/* don't assign it and only remove (remove - 1) arguments */
+/* flags being used by EE options */
+#define EE_ADJUST_PATH 4 /* value is a path, do processing on relative paths to try and make them absolute */
+#define EE_PATH_LIST 8 /* value is a list of paths */
+
static Option options[] = {
{ CONSOLE, &needConsole, VALUE_IS_FLAG, 0 },
{ CONSOLELOG, &needConsole, VALUE_IS_FLAG, 0 },
@@ -284,10 +288,10 @@ static Option options[] = {
static int optionsSize = (sizeof(options) / sizeof(options[0]));
static Option eeOptions[] = {
- { EE_EXECUTABLE, &eeExecutable, 0, 0 },
- { EE_CONSOLE, &eeConsole, 0, 0 },
- { EE_VM_LIBRARY, &eeLibrary, 0, 0 },
- { EE_LIBRARY_PATH, &eeLibPath, 0, 0 }
+ { EE_EXECUTABLE, &eeExecutable, EE_ADJUST_PATH, 0 },
+ { EE_CONSOLE, &eeConsole, EE_ADJUST_PATH, 0 },
+ { EE_VM_LIBRARY, &eeLibrary, EE_ADJUST_PATH, 0 },
+ { EE_LIBRARY_PATH, &eeLibPath, EE_ADJUST_PATH | EE_PATH_LIST, 0 }
};
static int eeOptionsSize = (sizeof(eeOptions) / sizeof(eeOptions[0]));
@@ -983,31 +987,22 @@ static _TCHAR* findSplash(_TCHAR* splashArg) {
}
static _TCHAR* findStartupJar(){
- _TCHAR * file;
+ _TCHAR * file, *ch;
_TCHAR * pluginsPath;
struct _stat stats;
int pathLength, progLength;
if( startupArg != NULL ) {
/* startup jar was specified on the command line */
-
- /* Construct the absolute name of the startup jar */
- file = malloc( (_tcslen( programDir ) + _tcslen( startupArg ) + 1) * sizeof( _TCHAR ) );
- file = _tcscpy( file, programDir );
- file = _tcscat( file, startupArg );
-
- /* If the file does not exist, treat the argument as an absolute path */
- if (_tstat( file, &stats ) != 0)
- {
- free( file );
- file = malloc( (_tcslen( startupArg ) + 1) * sizeof( _TCHAR ) );
- file = _tcscpy( file, startupArg );
-
- /* still doesn't exit? */
- if (_tstat( file, &stats ) != 0) {
- free(file);
- file = NULL;
- }
+ ch = _tcsdup(startupArg);
+ /* check path will check relative paths against programDir and workingDir */
+ file = checkPath(ch, programDir, 0);
+ if(file != ch)
+ free(ch);
+ /* check existence */
+ if (_tstat( file, &stats ) != 0) {
+ free(file);
+ file = NULL;
}
/* TODO What should the policy here be, if we didn't find what they
* specified? (Its harder to specify equinox.startup on the mac.) */
@@ -1124,6 +1119,7 @@ static int determineVM(_TCHAR** msg) {
/* vmName is passed in on command line with -vm */
if (vmName != NULL) {
+ vmName = checkPath(vmName, programDir, 0);
type = checkProvidedVMType(vmName);
switch (type) {
case VM_DIRECTORY:
@@ -1270,7 +1266,8 @@ static int determineVM(_TCHAR** msg) {
static int processEEProps(_TCHAR* eeFile)
{
_TCHAR ** argv;
- _TCHAR * ch;
+ _TCHAR * c1, * c2;
+ _TCHAR * eeDir;
int argc;
int index, i;
int matches = 0;
@@ -1282,6 +1279,13 @@ static int processEEProps(_TCHAR* eeFile)
nEEargs = argc;
eeVMarg = argv;
+ eeDir = _tcsdup(eeFile);
+ c1 = _tcsrchr( eeDir, dirSeparator );
+ if (c1 != NULL)
+ {
+ *(c1+1) = _T_ECLIPSE('\0');
+ }
+
for (index = 0; index < argc; index++){
/* Find the corresponding argument is a option supported by the launcher */
option = NULL;
@@ -1293,16 +1297,29 @@ static int processEEProps(_TCHAR* eeFile)
}
}
if(option != NULL) {
- ++matches;
- ch = malloc( (_tcslen(argv[index]) - _tcslen(option->name) + 1) *sizeof(_TCHAR));
- _tcscpy(ch, argv[index] + _tcslen(option->name));
+ ++matches;
if (option->flag & VALUE_IS_FLAG)
*((int*)option->value) = 1;
- else
- *((_TCHAR**)option->value) = ch;
+ else {
+ c1 = malloc( (_tcslen(argv[index]) - _tcslen(option->name) + 1) *sizeof(_TCHAR));
+ _tcscpy(c1, argv[index] + _tcslen(option->name));
+ if (option->flag & EE_ADJUST_PATH && option->flag & EE_PATH_LIST) {
+ c2 = checkPathList(c1, eeDir, 1);
+ free(c1);
+ c1 = c2;
+ } else if (option->flag & EE_ADJUST_PATH) {
+ c2 = checkPath(c1, eeDir, 1);
+ if (c2 != c1) {
+ free(c1);
+ c1 = c2;
+ }
+ }
+ *((_TCHAR**)option->value) = c1;
+ }
if(matches == eeOptionsSize)
break;
}
}
+ free(eeDir);
return 0;
}
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseUtil.c b/bundles/org.eclipse.equinox.executable/library/eclipseUtil.c
index 1f7e081ea..6c17993ec 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseUtil.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseUtil.c
@@ -20,8 +20,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
-
-#ifndef _WIN32
+#ifdef _WIN32
+#include <direct.h>
+#else
+#include <unistd.h>
#include <strings.h>
#endif
@@ -88,6 +90,97 @@ int checkProvidedVMType( _TCHAR* vm )
return VM_OTHER;
}
+/*
+ * If path is relative, attempt to make it absolute by
+ * 1) check relative to working directory
+ * 2) check relative to provided programDir
+ * If reverseOrder, then check the programDir before the working dir
+ */
+_TCHAR* checkPath( _TCHAR* path, _TCHAR* programDir, int reverseOrder )
+{
+ int cwdSize = MAX_PATH_LENGTH * sizeof(_TCHAR);
+ int i;
+ _TCHAR * workingDir, * buffer, * result;
+ _TCHAR * paths[2];
+ struct _stat stats;
+
+ /* If the command was an abolute pathname, use it as is. */
+ if (path[0] == dirSeparator ||
+ (_tcslen( path ) > 2 && path[1] == _T_ECLIPSE(':')))
+ {
+ return path;
+ }
+
+ /* get the current working directory */
+ workingDir = malloc(cwdSize);
+ while ( _tgetcwd( workingDir, cwdSize ) == NULL ){
+ cwdSize *= 2;
+ workingDir = realloc(workingDir, cwdSize);
+ }
+
+ paths[0] = reverseOrder ? programDir : workingDir;
+ paths[1] = reverseOrder ? workingDir : programDir;
+
+ /* just make a buffer big enough to hold everything */
+ buffer = malloc((_tcslen(paths[0]) + _tcslen(paths[1]) + _tcslen(path) + 2) * sizeof(_TCHAR));
+ for ( i = 0; i < 2; i++ ) {
+ _stprintf(buffer, _T_ECLIPSE("%s%c%s"), paths[i], dirSeparator, path);
+ if (_tstat(buffer, &stats) == 0) {
+ result = _tcsdup(buffer);
+ break;
+ }
+ }
+
+ free(buffer);
+ free(workingDir);
+
+ /* if we found something, return it, otherwise, return the original */
+ return result != NULL ? result : path;
+}
+
+/*
+ * pathList is a pathSeparator separated list of paths, run each through
+ * checkPath and recombine the results.
+ * New memory is always allocated for the result
+ */
+_TCHAR * checkPathList( _TCHAR* pathList, _TCHAR* programDir, int reverseOrder) {
+ _TCHAR * c1, *c2;
+ _TCHAR * checked, *result;
+ int checkedLength = 0, resultLength = 0;
+ int bufferLength = _tcslen(pathList);
+
+ result = malloc(bufferLength * sizeof(_TCHAR));
+ c1 = pathList;
+ while (c1 != NULL && *c1 != _T_ECLIPSE('\0'))
+ {
+ c2 = _tcschr(c1, pathSeparator);
+ if (c2 != NULL)
+ *c2 = 0;
+
+ checked = checkPath(c1, programDir, reverseOrder);
+ checkedLength = _tcslen(checked);
+ if (resultLength + checkedLength + 1> bufferLength) {
+ bufferLength += checkedLength + 1;
+ result = realloc(result, bufferLength * sizeof(_TCHAR));
+ }
+
+ if(resultLength > 0) {
+ result[resultLength++] = pathSeparator;
+ result[resultLength] = _T_ECLIPSE('\0');
+ }
+ _tcscpy(result + resultLength, checked);
+ resultLength += checkedLength;
+
+ if(checked != c1)
+ free(checked);
+ if(c2 != NULL)
+ *(c2++) = pathSeparator;
+ c1 = c2;
+ }
+
+ return result;
+}
+
int isVMLibrary( _TCHAR* vm )
{
_TCHAR *ch = NULL;
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseUtil.h b/bundles/org.eclipse.equinox.executable/library/eclipseUtil.h
index 9b14112ac..5be64926f 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseUtil.h
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseUtil.h
@@ -17,6 +17,8 @@
#define isJ9VM isJ9VMW
#define isVMLibrary isVMLibraryW
#define checkProvidedVMType checkProvidedVMTypeW
+#define checkPath checkPathW
+#define checkPathList checkPathListW
#endif
/* constants for checkProvidedVMType */
@@ -37,6 +39,12 @@ extern int isVMLibrary( _TCHAR* vm );
/* determine what the provided -vm argument is referring to */
extern int checkProvidedVMType( _TCHAR* vm );
+/* check the given path and attempt to make it absolute if it is relative */
+extern _TCHAR* checkPath( _TCHAR* path, _TCHAR* programDir, int reverseOrder );
+
+/* take a list of path separated with pathSeparator and run them through checkPath */
+extern _TCHAR * checkPathList( _TCHAR* pathList, _TCHAR* programDir, int reverseOrder);
+
#ifdef AIX
/* Get the version of the VM */
extern char* getVMVersion( char* vm );

Back to the top