vips.exe is less chatty

This commit is contained in:
John Cupitt 2010-06-24 16:02:00 +00:00
parent 4a43c7b19a
commit 3f8259e390
4 changed files with 38 additions and 63 deletions

View File

@ -3,6 +3,7 @@
- constant ops clip to target range - constant ops clip to target range
- oops, moreconst and moreeqconst were the same - oops, moreconst and moreeqconst were the same
- better buffer handling in sinkdisc for single-line images - better buffer handling in sinkdisc for single-line images
- less chatty errors from "vips"
12/5/10 started 7.22.0 12/5/10 started 7.22.0
- bump and rename - bump and rename

46
TODO
View File

@ -2,52 +2,6 @@
I guess this causes nip2 problems as well? or we call the full name I guess I guess this causes nip2 problems as well? or we call the full name I guess
- change vips error reporting
what we have now:
$ vips im_copy
usage: vips im_copy in out
where:
in is of type "image"
out is of type "image"
copy image, from package "conversion"
flags: (PIO function) (no coordinate transformation) (area operation) (result can be cached)
vips: error calling function
im_run_command: too few arguments
$ vips im_copy ~/pics/babe.jpg /dev/poop.v
usage: vips im_copy in out
where:
in is of type "image"
out is of type "image"
copy image, from package "conversion"
flags: (PIO function) (no coordinate transformation) (area operation) (result can be cached)
vips: error calling function
im_setupout: unable to write to "/dev/poop.v"
should be:
$ vips im_copy
usage: vips im_copy in out
where:
in is of type "image"
out is of type "image"
copy image, from package "conversion"
flags: (PIO function) (no coordinate transformation) (area operation) (result can be cached)
ie. no "error calling function" message
and
$ vips im_copy ~/pics/babe.jpg /dev/poop.v
im_setupout: unable to write to "/dev/poop.v"
ie. no usage message, no "error calling function" message
- lcms2 needs testing - lcms2 needs testing

View File

@ -12,6 +12,8 @@
* 2/10/09 * 2/10/09
* - error_exit() moved here * - error_exit() moved here
* - gtkdoc comments * - gtkdoc comments
* 24/6/10
* - fmt to error_exit() may be NULL
*/ */
/* /*
@ -363,19 +365,27 @@ im_warn( const char *domain, const char *fmt, ... )
* *
* Sends a formatted error message to stderr, then sends the contents of the * Sends a formatted error message to stderr, then sends the contents of the
* error buffer, if any, then terminates the program with an error code. * error buffer, if any, then terminates the program with an error code.
*
* @fmt may be %NULL, in which case only the error buffer is printed before
* exiting.
*
* See also: im_error().
*/ */
void void
error_exit( const char *fmt, ... ) error_exit( const char *fmt, ... )
{ {
va_list ap; if( fmt ) {
va_list ap;
fprintf( stderr, "%s: ", g_get_prgname() ); fprintf( stderr, "%s: ", g_get_prgname() );
va_start( ap, fmt ); va_start( ap, fmt );
(void) vfprintf( stderr, fmt, ap ); (void) vfprintf( stderr, fmt, ap );
va_end( ap ); va_end( ap );
fprintf( stderr, "\n" );
}
fprintf( stderr, "\n" );
fprintf( stderr, "%s", im_error_buffer() ); fprintf( stderr, "%s", im_error_buffer() );
exit( 1 ); exit( 1 );

View File

@ -32,6 +32,8 @@
* - and now we just have --list packages/classes/package-name * - and now we just have --list packages/classes/package-name
* 13/11/09 * 13/11/09
* - drop _f postfixes, drop many postfixes * - drop _f postfixes, drop many postfixes
* 24/6/10
* - less chatty error messages
*/ */
/* /*
@ -884,7 +886,7 @@ main( int argc, char **argv )
int i, j; int i, j;
if( im_init_world( argv[0] ) ) if( im_init_world( argv[0] ) )
error_exit( "unable to start VIPS" ); error_exit( NULL );
textdomain( GETTEXT_PACKAGE ); textdomain( GETTEXT_PACKAGE );
setlocale( LC_ALL, "" ); setlocale( LC_ALL, "" );
@ -920,8 +922,7 @@ main( int argc, char **argv )
if( main_option_plugin ) { if( main_option_plugin ) {
if( !im_load_plugin( main_option_plugin ) ) if( !im_load_plugin( main_option_plugin ) )
error_exit( "unable to load plugin %s", error_exit( NULL );
main_option_plugin );
} }
if( main_option_cpph ) if( main_option_cpph )
print_cppdecls( main_option_cpph ); print_cppdecls( main_option_cpph );
@ -933,7 +934,7 @@ main( int argc, char **argv )
print_list( main_option_list ); print_list( main_option_list );
if( main_option_usage ) { if( main_option_usage ) {
if( !(fn = im_find_function( main_option_usage )) ) if( !(fn = im_find_function( main_option_usage )) )
error_exit( "unknown operation %s", main_option_usage ); error_exit( NULL );
usage( fn ); usage( fn );
} }
if( main_option_version ) if( main_option_version )
@ -971,24 +972,33 @@ main( int argc, char **argv )
name[strlen( name ) - 4] = '\0'; name[strlen( name ) - 4] = '\0';
if( !(fn = im_find_function( name )) ) if( !(fn = im_find_function( name )) )
error_exit( "unknown function" ); error_exit( NULL );
} }
/* Execute it! /* Execute it!
*/ */
if( im_run_command( name, argc - 1, argv + 1 ) ) { if( im_run_command( name, argc - 1, argv + 1 ) ) {
usage( fn ); /* If there are no arguments and the operation failed,
error_exit( "error calling function" ); * show usage. There are no-arg operations, so we have
* to try running it.
*/
if( argc == 1 )
usage( fn );
else
error_exit( NULL );
} }
} }
else if( argc > 1 ) { else if( argc > 1 ) {
/* Nope ... run the first arg instead. /* Nope ... run the first arg instead.
*/ */
if( !(fn = im_find_function( argv[1] )) )
error_exit( NULL );
if( im_run_command( argv[1], argc - 2, argv + 2 ) ) { if( im_run_command( argv[1], argc - 2, argv + 2 ) ) {
if( !(fn = im_find_function( argv[1] )) ) if( argc == 2 )
error_exit( "unknown function" ); usage( fn );
usage( fn ); else
error_exit( "error calling function" ); error_exit( NULL );
} }
} }