From: Werner Koch Date: Thu, 5 Jan 2006 08:58:50 +0000 (+0000) Subject: Minor glib fix. X-Git-Tag: gpgme-1-1-1~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5b57bff96cc4eed3afa47eb10ac7fdbfd163b24d;p=gpgme.git Minor glib fix. Pretty up debug output. --- diff --git a/ChangeLog b/ChangeLog index 82fa65a..3f2b4ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-05 Werner Koch + + * configure.ac: Test for inline feature. + (AH_BOTTOM): New to define the pure attribute. + 2006-01-03 Werner Koch * configure.ac: Append SVN revision to the version. diff --git a/configure.ac b/configure.ac index 635dc8c..b85f049 100644 --- a/configure.ac +++ b/configure.ac @@ -180,6 +180,7 @@ AC_CHECK_HEADERS(sys/select.h) # Type checks. +AC_C_INLINE AC_CHECK_SIZEOF(unsigned int) AC_SYS_LARGEFILE AC_TYPE_OFF_T @@ -507,6 +508,15 @@ AH_VERBATIM([SEPCONSTANTS], #endif ]) +AH_BOTTOM([ +/* Definition of GCC specific attributes. */ +#if __GNUC__ > 2 +# define GPGME_GCC_A_PURE __attribute__ ((__pure__)) +#else +# define GPGME_GCC_A_PURE +#endif +]) + # Substitution used for gpgme-config GPGME_CONFIG_LIBS="-lgpgme" diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index ed7377d..6996bd7 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,10 @@ +2006-01-04 Werner Koch + + * debug.h (_gpgme_debug_srcname): New. Use it with the debug macros. + + * w32-glib-io.c (_gpgme_io_set_nonblocking): Add debug + statements. Disable error return for failed nonblocking call. + 2006-01-03 Marcus Brinkmann * w32-glib-io.c (_gpgme_io_close): Only close fd if there is no diff --git a/gpgme/debug.c b/gpgme/debug.c index c51f05a..870976c 100644 --- a/gpgme/debug.c +++ b/gpgme/debug.c @@ -1,6 +1,6 @@ /* debug.c - helpful output in desperate situations Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH This file is part of GPGME. diff --git a/gpgme/debug.h b/gpgme/debug.h index b05e167..ef5a400 100644 --- a/gpgme/debug.h +++ b/gpgme/debug.h @@ -1,5 +1,5 @@ /* debug.h - interface to debugging functions - Copyright (C) 2002, 2004 g10 Code GmbH + Copyright (C) 2002, 2004, 2005 g10 Code GmbH This file is part of GPGME. @@ -21,6 +21,20 @@ #ifndef DEBUG_H #define DEBUG_H +#include + +/* Remove path components from filenames (i.e. __FILE__) for cleaner + logs. */ +static inline const char *_gpgme_debug_srcname (const char *file) + GPGME_GCC_A_PURE; + +static inline const char * +_gpgme_debug_srcname (const char *file) +{ + const char *s = strrchr (file, '/'); + return s? s+1:file; +} + /* Log the formatted string FORMAT at debug level LEVEL or higher. */ void _gpgme_debug (int level, const char *format, ...); @@ -76,22 +90,26 @@ void _gpgme_debug_end (void **helper); #else /* This finally works everywhere, horror. */ #define DEBUG0(fmt) \ - _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__)) + _gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \ + XSTRINGIFY (__LINE__)) #define DEBUG1(fmt,a) \ - _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a)) + _gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \ + XSTRINGIFY (__LINE__), (a)) #define DEBUG2(fmt,a,b) \ - _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b)) + _gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \ + XSTRINGIFY (__LINE__), (a), (b)) #define DEBUG3(fmt,a,b,c) \ - _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \ - (c)) + _gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \ + XSTRINGIFY (__LINE__), (a), (b), (c)) #define DEBUG4(fmt,a,b,c,d) \ - _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \ - (c), (d)) + _gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \ + XSTRINGIFY (__LINE__), (a), (b), (c), (d)) #define DEBUG5(fmt,a,b,c,d,e) \ - _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \ - (c), (d), (e)) + _gpgme_debug (1, "%s:%s: " fmt, _gpgme_debug_srcname (__FILE__), \ + XSTRINGIFY (__LINE__), (a), (b), (c), (d), (e)) #define DEBUG_BEGIN(hlp,lvl,fmt) \ - _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__)) + _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, \ + _gpgme_debug_srcname (__FILE__), XSTRINGIFY (__LINE__)) #define DEBUG_ADD0(hlp,fmt) \ _gpgme_debug_add (&(hlp), fmt) #define DEBUG_ADD1(hlp,fmt,a) \ diff --git a/gpgme/gpgme.h b/gpgme/gpgme.h index e056735..40ca9aa 100644 --- a/gpgme/gpgme.h +++ b/gpgme/gpgme.h @@ -72,7 +72,7 @@ extern "C" { AM_PATH_GPGME macro) check that this header matches the installed library. Warning: Do not edit the next line. configure will do that for you! */ -#define GPGME_VERSION "1.1.1-cvs" +#define GPGME_VERSION "1.1.1-cvs1149" diff --git a/gpgme/w32-glib-io.c b/gpgme/w32-glib-io.c index 7dd5740..593cfba 100644 --- a/gpgme/w32-glib-io.c +++ b/gpgme/w32-glib-io.c @@ -290,6 +290,7 @@ _gpgme_io_close (int fd) else _close (fd); + return 0; } @@ -313,21 +314,25 @@ _gpgme_io_set_nonblocking (int fd) { GIOChannel *chan; GIOStatus status; - + chan = find_channel (fd, 0); if (!chan) { + DEBUG1 ("set nonblocking for fd %d failed: channel not found", fd); errno = EIO; return -1; } - status = g_io_channel_set_flags (chan, + status = g_io_channel_set_flags (chan, g_io_channel_get_flags (chan) | G_IO_FLAG_NONBLOCK, NULL); if (status != G_IO_STATUS_NORMAL) { - errno = EIO; - return -1; + /* glib 1.9.2 does not implement set_flags and returns an error. */ + DEBUG2 ("set nonblocking for fd %d failed: status=%d - ignored", + fd, status); +/* errno = EIO; */ +/* return -1; */ } return 0;