From e5425081cc1b0787a7a7ac518d5c1be0843b9bbd Mon Sep 17 00:00:00 2001 From: djcb Date: Thu, 8 Nov 2012 22:19:28 +0200 Subject: [PATCH] * remove hard dependency on wordexp.h (OpenBSD does not have it) --- configure.ac | 46 +++++++++++++++++++++++----------------- lib/mu-util.c | 14 +++++++++--- lib/tests/test-mu-util.c | 6 ++++-- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index d2dc0fe5..86a86e13 100644 --- a/configure.ac +++ b/configure.ac @@ -43,8 +43,8 @@ AM_PROG_LIBTOOL AC_PROG_AWK AC_CHECK_PROG(SORT,sort,sort) - -AC_CHECK_HEADERS([locale.h langinfo.h wordexp.h]) + +AC_CHECK_HEADERS([wordexp.h]) # use the 64-bit versions AC_SYS_LARGEFILE @@ -365,6 +365,7 @@ echo "Emacs version : $emacs_version" fi echo +echo "Have wordexp : $ac_cv_header_wordexp_h" echo "Build mu4e emacs frontend : $build_mu4e" echo "Build crypto support (gmime >= 2.6) : $have_gmime_26" echo "Build 'mug' toy-ui (gtk+/webkit) : $buildgui" @@ -376,31 +377,38 @@ echo "Have direntry->d_type : $use_dirent_d_type" echo "------------------------------------------------" echo +# +# Warnings / notes +# + +# makeinfo if test "x$have_makeinfo" != "xyes"; then - echo "You do not seem to have the makeinfo program; if you are building from git" - echo "you need that to create documentation for guile and emacs. It is in the" - echo "texinfo package in debian/ubuntu (ie., apt-get install texinfo)" + echo "* You do not seem to have the makeinfo program; if you are building from git" + echo " you need that to create documentation for guile and emacs. It is in the" + echo " texinfo package in debian/ubuntu (ie., apt-get install texinfo)" + echo fi - +# gui if test "x$buildgui" = "xyes"; then - echo "The demo UIs are in toys/mug and toys/mug2" - if test "x$gui" = "xgtk3"; then - echo "Note that mug2 will *not* work with gtk+3, because it depends" - echo "on libraries that use gtk+2, and the two can't be in one process" - fi + echo "* The demo UI will be built in toys/mug" + echo fi -if test "x$GUILE_MAJOR_VERSION" = "x1"; then - echo - echo "NOTE: If you have troubles with linking the guile-related stuff, it" - echo "might help to move .la-files out of the way" - echo - echo "See e.g: http://blog.flameeyes.eu/2008/04/14/what-about-those-la-files" +# the unit tests +echo "* You can run 'make check' to run the unit tests" +echo + +# wordexp +if test "x$ac_cv_header_wordexp_h" != "xyes"; then + echo "* Your system does not seem to have the 'wordexp' function." + echo " This means that you cannot use shell-like expansion in options and " + echo " some other places. So, for example, instead of" + echo " --maildir=~/Maildir" + echo " you should use the complete path, something like:" + echo " --maildir=/home/user/Maildir" fi echo echo "Now, type 'make' to build mu." echo -echo "If unit tests are built (see above), you can run 'make check'" -echo "for some basic testing of mu functionality." diff --git a/lib/mu-util.c b/lib/mu-util.c index d65a7ea7..7c5c48b6 100644 --- a/lib/mu-util.c +++ b/lib/mu-util.c @@ -24,9 +24,12 @@ #endif /*HAVE_CONFIG_H*/ #include "mu-util.h" - #define _XOPEN_SOURCE 500 + +#ifdef HAVE_WORDEXP_H #include /* for shell-style globbing */ +q#endif /*HAVE_WORDEXP_H*/ + #include #include @@ -43,9 +46,11 @@ #include + static char* do_wordexp (const char *path) { +#ifdef HAVE_WORDEXP_H wordexp_t wexp; char *dir; @@ -69,10 +74,13 @@ do_wordexp (const char *path) #ifndef __APPLE__ wordfree (&wexp); #endif /*__APPLE__*/ - return dir; -} +# else /*!HAVE_WORDEXP_H*/ +/* E.g. OpenBSD does not have wordexp.h, so we ignore it */ + return path ? g_strdup (path) : NULL; +#endif /*HAVE_WORDEXP_H*/ +} /* note, the g_debugs are commented out because this function may be diff --git a/lib/tests/test-mu-util.c b/lib/tests/test-mu-util.c index 82e1a97f..93d6d5f0 100644 --- a/lib/tests/test-mu-util.c +++ b/lib/tests/test-mu-util.c @@ -34,6 +34,7 @@ static void test_mu_util_dir_expand_00 (void) { +#ifdef HAVE_WORDEXP_H gchar *got, *expected; got = mu_util_dir_expand ("~/IProbablyDoNotExist"); @@ -44,12 +45,13 @@ test_mu_util_dir_expand_00 (void) g_free (got); g_free (expected); - +#endif /*HAVE_WORDEXP_H*/ } static void test_mu_util_dir_expand_01 (void) { +#ifdef HAVE_WORDEXP_H gchar *got, *expected; got = mu_util_dir_expand ("~/Desktop"); @@ -60,7 +62,7 @@ test_mu_util_dir_expand_01 (void) g_free (got); g_free (expected); - +#endif /*HAVE_WORDEXP_H*/ }