[Thuban-commits] r2809 - in branches/WIP-pyshapelib-Unicode/thuban: . libraries/pyshapelib libraries/shapelib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jan 16 21:27:54 CET 2008


Author: bramz
Date: 2008-01-16 21:27:53 +0100 (Wed, 16 Jan 2008)
New Revision: 2809

Modified:
   branches/WIP-pyshapelib-Unicode/thuban/ChangeLog
   branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/ChangeLog
   branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/pyshapelib_common.h
   branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/setup.py
   branches/WIP-pyshapelib-Unicode/thuban/libraries/shapelib/safileio.c
   branches/WIP-pyshapelib-Unicode/thuban/libraries/shapelib/shapefil.h
   branches/WIP-pyshapelib-Unicode/thuban/setup.py
Log:
updated shapelib from cvs.maptools.org.
pyshapelib: only use PyOs_ascii_atof if available.

Modified: branches/WIP-pyshapelib-Unicode/thuban/ChangeLog
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/ChangeLog	2008-01-16 15:37:58 UTC (rev 2808)
+++ branches/WIP-pyshapelib-Unicode/thuban/ChangeLog	2008-01-16 20:27:53 UTC (rev 2809)
@@ -1,8 +1,13 @@
 2008-01-16   Bram de Greve <bram.degreve at bramz.net>
 
-	Forward porting trunk (2801:2807] to WIP-pyshapelib-Unicode branch.
+	* Forward porting trunk (2801:2807] to WIP-pyshapelib-Unicode branch.
 	The previous merge was erroneously indicated as (2793:2793],
 	that should have been (2793:2801].
+	
+	* libraries/shapelib: forward ported from cvs.maptools.org:
+	shapefil.h v1.44, safileio.c v1.4
+	
+	* setup.py: updated for pyshapelib
 
 2008-01-09   Bernhard Reiter <bernhard at intevation.de>
 

Modified: branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/ChangeLog
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/ChangeLog	2008-01-16 15:37:58 UTC (rev 2808)
+++ branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/ChangeLog	2008-01-16 20:27:53 UTC (rev 2809)
@@ -1,3 +1,12 @@
+2008-01-16  Bram de Greve <bram.degreve at bramz.net>
+
+	* pyshapelib_common.h, setup.py: as shapefil.h r1.44 of cvs.maptools.org
+	now defines SHPAPI_UTF8_HOOKS, we no longer need to check for the 
+	availabitity of SASetupUtf8Hooks ourselves.
+	
+	* pyshapelib_common.h: only use PyOs_ascii_atof if >= Python 2.4.  Otherwise
+	use the standard atof function.
+
 2008-01-15  Bram de Greve <bram.degreve at bramz.net>
 
 	* shapelibmodule.c: In shapefile_write_object, use PyArg_ParseTuple to

Modified: branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/pyshapelib_common.h
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/pyshapelib_common.h	2008-01-16 15:37:58 UTC (rev 2808)
+++ branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/pyshapelib_common.h	2008-01-16 20:27:53 UTC (rev 2809)
@@ -85,16 +85,24 @@
 
 /* helpers to setup the shapelib API hooks correctly
  */
-#if HAVE_UTF8_HOOKS && defined(MS_WINDOWS)
+#if PY_VERSION_HEX >=0x02040000
+#	define PYSHAPELIB_ATOF PyOS_ascii_atof
+#else
+#	define PYSHAPELIB_ATOF atof
+#endif
+
+#if defined(SHPAPI_UTF8_HOOKS) && defined(SHPAPI_WINDOWS)
+#	define HAVE_UTF8_HOOKS 1
 #	define PYSHAPELIB_FILENAME_ENCODING "utf-8"
 #	define PYSHAPELIB_SETUPHOOKS(pHooks)\
 		SASetupUtf8Hooks(pHooks);\
-		(pHooks)->Atof = PyOS_ascii_atof
+		(pHooks)->Atof = PYSHAPELIB_ATOF
 #else
+#	define HAVE_UTF8_HOOKS 0
 #	define PYSHAPELIB_FILENAME_ENCODING Py_FileSystemDefaultEncoding
 #	define PYSHAPELIB_SETUPHOOKS(pHooks)\
 		SASetupDefaultHooks(pHooks);\
-		(pHooks)->Atof = PyOS_ascii_atof
+		(pHooks)->Atof = PYSHAPELIB_ATOF
 #endif
 
 

