Skip to content

Commit

Permalink
- Keep using smart, fast code for GCC/Clang
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14938 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 25, 2013
1 parent 2926298 commit 92b95b1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion SimulationRuntime/c/util/utility.c
Expand Up @@ -57,15 +57,22 @@ extern int OpenModelica_regexImpl(const char* str, const char* re, const int max
{
char *dup;
regex_t myregex;
regmatch_t *matches;
int nmatch=0,i,rc,res;
int flags = (extended ? REG_EXTENDED : 0) | (sensitive ? REG_ICASE : 0) | (maxn ? 0 : REG_NOSUB);
#if !defined(_MSC_VER)
regmatch_t matches[maxn];
#else
/* Stupid compiler */
regmatch_t matches;
matches = (regmatch_t*)malloc(maxn*sizeof(regmatch_t));
assert(matches != NULL);
#endif
memset(&myregex, 1, sizeof(regex_t));
rc = regcomp(&myregex, re, flags);
if (rc && maxn == 0) {
#if defined(_MSC_VER)
free(matches);
#endif
return 0;
}
if (rc) {
Expand All @@ -81,7 +88,9 @@ extern int OpenModelica_regexImpl(const char* str, const char* re, const int max
for (i=1; i<maxn; i++)
outMatches[i] = mystrdup("");
}
#if defined(_MSC_VER)
free(matches);
#endif
return 0;
}
res = regexec(&myregex, str, maxn, matches, 0);
Expand All @@ -103,7 +112,9 @@ extern int OpenModelica_regexImpl(const char* str, const char* re, const int max
}

regfree(&myregex);
#if defined(_MSC_VER)
free(matches);
#endif
return nmatch;
}

Expand Down

0 comments on commit 92b95b1

Please sign in to comment.