small fixes

help cleanup and debug if operations fail
This commit is contained in:
John Cupitt 2014-05-16 08:28:44 +01:00
parent bfbc132879
commit 1772588eb6
3 changed files with 21 additions and 17 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
scan scan
compile
po/*.pot po/*.pot
test-driver test-driver
vips-*.tar.gz vips-*.tar.gz

View File

@ -106,14 +106,14 @@ typedef struct _VipsMax {
/* The single max. Can be unset if, for example, the whole image is /* The single max. Can be unset if, for example, the whole image is
* NaN. * NaN.
*/ */
double max; double out;
int x; int x;
int y; int y;
/* And the positions and values we found as VipsArrays for returning /* And the positions and values we found as VipsArrays for returning
* to our caller. * to our caller.
*/ */
VipsArrayDouble *max_array; VipsArrayDouble *out_array;
VipsArrayInt *x_array; VipsArrayInt *x_array;
VipsArrayInt *y_array; VipsArrayInt *y_array;
@ -425,7 +425,7 @@ vips_max_class_init( VipsMaxClass *class )
_( "Output" ), _( "Output" ),
_( "Output value" ), _( "Output value" ),
VIPS_ARGUMENT_REQUIRED_OUTPUT, VIPS_ARGUMENT_REQUIRED_OUTPUT,
G_STRUCT_OFFSET( VipsMax, max ), G_STRUCT_OFFSET( VipsMax, out ),
-INFINITY, INFINITY, 0.0 ); -INFINITY, INFINITY, 0.0 );
VIPS_ARG_INT( class, "x", 2, VIPS_ARG_INT( class, "x", 2,
@ -453,7 +453,7 @@ vips_max_class_init( VipsMaxClass *class )
_( "Output array" ), _( "Output array" ),
_( "Array of output values" ), _( "Array of output values" ),
VIPS_ARGUMENT_OPTIONAL_OUTPUT, VIPS_ARGUMENT_OPTIONAL_OUTPUT,
G_STRUCT_OFFSET( VipsMax, max_array ), G_STRUCT_OFFSET( VipsMax, out_array ),
VIPS_TYPE_ARRAY_DOUBLE ); VIPS_TYPE_ARRAY_DOUBLE );
VIPS_ARG_BOXED( class, "x_array", 7, VIPS_ARG_BOXED( class, "x_array", 7,

View File

@ -601,17 +601,18 @@ static void
transform_array_int_g_string( const GValue *src_value, GValue *dest_value ) transform_array_int_g_string( const GValue *src_value, GValue *dest_value )
{ {
int n; int n;
int *array = vips_value_get_array_int( src_value, &n ); int *array;
char txt[1024]; char txt[1024];
VipsBuf buf = VIPS_BUF_STATIC( txt ); VipsBuf buf = VIPS_BUF_STATIC( txt );
int i; int i;
for( i = 0; i < n; i++ ) if( (array = vips_value_get_array_int( src_value, &n )) )
/* Use space as a separator since ',' may be a decimal point for( i = 0; i < n; i++ )
* in this locale. /* Use space as a separator since ',' may be a
*/ * decimal point in this locale.
vips_buf_appendf( &buf, "%d ", array[i] ); */
vips_buf_appendf( &buf, "%d ", array[i] );
g_value_set_string( dest_value, vips_buf_all( &buf ) ); g_value_set_string( dest_value, vips_buf_all( &buf ) );
} }
@ -689,17 +690,18 @@ static void
transform_array_double_g_string( const GValue *src_value, GValue *dest_value ) transform_array_double_g_string( const GValue *src_value, GValue *dest_value )
{ {
int n; int n;
double *array = vips_value_get_array_double( src_value, &n ); double *array;
char txt[1024]; char txt[1024];
VipsBuf buf = VIPS_BUF_STATIC( txt ); VipsBuf buf = VIPS_BUF_STATIC( txt );
int i; int i;
for( i = 0; i < n; i++ ) if( (array = vips_value_get_array_double( src_value, &n )) )
/* Use space as a separator since ',' may be a decimal point for( i = 0; i < n; i++ )
* in this locale. /* Use space as a separator since ',' may be a decimal
*/ * point in this locale.
vips_buf_appendf( &buf, "%g ", array[i] ); */
vips_buf_appendf( &buf, "%g ", array[i] );
g_value_set_string( dest_value, vips_buf_all( &buf ) ); g_value_set_string( dest_value, vips_buf_all( &buf ) );
} }
@ -1063,7 +1065,8 @@ vips_value_get_array( const GValue *value,
* vips_*_get_type(). * vips_*_get_type().
*/ */
area = g_value_get_boxed( value ); if( !(area = g_value_get_boxed( value )) )
return( NULL );
if( n ) if( n )
*n = area->n; *n = area->n;
if( type ) if( type )