make all tools unicode-aware on windows

sigh
This commit is contained in:
John Cupitt 2016-08-17 12:14:43 +01:00
parent d89dd8d073
commit 030921efc6
5 changed files with 88 additions and 19 deletions

12
TODO
View File

@ -1,14 +1,6 @@
- on win see:
vips2tiff:389 unknown control sequence
\W \S \s \d \c
if( !(buffer = vips__file_read_name( profile, VIPS_ICC_DIR, &length )) )
config.h:#define VIPS_ICC_DIR "C:\Windows\System32\spool\drivers\color"
hehe argh
- done: jpeg, tiff, csv, vips
- add unicode filename test
- add APPROX convsep test?

View File

@ -1027,7 +1027,12 @@ parse_options( GOptionContext *context, int *argc, char **argv )
"OPER", _( "execute vips operation OPER" ) );
g_option_context_set_summary( context, vips_buf_all( &buf ) );
if( !g_option_context_parse( context, argc, &argv, &error ) ) {
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
if( !g_option_context_parse( context, argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
g_error_free( error );
@ -1084,6 +1089,13 @@ main( int argc, char **argv )
textdomain( GETTEXT_PACKAGE );
setlocale( LC_ALL, "" );
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
argv = g_win32_get_command_line();
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#ifdef DEBUG_FATAL
/* Set masks for debugging ... stop on any problem.
*/
@ -1131,7 +1143,12 @@ main( int argc, char **argv )
*/
g_option_context_set_help_enabled( context, FALSE );
if( !g_option_context_parse( context, &argc, &argv, &error ) ) {
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
g_error_free( error );
@ -1140,6 +1157,12 @@ main( int argc, char **argv )
vips_error_exit( NULL );
}
/* On Windows, argc will not have been updated by
* g_option_context_parse_strv().
*/
for( argc = 0; argv[argc]; argc++ )
;
if( main_option_plugin ) {
if( !im_load_plugin( main_option_plugin ) )
vips_error_exit( NULL );
@ -1279,6 +1302,12 @@ main( int argc, char **argv )
g_option_context_free( context );
/* We don't free this on error exit, sadly.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
g_strfreev( argv );
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
vips_shutdown();
return( 0 );

View File

@ -136,6 +136,13 @@ main( int argc, char **argv )
textdomain( GETTEXT_PACKAGE );
setlocale( LC_ALL, "" );
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
argv = g_win32_get_command_line();
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
context = g_option_context_new(
_( "vipsedit - edit vips file header" ) );
main_group = g_option_group_new( NULL, NULL, NULL, NULL, NULL );
@ -144,7 +151,12 @@ main( int argc, char **argv )
g_option_group_set_translation_domain( main_group, GETTEXT_PACKAGE );
g_option_context_set_main_group( context, main_group );
if( !g_option_context_parse( context, &argc, &argv, &error ) ) {
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
g_error_free( error );
@ -152,7 +164,14 @@ main( int argc, char **argv )
exit( -1 );
}
if( argc != 2 ) {
/* On Windows, argc will not have been updated by
* g_option_context_parse_strv().
*/
for( argc = 0; argv[argc]; argc++ )
;
if( argc != 2 ) {
fprintf( stderr, _( "usage: %s [OPTION...] vips-file\n" ),
g_get_prgname() );
exit( -1 );
@ -239,6 +258,12 @@ main( int argc, char **argv )
im_close( im );
/* We don't free this on error exit, sadly.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
g_strfreev( argv );
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
vips_shutdown();
return( 0 );

View File

@ -189,6 +189,13 @@ main( int argc, char *argv[] )
textdomain( GETTEXT_PACKAGE );
setlocale( LC_ALL, "" );
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
argv = g_win32_get_command_line();
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
context = g_option_context_new( _( "- print image header" ) );
main_group = g_option_group_new( NULL, NULL, NULL, NULL, NULL );
g_option_group_add_entries( main_group, main_option );
@ -196,7 +203,12 @@ main( int argc, char *argv[] )
g_option_group_set_translation_domain( main_group, GETTEXT_PACKAGE );
g_option_context_set_main_group( context, main_group );
if( !g_option_context_parse( context, &argc, &argv, &error ) ) {
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
g_error_free( error );
@ -209,7 +221,7 @@ main( int argc, char *argv[] )
result = 0;
for( i = 1; i < argc; i++ ) {
for( i = 1; argv[i]; i++ ) {
VipsImage *im;
if( !(im = vips_image_new_from_file( argv[i], NULL )) ) {
@ -218,7 +230,7 @@ main( int argc, char *argv[] )
}
if( im &&
print_header( im, argc > 2 ) ) {
print_header( im, argv[2] != NULL ) ) {
print_error();
result = 1;
}
@ -227,6 +239,12 @@ main( int argc, char *argv[] )
g_object_unref( im );
}
/* We don't free this on error exit, sadly.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
g_strfreev( argv );
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
vips_shutdown();
return( result );

View File

@ -695,7 +695,12 @@ main( int argc, char **argv )
g_option_group_set_translation_domain( main_group, GETTEXT_PACKAGE );
g_option_context_set_main_group( context, main_group );
if( !g_option_context_parse( context, &argc, &argv, &error ) ) {
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
g_error_free( error );
@ -725,7 +730,7 @@ main( int argc, char **argv )
result = 0;
for( i = 1; i < argc; i++ ) {
for( i = 1; argv[i]; i++ ) {
/* Hang resources for processing this thumbnail off @process.
*/
VipsObject *process = VIPS_OBJECT( vips_image_new() );