Skip to content

Commit

Permalink
Remove string_util.{c,h} since that version of strtod spins in too ma…
Browse files Browse the repository at this point in the history
…ny cases.

Going back to strtod, which is locale-dependent, but at least works as long as external C code does not set the locale.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21260 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jun 24, 2014
1 parent ab3fa9b commit f6c5956
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3,843 deletions.
14 changes: 10 additions & 4 deletions Examples/BuildModelRecursive.mos
Expand Up @@ -202,7 +202,9 @@ if buildRes and javascript then
end if;
mdFile := if javascript then \""+s+".md\" else \"\";

if mslRegressionOutput <> \"\" then
resFile := \""+s+"_res.\" + outputFormat;

if mslRegressionOutput <> \"\" and referenceExists then
mslRegressionOutput := mslRegressionOutput + \"/"+OpenModelica.Scripting.stringReplace(s,".","/")+"/\";
mkdir(mslRegressionOutput);
simFailLog := mslRegressionOutput+\"simulate_failed.log\";
Expand All @@ -214,7 +216,12 @@ if mslRegressionOutput <> \"\" then
system(\"rm -f \"+(if buildRes then buildFailLog else buildSuccessLog));

system(\"cp \"+simFile+\" \" + simFile + \".tmp\");
system(\"cp "+s+"_res.csv "+s+".csv\");
if simRes then
system(\"cp \"+resFile+\" "+s+".csv\");
compareFilesAndMove(\""+s+".csv\", mslRegressionOutput+\""+s+".csv\");
else
system(\"rm -f \" + mslRegressionOutput + \""+s+".csv\");
end if;
system(\"cp "+s+".mos "+s+".mos.tmp\");

if err == \"\" then
Expand All @@ -225,7 +232,6 @@ if mslRegressionOutput <> \"\" then

compareFilesAndMove(errFile + \".tmp\", if buildRes then buildSuccessLog else buildFailLog);
compareFilesAndMove(simFile + \".tmp\", if buildRes then simSuccessLog else simFailLog);
compareFilesAndMove(\""+s+".csv\", mslRegressionOutput+\""+s+".csv\");
compareFilesAndMove(\""+s+".mos.tmp\", mslRegressionOutput+\"creation.txt\");
end if;

Expand All @@ -236,7 +242,7 @@ if simRes then
prefix := \"files/"+s+".diff\";
if referenceExists then
OpenModelica.Scripting.Internal.Time.timerTick(OpenModelica.Scripting.Internal.Time.RT_CLOCK_USER_RESERVED);
(referenceOK,diffVars) := diffSimulationResults(\""+s+"_res.\"+outputFormat,reference,prefix,relTol=reference_reltol,relTolDiffMinMax=reference_reltolDiffMinMax,rangeDelta=reference_rangeDelta);
(referenceOK,diffVars) := diffSimulationResults(resFile,reference,prefix,relTol=reference_reltol,relTolDiffMinMax=reference_reltolDiffMinMax,rangeDelta=reference_rangeDelta);
if referenceOK then
system(\"touch "+s+".verifysuccess\");
end if;
Expand Down
4 changes: 1 addition & 3 deletions SimulationRuntime/c/simulation/simulation_info_xml.c
Expand Up @@ -371,8 +371,6 @@ void freeModelInfoXml(MODEL_DATA_XML* xml)
#include <unistd.h>
#endif

#include "string_util.h"

static inline const char* skipSpace(const char* str)
{
do {
Expand Down Expand Up @@ -467,7 +465,7 @@ static const char* skipValue(const char* str)
case '9':
{
char *endptr = NULL;
double d = om_strtod(str,&endptr);
double d = strtod(str,&endptr);
if (str == endptr) {
throwStreamPrint(NULL, "Not a number, got %.20s\n", str);
}
Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/c/util/CMakeLists.txt
Expand Up @@ -2,13 +2,13 @@
SET(util_sources base_array.c boolean_array.c omc_error.c division.c index_spec.c
integer_array.c java_interface.c libcsv.c list.c memory_pool.c modelica_string.c
read_write.c read_matlab4.c read_csv.c real_array.c ringbuffer.c
rtclock.c simulation_options.c string_array.c string_util.c utility.c varinfo.c omc_msvc.c OldModelicaTables.c cJSON.o)
rtclock.c simulation_options.c string_array.c utility.c varinfo.c omc_msvc.c OldModelicaTables.c cJSON.o)


SET(util_headers base_array.h boolean_array.h division.h omc_error.h index_spec.h integer_array.h
java_interface.h jni.h jni_md.h jni_md_solaris.h jni_md_windows.h list.h memory_pool.h
modelica.h modelica_string.h read_write.h read_matlab4.h real_array.h
ringbuffer.h rtclock.h simulation_options.h string_array.h string_util.h utility.h varinfo.h)
ringbuffer.h rtclock.h simulation_options.h string_array.h utility.h varinfo.h)

if(MSVC)
INCLUDE_DIRECTORIES(${OMCTRUNCHOME}/3rdParty/regex-0.12)
Expand Down
3 changes: 1 addition & 2 deletions SimulationRuntime/c/util/read_csv.c
Expand Up @@ -34,7 +34,6 @@
#include "read_csv.h"
#include "read_matlab4.h"
#include "libcsv.h"
#include "string_util.h"

struct cell_row_count
{
Expand Down Expand Up @@ -160,7 +159,7 @@ static void add_cell(void *data, size_t len, void *t)
body->buffer_size = body->buffer_size > 0 ? body->buffer_size : 1024;
body->res = body->res ? (double*)realloc(body->res, sizeof(double)*body->buffer_size) : (double*) malloc(sizeof(double)*body->buffer_size);
}
body->res[body->size++] = data ? om_strtod((const char*)data,&endptr) : 0;
body->res[body->size++] = data ? strtod((const char*)data,&endptr) : 0;
if (*endptr) {
printf("Found non-double data in csv result-file: %s\n", (char*) data);
body->error = 1;
Expand Down

0 comments on commit f6c5956

Please sign in to comment.