better prefix guessing on Windows
see https://github.com/tumagonx/pygi-mingw-patches/issues/5
This commit is contained in:
parent
82994e4c33
commit
6dbdc173a2
@ -7,6 +7,7 @@
|
|||||||
- vips_conv(), vips_compass(), vips_convsep() default to FLOAT precision
|
- vips_conv(), vips_compass(), vips_convsep() default to FLOAT precision
|
||||||
- add FORCE resize mode to break aspect ratio
|
- add FORCE resize mode to break aspect ratio
|
||||||
- add vips_thumbnail_image()
|
- add vips_thumbnail_image()
|
||||||
|
- better prefix guessing on Windows, thanks tumagonx
|
||||||
|
|
||||||
23/4/17 started 8.5.5
|
23/4/17 started 8.5.5
|
||||||
- doc polishing
|
- doc polishing
|
||||||
|
@ -332,7 +332,7 @@ guint32 vips__random( guint32 seed );
|
|||||||
guint32 vips__random_add( guint32 seed, int value );
|
guint32 vips__random_add( guint32 seed, int value );
|
||||||
|
|
||||||
const char *vips__icc_dir( void );
|
const char *vips__icc_dir( void );
|
||||||
const char *vips__locale_dir( void );
|
const char *vips__windows_prefix( void );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -267,6 +267,7 @@ vips_init( const char *argv0 )
|
|||||||
char *prgname;
|
char *prgname;
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
const char *libdir;
|
const char *libdir;
|
||||||
|
char *locale;
|
||||||
|
|
||||||
/* Two stage done handling: 'done' means we've completed, 'started'
|
/* Two stage done handling: 'done' means we've completed, 'started'
|
||||||
* means we're currently initialising. Use this to prevent recursive
|
* means we're currently initialising. Use this to prevent recursive
|
||||||
@ -341,7 +342,9 @@ vips_init( const char *argv0 )
|
|||||||
|
|
||||||
/* Get i18n .mo files from $VIPSHOME/share/locale/.
|
/* Get i18n .mo files from $VIPSHOME/share/locale/.
|
||||||
*/
|
*/
|
||||||
bindtextdomain( GETTEXT_PACKAGE, vips__locale_dir() );
|
locale = g_build_filename( prefix, "share", "locale", NULL );
|
||||||
|
bindtextdomain( GETTEXT_PACKAGE, locale );
|
||||||
|
g_free( locale );
|
||||||
bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" );
|
bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" );
|
||||||
|
|
||||||
/* Deprecated, this is just for compat.
|
/* Deprecated, this is just for compat.
|
||||||
@ -953,8 +956,6 @@ const char *
|
|||||||
vips_guess_prefix( const char *argv0, const char *env_name )
|
vips_guess_prefix( const char *argv0, const char *env_name )
|
||||||
{
|
{
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
char *basename;
|
|
||||||
char name[VIPS_PATH_MAX];
|
|
||||||
|
|
||||||
/* Already set?
|
/* Already set?
|
||||||
*/
|
*/
|
||||||
@ -966,29 +967,18 @@ vips_guess_prefix( const char *argv0, const char *env_name )
|
|||||||
return( prefix );
|
return( prefix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the program name from argv0.
|
#ifdef OS_WIN32
|
||||||
*/
|
prefix = vips__windows_prefix();
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
char *basename;
|
||||||
|
|
||||||
basename = g_path_get_basename( argv0 );
|
basename = g_path_get_basename( argv0 );
|
||||||
|
prefix = guess_prefix( argv0, basename );
|
||||||
/* Add the exe suffix, if it's missing.
|
|
||||||
*/
|
|
||||||
if( strlen( VIPS_EXEEXT ) > 0 ) {
|
|
||||||
const char *olds[] = { VIPS_EXEEXT };
|
|
||||||
|
|
||||||
vips__change_suffix( basename, name,
|
|
||||||
VIPS_PATH_MAX, VIPS_EXEEXT, olds, 1 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
vips_strncpy( name, basename, VIPS_PATH_MAX );
|
|
||||||
|
|
||||||
g_free( basename );
|
g_free( basename );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
printf( "vips_guess_prefix: argv0 = %s\n", argv0 );
|
|
||||||
printf( "vips_guess_prefix: name = %s\n", name );
|
|
||||||
#endif /*DEBUG*/
|
|
||||||
|
|
||||||
prefix = guess_prefix( argv0, name );
|
|
||||||
g_setenv( env_name, prefix, TRUE );
|
g_setenv( env_name, prefix, TRUE );
|
||||||
|
|
||||||
return( prefix );
|
return( prefix );
|
||||||
|
@ -1970,13 +1970,13 @@ vips__icc_dir( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OS_WIN32
|
#ifdef OS_WIN32
|
||||||
static HMODULE vips_dll = NULL;
|
static HMODULE vips__dll = NULL;
|
||||||
#ifdef DLL_EXPORT
|
#ifdef DLL_EXPORT
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
|
DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
|
||||||
{
|
{
|
||||||
if( fdwReason == DLL_PROCESS_ATTACH )
|
if( fdwReason == DLL_PROCESS_ATTACH )
|
||||||
vips_dll = hinstDLL;
|
vips__dll = hinstDLL;
|
||||||
|
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
@ -1984,25 +1984,25 @@ DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
vips_locale_dir_once( void *null )
|
vips__windows_prefix_once( void *null )
|
||||||
{
|
{
|
||||||
char *prefix;
|
char *prefix;
|
||||||
|
|
||||||
#ifdef OS_WIN32
|
#ifdef OS_WIN32
|
||||||
prefix = g_win32_get_package_installation_directory_of_module(
|
prefix = g_win32_get_package_installation_directory_of_module(
|
||||||
vips_dll ),
|
vips__dll ),
|
||||||
#else
|
#else
|
||||||
prefix = (char *) g_getenv( "VIPSHOME" );
|
prefix = (char *) g_getenv( "VIPSHOME" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return( (void *) g_build_filename( prefix, "share", "locale", NULL ) );
|
return( (void *) prefix );
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
vips__locale_dir( void )
|
vips__windows_prefix( void )
|
||||||
{
|
{
|
||||||
static GOnce once = G_ONCE_INIT;
|
static GOnce once = G_ONCE_INIT;
|
||||||
|
|
||||||
return( (const char *) g_once( &once,
|
return( (const char *) g_once( &once,
|
||||||
(GThreadFunc) vips_locale_dir_once, NULL ) );
|
(GThreadFunc) vips__windows_prefix_once, NULL ) );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user