From 3fa1b5261c3a4f7f08b94a8c1cc4fd6b23eada09 Mon Sep 17 00:00:00 2001 From: beutlich Date: Thu, 17 Oct 2013 09:50:34 +0000 Subject: [PATCH] merged r7083 from trunk refs #1273: use a safe check for the locale-dependent versions of strtod and strtol on GNU/Linux git-svn-id: https://svn.modelica.org/projects/Modelica/branches/maintenance/3.2.1@7084 7ce873d0-865f-4ce7-a662-4bb36ea78beb --- .../Resources/C-Sources/ModelicaStandardTables.c | 16 ++++++++-------- Modelica/Resources/C-Sources/ModelicaStrings.c | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Modelica/Resources/C-Sources/ModelicaStandardTables.c b/Modelica/Resources/C-Sources/ModelicaStandardTables.c index d4265e9afa..b3c79353e3 100644 --- a/Modelica/Resources/C-Sources/ModelicaStandardTables.c +++ b/Modelica/Resources/C-Sources/ModelicaStandardTables.c @@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if defined(__linux__) && !defined(NO_FILE_SYSTEM) +#if defined(__gnu_linux__) && !defined(NO_FILE_SYSTEM) #define _GNU_SOURCE 1 #endif #include "ModelicaStandardTables.h" @@ -3828,7 +3828,7 @@ static double* readTxtTable(const char* tableName, const char* fileName, unsigned long lineNo = 1; #if defined(_MSC_VER) && _MSC_VER >= 1400 _locale_t loc; -#elif defined(__linux__) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) locale_t loc; #else char* dec; @@ -3894,7 +3894,7 @@ static double* readTxtTable(const char* tableName, const char* fileName, #if defined(_MSC_VER) && _MSC_VER >= 1400 loc = _create_locale(LC_NUMERIC, "C"); -#elif defined(__linux__) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) loc = newlocale(LC_NUMERIC, "C", NULL); #else dec = localeconv()->decimal_point; @@ -3930,7 +3930,7 @@ static double* readTxtTable(const char* tableName, const char* fileName, } #if defined(_MSC_VER) && _MSC_VER >= 1400 nRow = (unsigned long)_strtol_l(token, &endptr, 10, loc); -#elif defined(__linux__) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) nRow = (unsigned long)strtol_l(token, &endptr, 10, loc); #else nRow = (unsigned long)strtol(token, &endptr, 10); @@ -3944,7 +3944,7 @@ static double* readTxtTable(const char* tableName, const char* fileName, } #if defined(_MSC_VER) && _MSC_VER >= 1400 nCol = (unsigned long)_strtol_l(token, &endptr, 10, loc); -#elif defined(__linux__) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) nCol = (unsigned long)strtol_l(token, &endptr, 10, loc); #else nCol = (unsigned long)strtol(token, &endptr, 10); @@ -3965,7 +3965,7 @@ static double* readTxtTable(const char* tableName, const char* fileName, fclose(fp); #if defined(_MSC_VER) && _MSC_VER >= 1400 _free_locale(loc); -#elif defined(__linux__) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) freelocale(loc); #endif ModelicaError("Memory allocation error\n"); @@ -4005,7 +4005,7 @@ static double* readTxtTable(const char* tableName, const char* fileName, if (*endptr != 0) { tableReadError = 1; } -#elif defined(__linux__) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) TABLE(i, j) = strtod_l(token, &endptr, loc); if (*endptr != 0) { tableReadError = 1; @@ -4067,7 +4067,7 @@ static double* readTxtTable(const char* tableName, const char* fileName, fclose(fp); #if defined(_MSC_VER) && _MSC_VER >= 1400 _free_locale(loc); -#elif defined(__linux__) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) freelocale(loc); #endif if (foundTable == 0) { diff --git a/Modelica/Resources/C-Sources/ModelicaStrings.c b/Modelica/Resources/C-Sources/ModelicaStrings.c index a1daba470c..357ea4fd8f 100644 --- a/Modelica/Resources/C-Sources/ModelicaStrings.c +++ b/Modelica/Resources/C-Sources/ModelicaStrings.c @@ -47,7 +47,7 @@ #if !defined(MODELICA_EXPORT) # define MODELICA_EXPORT #endif -#if defined(__linux__) && !defined(_DS1006) +#if defined(__gnu_linux__) #define _GNU_SOURCE 1 #endif @@ -261,7 +261,7 @@ MODELICA_EXPORT void ModelicaStrings_scanInteger(const char* string, int startIn && string[next] != 'E') ) { #if defined(_MSC_VER) && _MSC_VER >= 1400 _locale_t loc = _create_locale(LC_NUMERIC, "C"); -#elif defined(__linux__) && !defined(_DS1006) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) locale_t loc = newlocale(LC_NUMERIC, "C", NULL); #endif char buf[MAX_TOKEN_SIZE+1]; @@ -276,7 +276,7 @@ MODELICA_EXPORT void ModelicaStrings_scanInteger(const char* string, int startIn #if defined(_MSC_VER) && _MSC_VER >= 1400 x = (int)_strtol_l(buf, &endptr, 10, loc); _free_locale(loc); -#elif defined(__linux__) && !defined(_DS1006) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) x = (int)strtol_l(buf, &endptr, 10, loc); freelocale(loc); #else @@ -367,7 +367,7 @@ MODELICA_EXPORT void ModelicaStrings_scanReal(const char* string, int startIndex if (total_length > 0 && total_length < MAX_TOKEN_SIZE) { #if defined(_MSC_VER) && _MSC_VER >= 1400 _locale_t loc = _create_locale(LC_NUMERIC, "C"); -#elif defined(__linux__) && !defined(_DS1006) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) locale_t loc = newlocale(LC_NUMERIC, "C", NULL); #else char* dec = localeconv()->decimal_point; @@ -384,7 +384,7 @@ MODELICA_EXPORT void ModelicaStrings_scanReal(const char* string, int startIndex #if defined(_MSC_VER) && _MSC_VER >= 1400 x = _strtod_l(buf, &endptr, loc); _free_locale(loc); -#elif defined(__linux__) && !defined(_DS1006) +#elif defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ >= 6 && __GLIBC_PREREQ(2, 3) x = strtod_l(buf, &endptr, loc); freelocale(loc); #else