[Thuban-commits] r2703 - trunk/thuban/libraries/shapelib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Sep 24 20:51:40 CEST 2006
Author: bernhard
Date: 2006-09-24 20:51:39 +0200 (Sun, 24 Sep 2006)
New Revision: 2703
Modified:
trunk/thuban/libraries/shapelib/dbfopen.c
trunk/thuban/libraries/shapelib/shapefil.h
Log:
Introduced a pointer atof_function which is called by DBFReadAttribute() now.
Default value is &atof, but DBFSetatof_function() can now be used
to change this during runtime.
Modified: trunk/thuban/libraries/shapelib/dbfopen.c
===================================================================
--- trunk/thuban/libraries/shapelib/dbfopen.c 2006-09-24 09:26:21 UTC (rev 2702)
+++ trunk/thuban/libraries/shapelib/dbfopen.c 2006-09-24 18:51:39 UTC (rev 2703)
@@ -255,6 +255,30 @@
static char * pszStringField = NULL;
/************************************************************************/
+/* DBFSet_atof_function() */
+/* */
+/* This makes it possible to initialise a different atof() function */
+/* which might be necessary because the standard atof() might be */
+/* sensitive to locale settings. */
+/* */
+/* If the calling application uses a locale with different decimal_point*/
+/* it should better also give us a locale agnostic atof() function. */
+/* */
+/* As far as I can see from Python PEP331 and GNU libc documentation */
+/* there is no standard for such a function yet. */
+/* */
+/* bernhard.reiter at intevation.de 20060924 */
+/************************************************************************/
+
+static double (* atof_function)(const char *nptr) = &atof;
+
+void SHPAPI_CALL
+ DBFSetatof_function( double (* new_atof_function)(const char *nptr))
+{
+ atof_function = new_atof_function;
+}
+
+/************************************************************************/
/* SfRealloc() */
/* */
/* A realloc cover function that will access a NULL pointer as */
@@ -826,7 +850,7 @@
/* -------------------------------------------------------------------- */
if( chReqType == 'N' )
{
- dDoubleField = atof(pszStringField);
+ dDoubleField = (*atof_function)(pszStringField);
pReturnField = &dDoubleField;
}
Modified: trunk/thuban/libraries/shapelib/shapefil.h
===================================================================
--- trunk/thuban/libraries/shapelib/shapefil.h 2006-09-24 09:26:21 UTC (rev 2702)
+++ trunk/thuban/libraries/shapelib/shapefil.h 2006-09-24 18:51:39 UTC (rev 2703)
@@ -464,6 +464,10 @@
#define XBASE_FLDHDR_SZ 32
+/* to hand over a locale agnostic atof function, if decimal_point != ".\0" */
+void SHPAPI_CALL
+ DBFSetatof_function( double (* new_atof_function)(const char *nptr));
+
DBFHandle SHPAPI_CALL
DBFOpen( const char * pszDBFFile, const char * pszAccess );
DBFHandle SHPAPI_CALL
More information about the Thuban-commits
mailing list