mirror of https://github.com/CGAL/cgal
Let libCGAL_ImageIO set temporarily the LC_NUMERIC locale to "C", during
the read/write operation of Inrimage headers. Otherwise the I/O operations can fail when the decimal point is not a dot.
This commit is contained in:
parent
abfd45595c
commit
d2fa7372e4
|
|
@ -43,7 +43,19 @@ typedef struct {
|
|||
} stringListHead;
|
||||
/* string list descriptor */
|
||||
|
||||
#include <clocale>
|
||||
class Set_numeric_locale {
|
||||
const char * old_locale;
|
||||
public:
|
||||
Set_numeric_locale(const char* locale)
|
||||
: old_locale(std::setlocale(LC_NUMERIC, locale))
|
||||
{
|
||||
}
|
||||
|
||||
~Set_numeric_locale() {
|
||||
std::setlocale(LC_NUMERIC, old_locale);
|
||||
}
|
||||
};
|
||||
|
||||
static void addStringElement(stringListHead *strhead,
|
||||
const char *str);
|
||||
|
|
@ -59,6 +71,8 @@ int _writeInrimageHeader(const _image *im, ENDIANNESS end) {
|
|||
unsigned int pos, i;
|
||||
char type[30], endianness[5], buf[257], scale[20];
|
||||
|
||||
Set_numeric_locale num_locale("C");
|
||||
|
||||
if(im->openMode != OM_CLOSE) {
|
||||
/* fix word kind */
|
||||
switch(im->wordKind) {
|
||||
|
|
@ -209,6 +223,8 @@ int readInrimageHeader(const char *,_image *im) {
|
|||
stringListHead strl = { NULL, NULL };
|
||||
stringListElement *oel, *el;
|
||||
|
||||
Set_numeric_locale num_locale("C");
|
||||
|
||||
if(im->openMode != OM_CLOSE) {
|
||||
/* read image magic number */
|
||||
if(!fgetns(str, 257, im )) return -1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue