Skip to content

Instantly share code, notes, and snippets.

@felixbuenemann
Created August 4, 2017 17:32
Show Gist options
  • Save felixbuenemann/00c6e802b25a413e298187fc7ec99ee5 to your computer and use it in GitHub Desktop.
Save felixbuenemann/00c6e802b25a413e298187fc7ec99ee5 to your computer and use it in GitHub Desktop.
diff --git a/libvips/convolution/conva.c b/libvips/convolution/conva.c
index 2b3a48bdf..49aed0aa2 100644
--- a/libvips/convolution/conva.c
+++ b/libvips/convolution/conva.c
@@ -79,9 +79,9 @@ sys 0m0.100s
*/
/*
- */
#define DEBUG
#define VIPS_DEBUG
+ */
#ifdef HAVE_CONFIG_H
#include <config.h>
diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c
index a606f8a4b..f7657e6a8 100644
--- a/libvips/iofuncs/init.c
+++ b/libvips/iofuncs/init.c
@@ -26,6 +26,8 @@
* constructed before we go parallel
* 18/9/16
* - call _setmaxstdio() on win32
+ * 4/8/17
+ * - hide warnings is VIPS_WARNING is set
*/
/*
@@ -241,6 +243,15 @@ vips_load_plugins( const char *fmt, ... )
return( result );
}
+/* Install this log handler to hide warning messages.
+ */
+static void
+empty_log_handler( const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message, gpointer user_data )
+{
+}
+
+
/**
* vips_init:
* @argv0: name of application
@@ -442,6 +453,18 @@ vips_init( const char *argv0 )
done = TRUE;
+ /* If VIPS_WARNING is defined, suppress all warning messages from vips.
+ *
+ * Libraries should not call g_log_set_handler(), it is
+ * supposed to be for the application layer, but this can be awkward to
+ * set up if you are using libvips from something like Ruby. Allow this
+ * env var hack as a workaround.
+ */
+ if( g_getenv( "VIPS_WARNING" ) ||
+ g_getenv( "IM_WARNING" ) )
+ g_log_set_handler( "VIPS", G_LOG_LEVEL_WARNING,
+ empty_log_handler, NULL );
+
vips__thread_gate_stop( "init: startup" );
return( 0 );
diff --git a/libvips/mosaicing/im_lrmerge.c b/libvips/mosaicing/im_lrmerge.c
index 5ce599eaa..cdb012cc9 100644
--- a/libvips/mosaicing/im_lrmerge.c
+++ b/libvips/mosaicing/im_lrmerge.c
@@ -392,7 +392,7 @@ make_firstlast( MergeInfo *inf, Overlapping *ovlap, Rect *oreg )
int ii; \
\
for( ii = 0; ii < cb; ii++ ) \
- if( tt[i] ) \
+ if( tt[i + ii] ) \
break; \
if( ii == cb ) \
(RESULT) = 1; \
diff --git a/libvips/mosaicing/im_tbmerge.c b/libvips/mosaicing/im_tbmerge.c
index 38079b257..09afb6ff3 100644
--- a/libvips/mosaicing/im_tbmerge.c
+++ b/libvips/mosaicing/im_tbmerge.c
@@ -335,7 +335,7 @@ make_firstlast( MergeInfo *inf, Overlapping *ovlap, Rect *oreg )
int ii; \
\
for( ii = 0; ii < cb; ii++ ) \
- if( tt[i] ) \
+ if( tt[i + ii] ) \
break; \
if( ii == cb ) \
(RESULT) = 1; \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment