[ghemical-devel] Bug report and pt_BR Translation of Ghemical
Ulisses Leitao
ualeitao at yahoo.com
Fri Oct 3 08:08:38 EDT 2008
OK, super!!!
--- On Fri, 10/3/08, Tommi Hassinen <Tommi.Hassinen at uku.fi> wrote:
From: Tommi Hassinen <Tommi.Hassinen at uku.fi>
Subject: Re: [ghemical-devel] Bug report and pt_BR Translation of Ghemical
To: "Jean Bréfort" <jean.brefort at normalesup.org>
Cc:
"Ronoaldo JLP" <ronoaldo at fluxsoftwares.com>,
"ghemical-devel at bioinformatics.org"
<ghemical-devel at bioinformatics.org>
Date: Friday, October 3, 2008, 6:10 AM
From: Jean Bréfort [jean.brefort at normalesup.org]
Sent: Thursday, October 02, 2008 11:40 PM
To: Tommi Hassinen
Cc: Ronoaldo JLP; ghemical-devel at bioinformatics.org
Subject: Re: [ghemical-devel] Bug report and pt_BR Translation of Ghemical
OK, found the issue: the numeric locale should be set to "C" in both
project::Import and project::Export.
Cheers,
Jean
Yes, that's true. And it explains why everything works if the numeric
locale already is "C"...
Here in the end of this message is how I modified project::ImportFile() and
project::ExportFile() methods in src/project.cpp file.
Regards,
Tommi
##########################################################################################
bool project::ImportFile(const char * filename, int index)
{
ifstream ifile;
ostringstream intermed;
file_trans translator;
// store the current (numeric) locale into my_num_locale,
// and switch into the "C" numeric locale...
static char my_num_locale[32] = "C";
strcpy(my_num_locale, setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
if (index == 0) // Automatic detection
{
if (!translator.CanImport(filename))
{
ErrorMessage("Cannot import that file
type.");
return false;
}
ifile.open(filename, ios::in);
translator.Import(filename, ifile, intermed);
ifile.close();
}
else // By type picked by the user
{
ifile.open(filename, ios::in);
translator.Import(filename, index - 1, ifile, intermed);
ifile.close();
}
istringstream interInput(intermed.str());
bool retval = ReadGPR((* this), interInput, false);
// change the original locale back...
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
setlocale(LC_NUMERIC, my_num_locale);
return retval;
}
bool project::ExportFile(const char * filename, int index)
{
ofstream ofile;
stringstream intermed;
file_trans translator;
// store the current (numeric) locale into my_num_locale,
// and switch into the "C" numeric locale...
static char my_num_locale[32] = "C";
strcpy(my_num_locale, setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
WriteGPR_v100((* this), intermed); // this is for
openbabel-1.100.2
istringstream interInput(intermed.str());
if (index == 0) // Automatic detection
{
if (!translator.CanExport(filename))
{
ErrorMessage("Cannot export that file
type.");
return false;
}
ofile.open(filename, ios::out);
translator.Export(filename, interInput, ofile);
ofile.close();
}
else // By type picked by the user
{
ofile.open(filename, ios::out);
translator.Export(filename, index - 1, interInput, ofile);
ofile.close();
}
// change the original locale back...
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
setlocale(LC_NUMERIC, my_num_locale);
return true;
}
_______________________________________________
ghemical-devel mailing list
ghemical-devel at bioinformatics.org
http://www.bioinformatics.org/mailman/listinfo/ghemical-devel
ertions compiled in the Official Debian distros.
We will recompile the last CVS version in order to introduce the correct package
in the ProLinux Distro.
Well done.
Ulisses
--- On Fri, 10/3/08, Tommi Hassinen <Tommi.Hassinen at uku.fi> wrote:
From: Tommi Hassinen <Tommi.Hassinen at uku.fi>
Subject: Re: [ghemical-devel] Bug report and pt_BR Translation of Ghemical
To: "Jean Bréfort" <jean.brefort at normalesup.org>
Cc: "Ronoaldo JLP" <ronoaldo at fluxsoftwares.com>, "ghemical-devel at bioinformatics.org" <ghemical-devel at bioinformatics.org>
Date: Friday, October 3, 2008, 6:10 AM
From: Jean Bréfort [jean.brefort at normalesup.org]
Sent: Thursday, October 02, 2008 11:40 PM
To: Tommi Hassinen
Cc: Ronoaldo JLP; ghemical-devel at bioinformatics.org
Subject: Re: [ghemical-devel] Bug report and pt_BR Translation of Ghemical
OK, found the issue: the numeric locale should be set to "C" in both
project::Import and project::Export.
Cheers,
Jean
Yes, that's true. And it explains why everything works if the numeric
locale already is "C"...
Here in the end of this message is how I modified project::ImportFile() and
project::ExportFile() methods in src/project.cpp file.
Regards,
Tommi
##########################################################################################
bool project::ImportFile(const char * filename, int index)
{
ifstream ifile;
ostringstream intermed;
file_trans translator;
// store the current (numeric) locale into my_num_locale,
// and switch into the "C" numeric locale...
static char my_num_locale[32] = "C";
strcpy(my_num_locale, setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
if (index == 0) // Automatic detection
{
if (!translator.CanImport(filename))
{
ErrorMessage("Cannot import that file
type.");
return false;
}
ifile.open(filename, ios::in);
translator.Import(filename, ifile, intermed);
ifile.close();
}
else // By type picked by the user
{
ifile.open(filename, ios::in);
translator.Import(filename, index - 1, ifile, intermed);
ifile.close();
}
istringstream interInput(intermed.str());
bool retval = ReadGPR((* this), interInput, false);
// change the original locale back...
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
setlocale(LC_NUMERIC, my_num_locale);
return retval;
}
bool project::ExportFile(const char * filename, int index)
{
ofstream ofile;
stringstream intermed;
file_trans translator;
// store the current (numeric) locale into my_num_locale,
// and switch into the "C" numeric locale...
static char my_num_locale[32] = "C";
strcpy(my_num_locale, setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
WriteGPR_v100((* this), intermed); // this is for
openbabel-1.100.2
istringstream interInput(intermed.str());
if (index == 0) // Automatic detection
{
if (!translator.CanExport(filename))
{
ErrorMessage("Cannot export that file
type.");
return false;
}
ofile.open(filename, ios::out);
translator.Export(filename, interInput, ofile);
ofile.close();
}
else // By type picked by the user
{
ofile.open(filename, ios::out);
translator.Export(filename, index - 1, interInput, ofile);
ofile.close();
}
// change the original locale back...
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
setlocale(LC_NUMERIC, my_num_locale);
return true;
}
_______________________________________________
ghemical-devel mailing list
ghemical-devel at bioinformatics.org
http://www.bioinformatics.org/mailman/listinfo/ghemical-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.bioinformatics.org/pipermail/ghemical-devel/attachments/20081003/8a74d098/attachment.html>
More information about the ghemical-devel
mailing list