fail for too many args on the CLI

This commit is contained in:
John Cupitt 2011-11-21 18:09:28 +00:00
parent 173576259e
commit 951dc0f83e
3 changed files with 31 additions and 6 deletions

11
TODO
View File

@ -1,12 +1,13 @@
- text vips_complexform()
- imagevec in can be non-NULL if the images do not exist
- try
not enough to check that imagevec is non-NULL, have to check all images too,
argh
$ vips bandjoin a b c
test with
copies a on top of b, ignores c ... argh!!
$ vips bandjoin a b
need to fail if there are unused arguments
where 'a' does not exist

View File

@ -224,10 +224,17 @@ vips_object_print_name( VipsObject *object )
gboolean
vips_object_sanity( VipsObject *object )
{
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsObjectClass *class;
char str[1000];
VipsBuf buf = VIPS_BUF_STATIC( str );
if( !object ) {
printf( "vips_object_sanity: null object\n" );
return( FALSE );
}
class = VIPS_OBJECT_GET_CLASS( object );
class->sanity( object, &buf );
if( !vips_buf_is_empty( &buf ) ) {
printf( "sanity failure: " );

View File

@ -909,6 +909,23 @@ vips_call_argv( VipsOperation *operation, int argc, char **argv )
(void) vips_argument_map( VIPS_OBJECT( operation ),
vips_call_argv_input, &call, NULL );
/* Any unused arguments? We must fail. Consider eg. "vips bandjoin a b
* c". This would overwrite b with a and ignore c, potentially
* disasterous.
*/
if( argc > call.i ) {
vips_error( VIPS_OBJECT_GET_CLASS( operation )->nickname,
"%s", _( "too many arguments" ) );
/* We must unref any output objects, they are holding refs to
* the operation.
*/
(void) vips_argument_map( VIPS_OBJECT( operation ),
vips_call_argv_unref_output, NULL, NULL );
return( -1 );
}
if( vips_object_build( VIPS_OBJECT( operation ) ) ) {
/* We must unref any output objects, they are holding refs to
* the operation.