improve realpath() compat on older libc

older libc didn't allow a NULL for the second param
This commit is contained in:
John Cupitt 2019-05-24 15:24:18 +01:00
parent da402cee23
commit 5855321638
4 changed files with 17 additions and 16 deletions

View File

@ -1,3 +1,6 @@
24/5/19 started 8.8.1
- improve realpath() use on older libc
21/9/18 started 8.8.0
- much faster smartcrop [lovell]
- add low/high to smartcrop [jcupitt]

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below
AC_INIT([vips], [8.8.0], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [8.8.1], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ(2.62)
@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [8])
m4_define([vips_minor_version], [8])
m4_define([vips_micro_version], [0])
m4_define([vips_micro_version], [1])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date -u -r ChangeLog`
# binary interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=52
LIBRARY_REVISION=0
LIBRARY_REVISION=1
LIBRARY_AGE=10
# patched into include/vips/version.h

View File

@ -979,24 +979,22 @@ guess_prefix( const char *argv0, const char *name )
}
}
#ifdef HAVE_REALPATH
/* Try to guess from cwd. Only if this is a relative path, though. No
* realpath on winders, but fortunately it seems to always generate
* a full path in argv[0].
/* Try to guess from cwd. Only if this is a relative path, though.
*/
if( !g_path_is_absolute( argv0 ) ) {
char *dir;
char full_path[VIPS_PATH_MAX];
char *resolved;
char *dir;
dir = g_get_current_dir();
vips_snprintf( full_path, VIPS_PATH_MAX,
"%s" G_DIR_SEPARATOR_S "%s", dir, argv0 );
g_free( dir );
if( (resolved = realpath( full_path, NULL )) ) {
if( (resolved = vips_realpath( full_path )) ) {
prefix = extract_prefix( resolved, name );
free( resolved );
g_free( resolved );
if( prefix ) {
#ifdef DEBUG
printf( "vips_guess_prefix: found \"%s\" "
@ -1006,7 +1004,6 @@ guess_prefix( const char *argv0, const char *name )
}
}
}
#endif /*HAVE_REALPATH*/
/* Fall back to the configure-time prefix.
*/

View File

@ -1875,9 +1875,12 @@ vips_realpath( const char *path )
#ifdef HAVE_REALPATH
{
char *real2;
char buf[PATH_MAX];
if( !(real = realpath( path, NULL )) ) {
/* More modern realpath() allow NULL for the second param, but we want
* to work with older libc as well.
*/
if( !(real = realpath( path, buf )) ) {
vips_error_system( errno, "vips_realpath",
"%s", _( "unable to form filename" ) );
return( NULL );
@ -1885,9 +1888,7 @@ vips_realpath( const char *path )
/* We must return a path that can be freed with g_free().
*/
real2 = g_strdup( real );
free( real );
real = real2;
real = g_strdup( real );
}
#else /*!HAVE_REALPATH*/
{