Alan,

This latest commit breaks plplot for me. The SAHooks functionality suggested 
by Frank is only available in more recent versions of shapelib, certainly more 
recent than is packaged in the latest version of Ubuntu or Debian. Since we do 
not check whether that functionality exists, only if shapelib is available,  
the whole build will fail for older versions. I'd suggest we need to check for 
SAHooks for now and have this additional code within #ifdefs. Shapelib doesn't 
seem to have any versioning information stored in the include files which we 
could use to check for the required version.

Andrew

On Wednesday 27 Nov 2013 06:09:50 air...@users.sourceforge.net wrote:
> Revision: 12758
>           http://sourceforge.net/p/plplot/code/12758
> Author:   airwin
> Date:     2013-11-27 06:09:46 +0000 (Wed, 27 Nov 2013)
> Log Message:
> -----------
> Use an approach suggested by Frank Warmerdam <warmer...@pobox.com>,
> the developer of shapelib to quiet the misleading "Unable to open"
> error messages generated by shapelib due to our method of
> searching several directories until the shapelib routine SHPOpenLL
> returns a non-NULL result indicating shapelib has found shapefiles
> with the correct basename.
> 
> Tested by Alan W. Irwin <air...@users.sourceforge.net> with variants
> of the final CustomErrors to prove this function was being called
> and was correctly suppressing "Unable to open" error messages.
> 
> Modified Paths:
> --------------
>     trunk/src/plmap.c
> 
> Modified: trunk/src/plmap.c
> ===================================================================
> --- trunk/src/plmap.c 2013-11-26 20:59:05 UTC (rev 12757)
> +++ trunk/src/plmap.c 2013-11-27 06:09:46 UTC (rev 12758)
> @@ -50,6 +50,9 @@
>  SHPHandle
>  OpenShapeFile( const char *fn );
> 
> +static void
> +CustomErrors(const char *message);
> +
>  #endif
> 
>  //-------------------------------------------------------------------------
> - @@ -470,19 +473,32 @@
>  //! found
>  //-------------------------------------------------------------------------
> - #ifdef HAVE_SHAPELIB
> +// Our thanks to Frank Warmerdam, the developer of shapelib for suggesting
> +// this approach for quieting shapelib "Unable to open" error messages.
> +static
> +void CustomErrors(const char *message)
> +{
> +    if (strstr(message,"Unable to open") == NULL)
> +        fprintf( stderr, "%s\n", message );
> +}
> +
>  SHPHandle
>  OpenShapeFile( const char *fn )
>  {
>      SHPHandle file;
>      char      *fs = NULL, *dn = NULL;
> +    SAHooks sHooks;
> 
> +    SASetupDefaultHooks( &sHooks );
> +    sHooks.Error = CustomErrors;
> +
>  //***   search build tree               ***
> 
>      if ( plInBuildTree() == 1 )
>      {
>          plGetName( SOURCE_DIR, "data", fn, &fs );
> 
> -        if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
> +        if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
>              goto done;
>      }
> 
> @@ -493,7 +509,7 @@
>      {
>          plGetName( dn, "", fn, &fs );
> 
> -        if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
> +        if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
>              goto done;
>          fprintf( stderr, PLPLOT_LIB_ENV "=\"%s\"\n", dn ); // what IS set?
>      }
> @@ -501,7 +517,7 @@
> 
>  //***        search current directory        ***
> 
> -    if ( ( file = SHPOpen( fn, "rb" ) ) != NULL )
> +    if ( ( file = SHPOpenLL( fn, "rb", &sHooks ) ) != NULL )
>      {
>          pldebug( "OpenShapeFile", "Found file %s in current directory.\n",
> fn ); free_mem( fs );
> @@ -515,7 +531,7 @@
>      {
>          plGetName( dn, "lib", fn, &fs );
> 
> -        if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
> +        if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
>              goto done;
>          fprintf( stderr, PLPLOT_HOME_ENV "=\"%s\"\n", dn ); // what IS set?
> }
> @@ -526,7 +542,7 @@
>  #if defined ( DATA_DIR )
>      plGetName( DATA_DIR, "", fn, &fs );
> 
> -    if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
> +    if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
>          goto done;
>  #endif  // DATA_DIR
> 
> @@ -535,7 +551,7 @@
>  #ifdef PLLIBDEV
>      plGetName( PLLIBDEV, "", fn, &fs );
> 
> -    if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
> +    if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
>          goto done;
>  #endif  // PLLIBDEV
> 
> 
> This was sent by the SourceForge.net collaborative development platform, the
> world's largest Open Source development site.
> 
> 
> ----------------------------------------------------------------------------
> -- Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> _______________________________________________
> Plplot-cvs mailing list
> plplot-...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/plplot-cvs


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to