#1766 closed defect (fixed)
Locale changes cause real to string conversion to fail
Reported by: | Jens Frenkel | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.0 |
Component: | Frontend | Version: | trunk |
Keywords: | Cc: | Martin Sjölund, Per Östlund |
Description
For the msl3.1 example
Modelica.Mechanics.Rotational.Examples.LossyGearDemo1
instantiation fails for the parameter gear.lossTable
in Example:
Rotational.Components.LossyGear gear(ratio=2, lossTable=[0, 0.5, 0.5, 0, 0],useSupport=true)
instantiation Result:
parameter Real gear.lossTable[1,1] = 0.0 \"Array for mesh efficiencies and bearing friction depending on speed\";
parameter Real gear.lossTable[1,2] = 0.0 \"Array for mesh efficiencies and bearing friction depending on speed\";
parameter Real gear.lossTable[1,3] = 0.0 \"Array for mesh efficiencies and bearing friction depending on speed\";
parameter Real gear.lossTable[1,4] = 0.0 \"Array for mesh efficiencies and bearing friction depending on speed\";
parameter Real gear.lossTable[1,5] = 0.0 \"Array for mesh efficiencies and bearing friction depending on speed\";
Change History (12)
comment:1 by , 12 years ago
Summary: | instantiateModel(Modelica.Mechanics.Rotational.Examples.LossyGearDemo1) fails for gear.gear.lossTable → instantiateModel(Modelica.Mechanics.Rotational.Examples.LossyGearDemo1) fails for gear.lossTable |
---|
comment:2 by , 12 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 12 years ago
It's broken for me on linux too, but it was broken very recently so you probably just don't have the lastest revision on linux. Apparently it was broken in r12389, which was a commit by Martin for some translation stuff. I don't know how that's possible, perhaps some flag stuff, but I'm investigating.
comment:5 by , 12 years ago
- I checked the commit versions from 12380 up to 12389 and It happens since 12389
comment:6 by , 12 years ago
Owner: | changed from | to
---|
Ok, so calling System.gettextInit with an empty string (the default) or something like sv_SE.utf8 causes the compiler to output zeroes instead of the correct values for this particular case. This is too weird for me, reassigning to Martin.
comment:7 by , 12 years ago
I checked on my local machine the locale information and I assume the problem is that the decimal point symbol is changed.
Locale is: C
Date is: 08/02/12 20:37:58
decimal_point symbol is: .
Locale is: German_Germany.1252
Date is: 02.08.2012 20:37:58
decimal_point symbol is: ,
void SystemImplgettextInit(const char *locale)
{
#if defined(_MSC_VER)
#else
const char *omhome = SettingsImplgetInstallationDirectoryPath();
char *localedir;
int omlen;
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
struct lconv * lc;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ("Locale is: %s\n", setlocale(LC_ALL,NULL) );
strftime (buffer,80,"%c",timeinfo);
printf ("Date is: %s\n",buffer);
lc = localeconv ();
printf ("Currency symbol is: %s\n-\n",lc->currency_symbol);
printf ("decimal_point symbol is: %s\n-\n",lc->decimal_point);
if (!setlocale(LC_ALL, locale)) {
const char *c_tokens[1]={locale};
c_add_message(85, /* ERROR_OPENING_FILE */
ErrorType_scripting,
ErrorLevel_warning,
"Failed to set locale: '%s'.",
c_tokens,
1);
}
omlen = strlen(omhome);
localedir = (char*) malloc(omlen + 25);
sprintf(localedir, "%s/share/locale", omhome);
bindtextdomain ("openmodelica", localedir);
textdomain ("openmodelica");
free(localedir);
printf ("Locale is: %s\n", setlocale(LC_ALL,NULL) );
strftime (buffer,80,"%c",timeinfo);
printf ("Date is: %s\n",buffer);
lc = localeconv ();
printf ("Currency symbol is: %s\n-\n",lc->currency_symbol);
printf ("decimal_point symbol is: %s\n-\n",lc->decimal_point);
#endif
}
comment:8 by , 12 years ago
If I call omc with +locale=C all is fine, so I guess we should change the default value of the ConfigFlag locale to "C".
comment:9 by , 12 years ago
It is default C when running the testsuite. I'll also fix it to only set LC_MESSAGES instead of the other stuff in locale, but my local copy is weird because I upgraded gcc.
comment:11 by , 12 years ago
Milestone: | → 1.9.0 |
---|---|
Summary: | instantiateModel(Modelica.Mechanics.Rotational.Examples.LossyGearDemo1) fails for gear.lossTable → Locale changes cause real to string conversion to fail |
comment:12 by , 12 years ago
Component: | Instantiation → Frontend |
---|
Note there can be only one owner of a ticker, use cc instead