Skip to content

Commit

Permalink
- Revert r15347 (breaks Linux compilation, breaks setModelicaPath() API)
Browse files Browse the repository at this point in the history
  - If this functionality is needed; do the caching for both Linux and Windows. And make sure setModelicaPath updates the cached path instead of just set the env.var


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15348 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 27, 2013
1 parent 8275f33 commit 2f25bc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Compiler/runtime/Settings_omc.cpp
Expand Up @@ -53,7 +53,7 @@ extern const char* Settings_getModelicaPath(int runningTestsuite)
const char *path = SettingsImpl__getModelicaPath(runningTestsuite);
if (path == NULL)
MMC_THROW();
return strdup(path);
return path;
}

extern const char* Settings_getCompileCommand()
Expand Down
3 changes: 2 additions & 1 deletion Compiler/runtime/Settings_rml.c
Expand Up @@ -138,7 +138,8 @@ RML_BEGIN_LABEL(Settings__getModelicaPath)
if (path == NULL)
RML_TAILCALLK(rmlFC);
else
rmlA0 = (void*) mk_scon(path);
rmlA0 = mk_scon(path);
free(path);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL
Expand Down
19 changes: 5 additions & 14 deletions Compiler/runtime/settingsimpl.c
Expand Up @@ -65,9 +65,7 @@ static int echo = 1; //true
extern char* _replace(char* source_str,char* search_str,char* replace_str); //Defined in systemimpl.c
extern int SystemImpl__directoryExists(const char*);

#if defined(__MINGW32__) || defined(_MSC_VER)
static char* winPath = NULL;
#endif

// Do not free or modify the returned variable. It's part of the environment!
const char* SettingsImpl__getInstallationDirectoryPath() {
Expand Down Expand Up @@ -95,14 +93,11 @@ const char* SettingsImpl__getInstallationDirectoryPath() {
i++;
}
return (const char*)winPath;
#else
return path;
#endif
return path;
}

#if defined(__MINGW32__) || defined(_MSC_VER)
static char* winLibPath = NULL;
#endif
char* winLibPath = NULL;

// Do not free the returned variable. It's malloc'ed
char* SettingsImpl__getModelicaPath(int runningTestsuite) {
Expand Down Expand Up @@ -134,17 +129,13 @@ char* SettingsImpl__getModelicaPath(int runningTestsuite) {
}

#if defined(__MINGW32__) || defined(_MSC_VER)
/* already set, set it only once! */
if (winLibPath != NULL)
return winLibPath;

/* adrpo: translate this to forward slashes! */
/* duplicate the path */
winLibPath = strdup(path);

/* ?? not enough memory for duplication */
if (!winLibPath)
return path;
return strdup(path);

/* convert \\ to / */
while(winLibPath[i] != '\0')
Expand All @@ -153,9 +144,9 @@ char* SettingsImpl__getModelicaPath(int runningTestsuite) {
i++;
}
return winLibPath;
#else
return path;
#endif

return strdup(path);
}

static const char* SettingsImpl__getCompileCommand()
Expand Down

0 comments on commit 2f25bc6

Please sign in to comment.