Author: nadiramra
Date: Mon May 16 22:18:07 2011
New Revision: 1103926
URL: http://svn.apache.org/viewvc?rev=1103926&view=rev
Log:
AXISCPP-1079 use locale decimal point in strtod on IBM i
Modified:
axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp
axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp
axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.cpp
axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp
axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp
axis/axis1/c/trunk/src/soap/xsd/Decimal.cpp
axis/axis1/c/trunk/src/soap/xsd/Double.cpp
axis/axis1/c/trunk/src/soap/xsd/Float.cpp
Modified: axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp
URL:
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp?rev=1103926&r1=1103925&r2=1103926&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp Mon May 16
22:18:07 2011
@@ -80,6 +80,13 @@
#define PLATFORM_DOUBLE_QUOTE_S "\""
#define PLATFORM_DOUBLE_QUOTE_C '\"'
+// Some C functions are locale-sensitive. On IBM i strtod() is
locale-sensitive,
+// such that if running in french locale the strtod() function expects
+// the decimal point to be a comma. If the same holds true with
+// other platforms then you will need to set this define appropriately.
+#define PLATFORM_PROCESS_DECIMAL_POINT_C '.'
+
+
#define PLATFORM_XML_ENTITY_REFERENCE_CHARS_S "<>&\"\'"
// Case-insensitive string compares
Modified: axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp
URL:
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp?rev=1103926&r1=1103925&r2=1103926&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp Mon May 16
22:18:07 2011
@@ -79,6 +79,12 @@
#define PLATFORM_DOUBLE_QUOTE_S "\""
#define PLATFORM_DOUBLE_QUOTE_C '\"'
+// Some C functions are locale-sensitive. On IBM i strtod() is
locale-sensitive,
+// such that if running in french locale the strtod() function expects
+// the decimal point to be a comma. If the same holds true with
+// other platforms then you will need to set this define appropriately.
+#define PLATFORM_PROCESS_DECIMAL_POINT_C '.'
+
#define PLATFORM_XML_ENTITY_REFERENCE_CHARS_S "<>&\"\'"
// Case-insensitive string compares
Modified: axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.cpp
URL:
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.cpp?rev=1103926&r1=1103925&r2=1103926&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.cpp (original)
+++ axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.cpp Mon May 16
22:18:07 2011
@@ -30,7 +30,7 @@
#include <except.h>
#include <errno.h>
#include <qwcrtvca.h> // Retrieve job's ccsid API prototype
-
+#include <locale.h>
/**********************************************************************/
@@ -348,6 +348,8 @@ char* asctobuf( char *b, int len )
char PLATFORM_DOUBLE_QUOTE_S[] = "\"";
char PLATFORM_DOUBLE_QUOTE_C = '\"';
char PLATFORM_XML_ENTITY_REFERENCE_CHARS_S[] = "<>&\"\'";
+char PLATFORM_PROCESS_DECIMAL_POINT_C = '.';
+
static int initializePlatform()
{
@@ -370,6 +372,11 @@ static int initializePlatform()
}
}
+ struct lconv * processLocale = localeconv();
+
+ if (processLocale != NULL)
+ PLATFORM_PROCESS_DECIMAL_POINT_C = *(processLocale->decimal_point);
+
return rc;
}
Modified: axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp
URL:
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp?rev=1103926&r1=1103925&r2=1103926&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp Mon May 16
22:18:07 2011
@@ -94,6 +94,12 @@ extern const char EBCDICtoASCII[256];
extern char PLATFORM_DOUBLE_QUOTE_S[];
extern char PLATFORM_DOUBLE_QUOTE_C;
+// Some C functions are locale-sensitive. On IBM i strtod() is
locale-sensitive,
+// such that if running in french locale the strtod() function expects
+// the decimal point to be a comma. If the same holds true with
+// other platforms then you will need to set this define appropriately.
+extern char PLATFORM_PROCESS_DECIMAL_POINT_C;
+
extern char PLATFORM_XML_ENTITY_REFERENCE_CHARS_S[];
// =============================================================
Modified: axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp
URL:
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp?rev=1103926&r1=1103925&r2=1103926&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp
(original)
+++ axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp Mon
May 16 22:18:07 2011
@@ -113,6 +113,12 @@
#define PLATFORM_DOUBLE_QUOTE_S "\""
#define PLATFORM_DOUBLE_QUOTE_C '\"'
+// Some C functions are locale-sensitive. On IBM i strtod() is
locale-sensitive,
+// such that if running in french locale the strtod() function expects
+// the decimal point to be a comma. If the same holds true with
+// other platforms then you will need to set this define appropriately.
+#define PLATFORM_PROCESS_DECIMAL_POINT_C '.'
+
#define PLATFORM_XML_ENTITY_REFERENCE_CHARS_S "<>&\"\'"
// Case-insensitive string compares
Modified: axis/axis1/c/trunk/src/soap/xsd/Decimal.cpp
URL:
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/soap/xsd/Decimal.cpp?rev=1103926&r1=1103925&r2=1103926&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/soap/xsd/Decimal.cpp (original)
+++ axis/axis1/c/trunk/src/soap/xsd/Decimal.cpp Mon May 16 22:18:07 2011
@@ -167,6 +167,20 @@ AxisChar* Decimal::serialize(const xsd__
AxisChar* serializedValue = new char[valueSize];
AxisSprintf (serializedValue, valueSize, formatSpecifier.c_str(), *value);
+ // When sending decimal, double, or float, the decimal point character
must be a period.
+ if (PLATFORM_PROCESS_DECIMAL_POINT_C != '.')
+ {
+ char *p = serializedValue;
+ while (*p)
+ {
+ if (*p == PLATFORM_PROCESS_DECIMAL_POINT_C)
+ {
+ *p = '.';
+ break;
+ }
+ p++;
+ }
+ }
IAnySimpleType::serialize(serializedValue);
delete [] serializedValue;
@@ -176,10 +190,33 @@ AxisChar* Decimal::serialize(const xsd__
xsd__decimal* Decimal::deserializeDecimal(const AxisChar* valueAsChar) throw
(AxisSoapException)
{
AxisChar* end;
+ bool decimalPointChanged = false;
+ // When sending decimal, double, or float, the decimal point character
must be a period.
+ // However, strtod is locale-sensitive, so that for it to function
properly the decimal point
+ // must be set to whatever the locale decimal point is.
+ AxisChar *p = NULL;
+ if (valueAsChar != NULL && PLATFORM_PROCESS_DECIMAL_POINT_C != '.')
+ {
+ p = (AxisChar *)valueAsChar;
+ while (*p)
+ {
+ if (*p == '.')
+ {
+ decimalPointChanged = true;
+ *p = PLATFORM_PROCESS_DECIMAL_POINT_C;
+ break;
+ }
+ p++;
+ }
+ }
+
xsd__decimal * value = new xsd__decimal;
*value = strtod (valueAsChar, &end);
+ if (decimalPointChanged)
+ *p = '.';
+
return value;
}
Modified: axis/axis1/c/trunk/src/soap/xsd/Double.cpp
URL:
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/soap/xsd/Double.cpp?rev=1103926&r1=1103925&r2=1103926&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/soap/xsd/Double.cpp (original)
+++ axis/axis1/c/trunk/src/soap/xsd/Double.cpp Mon May 16 22:18:07 2011
@@ -142,7 +142,22 @@ AxisChar* Double::serialize(const xsd__d
AxisChar serializedValue[80];
AxisSprintf (serializedValue, 80, "%.10g", *value);
-
+
+ // When sending decimal, double, or float, the decimal point character
must be a period.
+ if (PLATFORM_PROCESS_DECIMAL_POINT_C != '.')
+ {
+ char *p = serializedValue;
+ while (*p)
+ {
+ if (*p == PLATFORM_PROCESS_DECIMAL_POINT_C)
+ {
+ *p = '.';
+ break;
+ }
+ p++;
+ }
+ }
+
IAnySimpleType::serialize(serializedValue);
return m_Buf;
}
@@ -150,9 +165,32 @@ AxisChar* Double::serialize(const xsd__d
xsd__double* Double::deserializeDouble(const AxisChar* valueAsChar) throw
(AxisSoapException)
{
AxisChar* end;
+ bool decimalPointChanged = false;
+ // When sending decimal, double, or float, the decimal point character
must be a period.
+ // However, strtod is locale-sensitive, so that for it to function
properly the decimal point
+ // must be set to whatever the locale decimal point is.
+ AxisChar *p = NULL;
+ if (valueAsChar != NULL && PLATFORM_PROCESS_DECIMAL_POINT_C != '.')
+ {
+ p = (AxisChar *)valueAsChar;
+ while (*p)
+ {
+ if (*p == '.')
+ {
+ decimalPointChanged = true;
+ *p = PLATFORM_PROCESS_DECIMAL_POINT_C;
+ break;
+ }
+ p++;
+ }
+ }
+
xsd__double * value = new xsd__double;
*value = strtod (valueAsChar, &end);
+
+ if (decimalPointChanged)
+ *p = '.';
return value;
}
Modified: axis/axis1/c/trunk/src/soap/xsd/Float.cpp
URL:
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/soap/xsd/Float.cpp?rev=1103926&r1=1103925&r2=1103926&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/soap/xsd/Float.cpp (original)
+++ axis/axis1/c/trunk/src/soap/xsd/Float.cpp Mon May 16 22:18:07 2011
@@ -146,6 +146,21 @@ AxisChar* Float::serialize(const xsd__fl
AxisChar serializedValue[80];
AxisSprintf (serializedValue, 80, "%.6g", *value);
+
+ // When sending decimal, double, or float, the decimal point character
must be a period.
+ if (PLATFORM_PROCESS_DECIMAL_POINT_C != '.')
+ {
+ char *p = serializedValue;
+ while (*p)
+ {
+ if (*p == PLATFORM_PROCESS_DECIMAL_POINT_C)
+ {
+ *p = '.';
+ break;
+ }
+ p++;
+ }
+ }
IAnySimpleType::serialize(serializedValue);
return m_Buf;
@@ -154,10 +169,33 @@ AxisChar* Float::serialize(const xsd__fl
xsd__float* Float::deserializeFloat(const AxisChar* valueAsChar) throw
(AxisSoapException)
{
AxisChar* end;
+ bool decimalPointChanged = false;
+
+ // When sending decimal, double, or float, the decimal point character
must be a period.
+ // However, strtod is locale-sensitive, so that for it to function
properly the decimal point
+ // must be set to whatever the locale decimal point is.
+ AxisChar *p = NULL;
+ if (valueAsChar != NULL && PLATFORM_PROCESS_DECIMAL_POINT_C != '.')
+ {
+ p = (AxisChar *)valueAsChar;
+ while (*p)
+ {
+ if (*p == '.')
+ {
+ decimalPointChanged = true;
+ *p = PLATFORM_PROCESS_DECIMAL_POINT_C;
+ break;
+ }
+ p++;
+ }
+ }
xsd__float * value = new xsd__float;
*value = (xsd__float) strtod (valueAsChar, &end);
+ if (decimalPointChanged)
+ *p = '.';
+
return value;
}