|
|
383414c |
diff -r 7fba7ef21117 -r f104ace19a51 src/backend/APT/APTRanges.cpp
|
|
|
383414c |
--- src/backend/APT/APTRanges.cpp Sat Jan 18 17:45:15 2014 +0100
|
|
|
383414c |
+++ src/backend/APT/APTRanges.cpp Wed Feb 05 22:08:32 2014 +0100
|
|
|
383414c |
@@ -26,7 +26,6 @@
|
|
|
383414c |
|
|
|
383414c |
#include <map>
|
|
|
383414c |
#include <fstream>
|
|
|
383414c |
-#include <clocale>
|
|
|
383414c |
#include <numeric>
|
|
|
383414c |
#include <cstring>
|
|
|
383414c |
|
|
|
383414c |
@@ -484,15 +483,7 @@
|
|
|
383414c |
}
|
|
|
383414c |
|
|
|
383414c |
|
|
|
383414c |
- //switch to "C" style decimal notation (English),
|
|
|
383414c |
- //as needed
|
|
|
383414c |
- char *oldLocale=setlocale(LC_NUMERIC,NULL);
|
|
|
383414c |
-
|
|
|
383414c |
- //setlocale reserves the right to trash the returned pointer
|
|
|
383414c |
- //on subsequent calls (it totally makes sense, or something..).
|
|
|
383414c |
- oldLocale=strdup(oldLocale);
|
|
|
383414c |
- if(strcmp(oldLocale,"C"))
|
|
|
383414c |
- setlocale(LC_NUMERIC,"C");
|
|
|
383414c |
+ pushLocale("C",LC_NUMERIC);
|
|
|
383414c |
|
|
|
383414c |
size_t errCode;
|
|
|
383414c |
switch(fileFormat)
|
|
|
383414c |
@@ -521,31 +512,19 @@
|
|
|
383414c |
default:
|
|
|
383414c |
ASSERT(false);
|
|
|
383414c |
fclose(fpRange);
|
|
|
383414c |
- if(strcmp(oldLocale,"C"))
|
|
|
383414c |
- setlocale(LC_NUMERIC,oldLocale);
|
|
|
383414c |
- free(oldLocale);
|
|
|
383414c |
+ popLocale();
|
|
|
383414c |
return RANGE_ERR_FORMAT;
|
|
|
383414c |
}
|
|
|
383414c |
|
|
|
383414c |
+ popLocale();
|
|
|
383414c |
fclose(fpRange);
|
|
|
383414c |
if(errCode)
|
|
|
383414c |
{
|
|
|
383414c |
errState=errCode;
|
|
|
383414c |
-
|
|
|
383414c |
- if(strcmp(oldLocale,"C"))
|
|
|
383414c |
- setlocale(LC_NUMERIC,oldLocale);
|
|
|
383414c |
- free(oldLocale);
|
|
|
383414c |
|
|
|
383414c |
return errState;
|
|
|
383414c |
}
|
|
|
383414c |
|
|
|
383414c |
- //revert back to user's locale, as needed
|
|
|
383414c |
- if(strcmp(oldLocale,"C"))
|
|
|
383414c |
- setlocale(LC_NUMERIC,oldLocale);
|
|
|
383414c |
-
|
|
|
383414c |
- free(oldLocale);
|
|
|
383414c |
-
|
|
|
383414c |
-
|
|
|
383414c |
//Run self consistency check on freshly loaded data
|
|
|
383414c |
if(!isSelfConsistent())
|
|
|
383414c |
{
|
|
|
383414c |
diff -r 7fba7ef21117 -r f104ace19a51 src/backend/filters/transform.cpp
|
|
|
383414c |
--- src/backend/filters/transform.cpp Sat Jan 18 17:45:15 2014 +0100
|
|
|
383414c |
+++ src/backend/filters/transform.cpp Wed Feb 05 22:08:32 2014 +0100
|
|
|
383414c |
@@ -1110,7 +1110,15 @@
|
|
|
383414c |
return ERR_CALLBACK_FAIL;
|
|
|
383414c |
}
|
|
|
383414c |
//Shuffle the value data.TODO: callback functor
|
|
|
383414c |
+
|
|
|
383414c |
+#ifndef HAVE_CPP1X
|
|
|
383414c |
+ std::srand(time(0));
|
|
|
383414c |
std::random_shuffle(massData.begin(),massData.end());
|
|
|
383414c |
+#else
|
|
|
383414c |
+ std::mt19937_64 r;
|
|
|
383414c |
+ r.seed(time(0));
|
|
|
383414c |
+ std::shuffle(massData.begin(),massData.end(),r);
|
|
|
383414c |
+#endif
|
|
|
383414c |
if(!(*callback)(true))
|
|
|
383414c |
{
|
|
|
383414c |
delete d;
|
|
|
383414c |
diff -r 7fba7ef21117 -r f104ace19a51 src/common/basics.cpp
|
|
|
383414c |
--- src/common/basics.cpp Sat Jan 18 17:45:15 2014 +0100
|
|
|
383414c |
+++ src/common/basics.cpp Wed Feb 05 22:08:32 2014 +0100
|
|
|
383414c |
@@ -41,6 +41,9 @@
|
|
|
383414c |
#include <sys/stat.h>
|
|
|
383414c |
#endif
|
|
|
383414c |
|
|
|
383414c |
+#include <cstring>
|
|
|
383414c |
+#include <clocale>
|
|
|
383414c |
+
|
|
|
383414c |
using std::string;
|
|
|
383414c |
using std::vector;
|
|
|
383414c |
using std::list;
|
|
|
383414c |
@@ -65,6 +68,9 @@
|
|
|
383414c |
//default font to use.
|
|
|
383414c |
std::string defaultFontFile;
|
|
|
383414c |
|
|
|
383414c |
+static char *oldLocaleStatic;
|
|
|
383414c |
+static int localeStaticType;
|
|
|
383414c |
+
|
|
|
383414c |
unsigned int getBitNum(unsigned int u)
|
|
|
383414c |
{
|
|
|
383414c |
ASSERT(u);
|
|
|
383414c |
@@ -86,6 +92,45 @@
|
|
|
383414c |
return "0";
|
|
|
383414c |
}
|
|
|
383414c |
|
|
|
383414c |
+void pushLocale(const char *newLocale, int type)
|
|
|
383414c |
+{
|
|
|
383414c |
+ ASSERT(!oldLocaleStatic);
|
|
|
383414c |
+ ASSERT(!localeStaticType);
|
|
|
383414c |
+
|
|
|
383414c |
+ ASSERT(type == LC_NUMERIC || type == LC_MONETARY || type == LC_CTYPE
|
|
|
383414c |
+ || type == LC_COLLATE || type == LC_ALL || type == LC_TIME
|
|
|
383414c |
+ || type== LC_MESSAGES);
|
|
|
383414c |
+
|
|
|
383414c |
+ oldLocaleStatic=setlocale(type,NULL);
|
|
|
383414c |
+
|
|
|
383414c |
+ //setlocale reserves the right to trash the returned pointer
|
|
|
383414c |
+ // on subsequent calls (i.e. use the returned pointer for later)
|
|
|
383414c |
+ // thus we must duplicate the pointer to own it
|
|
|
383414c |
+ oldLocaleStatic=strdup(oldLocaleStatic);
|
|
|
383414c |
+ if(strcmp(oldLocaleStatic,newLocale))
|
|
|
383414c |
+ {
|
|
|
383414c |
+ setlocale(type,newLocale);
|
|
|
383414c |
+ localeStaticType=type;
|
|
|
383414c |
+ }
|
|
|
383414c |
+ else
|
|
|
383414c |
+ {
|
|
|
383414c |
+ //record that we did not set this
|
|
|
383414c |
+ localeStaticType=-1;
|
|
|
383414c |
+ }
|
|
|
383414c |
+
|
|
|
383414c |
+}
|
|
|
383414c |
+
|
|
|
383414c |
+void popLocale()
|
|
|
383414c |
+{
|
|
|
383414c |
+ if(localeStaticType != -1)
|
|
|
383414c |
+ setlocale(localeStaticType,oldLocaleStatic);
|
|
|
383414c |
+
|
|
|
383414c |
+ localeStaticType=0;
|
|
|
383414c |
+
|
|
|
383414c |
+ free(oldLocaleStatic);
|
|
|
383414c |
+ oldLocaleStatic=0;
|
|
|
383414c |
+}
|
|
|
383414c |
+
|
|
|
383414c |
|
|
|
383414c |
bool dummyCallback(bool)
|
|
|
383414c |
{
|
|
|
383414c |
diff -r 7fba7ef21117 -r f104ace19a51 src/common/basics.h
|
|
|
383414c |
--- src/common/basics.h Sat Jan 18 17:45:15 2014 +0100
|
|
|
383414c |
+++ src/common/basics.h Wed Feb 05 22:08:32 2014 +0100
|
|
|
383414c |
@@ -42,6 +42,13 @@
|
|
|
383414c |
extern const char *FONT_FILE;
|
|
|
383414c |
|
|
|
383414c |
|
|
|
383414c |
+//Set new locale code. Must be followed by a popLocale call before completion
|
|
|
383414c |
+// Only one locale type can be pushed at a time this way
|
|
|
383414c |
+void pushLocale(const char *newLocale, int type);
|
|
|
383414c |
+
|
|
|
383414c |
+//Restore old locale code
|
|
|
383414c |
+void popLocale();
|
|
|
383414c |
+
|
|
|
383414c |
|
|
|
383414c |
|
|
|
383414c |
//C file peek function
|
|
|
383414c |
diff -r 7fba7ef21117 -r f104ace19a51 src/gui/mathglPane.cpp
|
|
|
383414c |
--- src/gui/mathglPane.cpp Sat Jan 18 17:45:15 2014 +0100
|
|
|
383414c |
+++ src/gui/mathglPane.cpp Wed Feb 05 22:08:32 2014 +0100
|
|
|
383414c |
@@ -27,7 +27,6 @@
|
|
|
383414c |
|
|
|
383414c |
#ifdef USE_MGL2
|
|
|
383414c |
#include <mgl2/canvas_wnd.h>
|
|
|
383414c |
- #include <mgl2/canvas_wnd.h>
|
|
|
383414c |
#else
|
|
|
383414c |
#include <mgl/mgl_eps.h>
|
|
|
383414c |
#endif
|
|
|
383414c |
@@ -1091,7 +1090,13 @@
|
|
|
383414c |
grS->SetWarn(0);
|
|
|
383414c |
grS->Message=mglWarnMsgBuf;
|
|
|
383414c |
#endif
|
|
|
383414c |
+
|
|
|
383414c |
+ //Mathgl does not set locale prior to writing SVG
|
|
|
383414c |
+ // do this by hand
|
|
|
383414c |
+ pushLocale("C",LC_NUMERIC);
|
|
|
383414c |
grS->WriteSVG(filename.c_str());
|
|
|
383414c |
+ popLocale();
|
|
|
383414c |
+
|
|
|
383414c |
|
|
|
383414c |
bool doWarn;
|
|
|
383414c |
#ifdef USE_MGL2
|