Modified: branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/setup.py
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/setup.py	2008-01-16 15:37:58 UTC (rev 2808)
+++ branches/WIP-pyshapelib-Unicode/thuban/libraries/pyshapelib/setup.py	2008-01-16 20:27:53 UTC (rev 2809)
@@ -31,8 +31,8 @@
 	print >>sys.stderr, "no shapelib directory found"
 	sys.exit(1)
 
-def determine_macros():
-	"""Return the macros to define when compiling the shapelib and dbflib wrapper.
+def dbf_macros():
+	"""Return the macros to define when compiling the dbflib wrapper.
 
 	The returned list specifies following macros:
 	- HAVE_UPDATE_HEADER, which is 
@@ -43,8 +43,6 @@
 	- HAVE_CODE_PAGE, which is '1' if the dbflib version we will 
 	compiling with has the DBFGetCodePage function and '0' otherwise.
 	Again, shapefil.h is scanned to check this.
-	- HAVE_UTF8_HOOKS, which is '1' if shapelib and dbflib can use UTF-8 filenames
-	on Windows.
 	"""
 	f = open(convert_path(shp_dir + "/shapefil.h"))
 	contents = f.read()
@@ -57,8 +55,7 @@
 	
 	return [
 		("HAVE_UPDATE_HEADER", have("DBFUpdateHeader")),
-		("HAVE_CODE_PAGE", have("DBFGetCodePage")),
-		("HAVE_UTF8_HOOKS", have("SASetupUtf8Hooks"))]
+		("HAVE_CODE_PAGE", have("DBFGetCodePage"))]
 
 
 
@@ -72,7 +69,6 @@
 
 
 
-macros = determine_macros()
 sahooks_files = search_sahooks_files()
 
 extensions = [Extension("shapelib",
@@ -80,8 +76,7 @@
 						shp_dir + "/shpopen.c",
 						shp_dir + "/shptree.c"]
 						+ sahooks_files,
-						include_dirs = [shp_dir],
-						define_macros = macros),
+						include_dirs = [shp_dir]),
 			Extension("shptree",
 						["shptreemodule.c"],
 						include_dirs = [shp_dir]),
@@ -90,7 +85,7 @@
 						shp_dir + "/dbfopen.c"]
 						+ sahooks_files,
 						include_dirs = [shp_dir],
-						define_macros = macros)]
+						define_macros =dbf_macros())]
 
 setup(name = "pyshapelib",
 	version = "0.4",

Modified: branches/WIP-pyshapelib-Unicode/thuban/libraries/shapelib/safileio.c
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/libraries/shapelib/safileio.c	2008-01-16 15:37:58 UTC (rev 2808)
+++ branches/WIP-pyshapelib-Unicode/thuban/libraries/shapelib/safileio.c	2008-01-16 20:27:53 UTC (rev 2809)
@@ -61,12 +61,13 @@
 
 SHP_CVSID("$Id: safileio.c,v 1.3 2007/12/18 18:28:11 bram Exp $");
 
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
-#	define SA_UTF8_WINDOWS
-#   define WIN32_LEAN_AND_MEAN
-#   define NOMINMAX
-#   include <windows.h>
-#   pragma comment(lib, "kernel32.lib")
+#ifdef SHPAPI_UTF8_HOOKS
+#   ifdef SHPAPI_WINDOWS
+#       define WIN32_LEAN_AND_MEAN
+#       define NOMINMAX
+#       include <windows.h>
+#       pragma comment(lib, "kernel32.lib")
+#   endif
 #endif
 
 /************************************************************************/
@@ -184,7 +185,7 @@
 
 
 
-#ifdef SA_UTF8_WINDOWS
+#ifdef SHPAPI_WINDOWS
 
 /************************************************************************/
 /*                          Utf8ToWideChar                              */
@@ -251,13 +252,15 @@
 
 #endif
 
+#ifdef SHPAPI_UTF8_HOOKS
+
 /************************************************************************/
 /*                          SASetupUtf8Hooks()                          */
 /************************************************************************/
 
 void SASetupUtf8Hooks( SAHooks *psHooks )
 {
-#ifdef SA_UTF8_WINDOWS    
+#ifdef SHPAPI_WINDOWS    
     psHooks->FOpen   = SAUtf8WFOpen;
     psHooks->Remove  = SAUtf8WRemove;
 #else
@@ -274,3 +277,5 @@
     psHooks->Error   = SADError;
     psHooks->Atof    = atof;
 }
+
+#endif

Modified: branches/WIP-pyshapelib-Unicode/thuban/libraries/shapelib/shapefil.h
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/libraries/shapelib/shapefil.h	2008-01-16 15:37:58 UTC (rev 2808)
+++ branches/WIP-pyshapelib-Unicode/thuban/libraries/shapelib/shapefil.h	2008-01-16 20:27:53 UTC (rev 2809)
@@ -1,5 +1,5 @@
-#ifndef _SHAPEFILE_H_INCLUDED
-#define _SHAPEFILE_H_INCLUDED
+#ifndef SHAPEFILE_H_INCLUDED
+#define SHAPEFILE_H_INCLUDED
 
 /******************************************************************************
  * $Id$
@@ -37,6 +37,15 @@
  ******************************************************************************
  *
  * $Log: shapefil.h,v $
+ * Revision 1.44  2008/01/16 20:05:19  bram
+ * Add file hooks that accept UTF-8 encoded filenames on some platforms.  Use SASetupUtf8Hooks
+ *  tosetup the hooks and check SHPAPI_UTF8_HOOKS for its availability.  Currently, this
+ *  is only available on the Windows platform that decodes the UTF-8 filenames to wide
+ *  character strings and feeds them to _wfopen and _wremove.
+ *
+ * Revision 1.43  2008/01/10 16:35:30  fwarmerdam
+ * avoid _ prefix on #defined symbols (bug 1840)
+ *
  * Revision 1.42  2007/12/18 18:28:14  bram
  * - create hook for client specific atof (bugzilla ticket 1615)
  * - check for NULL handle before closing cpCPG file, and close after reading.
@@ -195,8 +204,17 @@
 #else
 #  define SHP_CVSID(string)
 #endif
-    
+
 /* -------------------------------------------------------------------- */
+/*      On some platforms, additional file IO hooks are defined that    */
+/*      UTF-8 encoded filenames Unicode filenames                       */
+/* -------------------------------------------------------------------- */
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+#	define SHPAPI_WINDOWS
+#	define SHPAPI_UTF8_HOOKS
+#endif
+
+/* -------------------------------------------------------------------- */
 /*      IO/Error hook functions.                                        */
 /* -------------------------------------------------------------------- */
 typedef int *SAFile;
@@ -220,7 +238,9 @@
 } SAHooks;
 
 void SHPAPI_CALL SASetupDefaultHooks( SAHooks *psHooks );
+#ifdef SHPAPI_UTF8_HOOKS
 void SHPAPI_CALL SASetupUtf8Hooks( SAHooks *psHooks );
+#endif
 
 /************************************************************************/
 /*                             SHP Support.                             */
@@ -576,4 +596,4 @@
 }
 #endif
 
-#endif /* ndef _SHAPEFILE_H_INCLUDED */
+#endif /* ndef SHAPEFILE_H_INCLUDED */

Modified: branches/WIP-pyshapelib-Unicode/thuban/setup.py
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/setup.py	2008-01-16 15:37:58 UTC (rev 2808)
+++ branches/WIP-pyshapelib-Unicode/thuban/setup.py	2008-01-16 20:27:53 UTC (rev 2809)
@@ -269,7 +269,7 @@
 # shapelib wrappers are also distributed with thuban
 #
 
-def determine_macros():
+def determine_shapelib_macros():
     f = open(convert_path(shp_dir + "/shapefil.h"))
     contents = f.read()
     f.close()
@@ -281,14 +281,13 @@
     
     return [
         ("HAVE_UPDATE_HEADER", have("DBFUpdateHeader")),
-        ("HAVE_CODE_PAGE", have("DBFGetCodePage")),
-        ("HAVE_UTF8_HOOKS", have("SASetupUtf8Hooks"))]
+        ("HAVE_CODE_PAGE", have("DBFGetCodePage"))]
 
 def search_sahooks_files():
     candidates = [shp_dir + "/safileio.c"]
     return filter(os.path.exists, candidates)
 
-macros = determine_macros()
+shapelib_macros = determine_shapelib_macros()
 sahooks_files = search_sahooks_files()
 
 extensions.append(Extension("Lib.shapelib",
@@ -296,8 +295,7 @@
                              shp_dir + "/shpopen.c",
                              shp_dir + "/shptree.c"]
                             + sahooks_files,
-                            include_dirs = [shp_dir],
-                            define_macros = macros))
+                            include_dirs = [shp_dir]))
 extensions.append(Extension("Lib.shptree",
                             [ext_dir + "/pyshapelib/shptreemodule.c"],
                             include_dirs = [shp_dir]))
@@ -306,7 +304,7 @@
                              shp_dir + "/dbfopen.c"]
                             + sahooks_files,
                             include_dirs = [shp_dir],
-                            define_macros = macros))
+                            define_macros = shapelib_macros))
 
 
 #



More information about the Thuban-commits mailing list