diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-04-01 23:47:59 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-04-01 23:47:59 +0300 |
commit | c5416aa2097f666cfc7701210872000871f65abb (patch) | |
tree | 63d86b6ea0ce908271a195bcdbe04e51e50e7ee6 | |
parent | 26ff8a3fed46bd8d11647a70fffc3c62fc7c84e7 (diff) | |
download | anubis-c5416aa2097f666cfc7701210872000871f65abb.tar.gz anubis-c5416aa2097f666cfc7701210872000871f65abb.tar.bz2 |
Prepare for Guile 2.0: fix obsolete and deprecated calls in Guile code.
* am/guile.m4: Import from Mailutils.
* configure.ac: Use AC_DEFINE_UNQUOTED to define
a replacement for socklen_t.
* src/guile.c (guile_debug): Protect calls to
SCM_DEVAL_P &c. by #ifdef GUILE_DEBUG_MACROS
(guile_process_proc_handler): Use scm_apply_3
to avoid unwanted evaluation of parameters.
(guile_load_path_append_handler)
(guile_to_anubis, guile_process_proc): Remove the uses of
deprecated Guile functions.
* src/logport.c [!HAVE_SCM_T_OFF](scm_t_off): New typedef.
(scm_tc16_anubis_error_port)
(scm_tc16_anubis_info_port): Change type to scm_t_bits.
(_make_anubis_log_port): Use scm_new_port_table_entry instead
of the deprecated scm_add_to_port_table.
(_anubis_error_port_seek): Fix signature and return type.
-rw-r--r-- | am/guile.m4 | 156 | ||||
-rw-r--r-- | build/.gitignore | 3 | ||||
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | lib/.gitignore | 3 | ||||
-rw-r--r-- | src/guile.c | 45 | ||||
-rw-r--r-- | src/logport.c | 21 |
6 files changed, 112 insertions, 123 deletions
diff --git a/am/guile.m4 b/am/guile.m4 index 7109c42..8841a6a 100644 --- a/am/guile.m4 +++ b/am/guile.m4 @@ -1,101 +1,85 @@ dnl This file is part of GNU mailutils. -dnl Copyright (C) 2001, 2003, 2004, 2007 Free Software Foundation, Inc. +dnl Copyright (C) 2001, 2006, 2007, 2010 Free Software Foundation, Inc. dnl -dnl This program is free software; you can redistribute it and/or modify it -dnl under the terms of the GNU General Public License as published by the -dnl Free Software Foundation; either version 3 of the License, or (at your -dnl option) any later version. +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl -dnl You should have received a copy of the GNU General Public License along -dnl with this program. If not, see <http://www.gnu.org/licenses/>. +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software Foundation, +dnl Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. dnl -dnl MU_RESULT_ACTIONS -- generate shell code for the result of a test -dnl $1 -- CVAR -- cache variable to check -dnl $2 -- NAME -- if not empty, used to generate a default value TRUE: -dnl `AC_DEFINE(HAVE_NAME)' -dnl $2 -- TRUE -- what to do if the CVAR is not `no' -dnl $3 -- FALSE -- what to do otherwise; defaults to `:' - -AC_DEFUN([MU_RESULT_ACTIONS], [ -[if test "$$1" != "" -a "$$1" != no; then - ]ifelse([$3], , - [AC_DEFINE(HAVE_]translit($2, [a-z ./<>], [A-Z___])[,1,[FIXME])], - [$3])[ -else - ]ifelse([$4], , [:], [$4])[ -fi]])dnl - +dnl MU_CHECK_GUILE(minversion, [act-if-found], [ac-if-not-found]) +dnl $1 $2 $3 AC_DEFUN([MU_CHECK_GUILE], [ - if test "x$mu_cv_lib_guile" = x; then - cached="" - AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $PATH) - if test $GUILE_CONFIG = no; then - mu_cv_lib_guile=no - else - GUILE_INCLUDES=`guile-config compile` - GUILE_LIBS=`guile-config link` - fi + AS_VAR_SET([mu_cv_guile], [no]) + AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $PATH) + if test "$GUILE_CONFIG" = no; then + m4_if([$3],,[AC_MSG_ERROR(cannot find Guile)], [$3]) + else + AC_SUBST(GUILE_INCLUDES) + AC_SUBST(GUILE_LIBS) + AC_SUBST(GUILE_VERSION) + AC_SUBST(GUILE_VERSION_NUMBER) + + GUILE_INCLUDES=`$GUILE_CONFIG compile` + GUILE_LIBS=`$GUILE_CONFIG link` + GUILE_VERSION=`($GUILE_CONFIG --version 2>&1; echo '')|sed 's/guile-config [[^0-9]]* \([[0-9]][[0-9.]]*\)$/\1/'` + VEX=`echo $GUILE_VERSION | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'` + GUILE_VERSION_NUMBER=`eval expr "$VEX"` + + m4_if([$1],,,[ + VEX=`echo $1 | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'` + min=`eval expr "$VEX"` + if test $GUILE_VERSION_NUMBER -lt $min; then + m4_if([$3],, + [AC_MSG_ERROR([Guile version too old; required is at least ]$1)], + [$3]) + fi]) + + save_LIBS=$LIBS + save_CFLAGS=$CFLAGS + LIBS="$LIBS $GUILE_LIBS" + CFLAGS="$CFLAGS $GUILE_INCLUDES" + AC_TRY_LINK([#include <libguile.h>], + m4_if([$1], , scm_shell(0, NULL);, [$1]), + [AS_VAR_SET([mu_cv_guile], $GUILE_VERSION)]) + LIBS=$save_LIBS + CFLAGS=$save_CFLAGS + fi - if test $GUILE_CONFIG != no; then - AC_MSG_CHECKING(for guile version 1.8 or higher) - GUILE_VERSION=`($GUILE_CONFIG --version 2>&1; echo '')|sed -n 's/guile-config - Guile version \([[0-9]][[0-9]]*\)\.\([[0-9]][[0-9]]*\).*/\1\2/p'` - case "x$GUILE_VERSION" in - x[[0-9]]*) - if test $GUILE_VERSION -lt 18; then - AC_MSG_RESULT(Nope. Version number too low.) - mu_cv_lib_guile=no - else - AC_DEFINE_UNQUOTED(GUILE_VERSION, $GUILE_VERSION, - [Guile version number: MAX*10 + MIN]) - AC_MSG_RESULT(OK) - save_LIBS=$LIBS - save_CFLAGS=$CFLAGS - LIBS="$LIBS $GUILE_LIBS" - CFLAGS="$CFLAGS $GUILE_INCLUDES" - AC_TRY_LINK([#include <libguile.h>], - ifelse([$1], , scm_shell(0, NULL);, [$1]), - [mu_cv_lib_guile=yes], - [mu_cv_lib_guile=no]) - LIBS=$save_LIBS - CFLAGS=$save_CFLAGS - fi ;; - *) AC_MSG_RESULT(Nope. Unknown version number) - mu_cv_lib_guile=no;; - esac - fi - else - cached=" (cached) " - GUILE_INCLUDES=`guile-config compile` - GUILE_LIBS=`guile-config link` - fi - AC_MSG_CHECKING(whether to build guile support) - MU_RESULT_ACTIONS([mu_cv_lib_guile],[LIBGUILE],[$2],[$3]) - AC_MSG_RESULT(${cached}$mu_cv_lib_guile) - if test $mu_cv_lib_guile = yes; then - if test $GUILE_VERSION -gt 16; then - LIBS="$LIBS $GUILE_LIBS" - CFLAGS="$CFLAGS $GUILE_INCLUDES" - AC_CHECK_FUNCS(scm_long2num scm_cell scm_list_1 scm_list_n scm_c_define\ - scm_c_lookup) - if test $ac_cv_func_scm_cell = no; then - AC_MSG_CHECKING(for inline scm_cell) - AC_TRY_LINK([#include <libguile.h>], - [scm_cell(SCM_EOL, SCM_EOL)], - [ac_cv_func_scm_cell=yes - AC_DEFINE(HAVE_SCM_CELL,1, - Define if you have scm_cell function)]) - AC_MSG_RESULT($ac_cv_func_scm_cell) - fi - CFLAGS=$save_CFLAGS - LIBS=$save_LIBS + if test $mu_cv_guile = no; then + GUILE_INCLUDES= + GUILE_LIBS= + GUILE_VERSION= + GUILE_VERSION_NUMBER= + m4_if($3,,[AC_MSG_ERROR(required library libguile not found)], [$3]) + else + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libguile.h>]], + [SCM_DEVAL_P = 1; + SCM_BACKTRACE_P = 1; + SCM_RECORD_POSITIONS_P = 1; + SCM_RESET_DEBUG_MODE;])], + [mu_cv_guile_debug=yes], + [mu_cv_guile_debug=no]) + if test $mu_cv_guile_debug = yes; then + AC_DEFINE_UNQUOTED([GUILE_DEBUG_MACROS], 1, + [Define to 1 if SCM_DEVAL_P, SCM_BACKTRACE_P, SCM_RECORD_POSITIONS_P and SCM_RESET_DEBUG_MODE are defined]) fi - fi -]) + AC_CHECK_TYPES([scm_t_off],[],[],[#include <libguile.h>]) + AC_DEFINE_UNQUOTED([GUILE_VERSION], "$GUILE_VERSION", + [Guile version number]) + AC_DEFINE_UNQUOTED([GUILE_VERSION_NUMBER], $GUILE_VERSION_NUMBER, + [Guile version number: MAX*10 + MIN]) + m4_if([$2],,,[$2]) + fi +]) diff --git a/build/.gitignore b/build/.gitignore index f95ad11..51ab4b7 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -1,5 +1,7 @@ Makefile Makefile.in +arg-nonnull.h +c++defs.h config.guess config.rpath config.sub @@ -12,4 +14,5 @@ mdate-sh missing mkinstalldirs texinfo.tex +warn-on-use.h ylwrap diff --git a/configure.ac b/configure.ac index 4638ae1..9947012 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,8 @@ dnl dnl configure.ac dnl dnl This file is part of GNU Anubis. -dnl Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 The Anubis Team. +dnl Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009, +dnl 2010 The Anubis Team. dnl dnl GNU Anubis is free software; you can redistribute it and/or modify it dnl under the terms of the GNU General Public License as published by the @@ -48,8 +49,8 @@ AC_TYPE_SIGNAL AC_CHECK_TYPE(u_char, unsigned char) AC_CHECK_HEADERS(arpa/inet.h sys/types.h sys/socket.h socket.h locale.h) -AC_CHECK_TYPE(socklen_t, , AC_DEFINE(socklen_t, int, -[Define to int if <sys/types.h> does not define]), +AC_CHECK_TYPE([socklen_t], , +[AC_DEFINE_UNQUOTED([socklen_t], [int], [Type to use instead of socklen_t, if <sys/types.h> does not define])], [ #if HAVE_SYS_TYPES_H # include <sys/types.h> diff --git a/lib/.gitignore b/lib/.gitignore index 46e9e49..691e3e1 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -24,6 +24,8 @@ getpass.h gettext.h gnulib.mk intprops.h +langinfo.h +langinfo.in.h localcharset.c localcharset.h lseek.c @@ -33,6 +35,7 @@ malloca.h malloca.valgrind mbrtowc.c mbsinit.c +nl_langinfo.c obstack.c obstack.h realloc.c diff --git a/src/guile.c b/src/guile.c index b2f841f..6af115e 100644 --- a/src/guile.c +++ b/src/guile.c @@ -2,7 +2,7 @@ guile.c This file is part of GNU Anubis. - Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 The Anubis Team. + Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 The Anubis Team. GNU Anubis is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -70,19 +70,21 @@ guile_safe_exec (SCM (*handler) (void *data), void *data, SCM *result) void guile_debug (int val) { +#ifdef GUILE_DEBUG_MACROS SCM_DEVAL_P = val; SCM_BACKTRACE_P = val; SCM_RECORD_POSITIONS_P = val; SCM_RESET_DEBUG_MODE; +#endif } void init_guile () { - scm_init_guile (); - scm_load_goops (); - guile_init_anubis_info_port (); - guile_init_anubis_error_port (); + scm_init_guile (); + scm_load_goops (); + guile_init_anubis_info_port (); + guile_init_anubis_error_port (); } @@ -140,7 +142,7 @@ guile_load_path_append_handler (void *data) char *path = list_item (arglist, 0); SCM scm, path_scm, *pscm; path_scm = SCM_VARIABLE_REF (scm_c_lookup ("%load-path")); - for (scm = path_scm; scm != SCM_EOL; scm = SCM_CDR (scm)) + for (scm = path_scm; !scm_is_null (scm); scm = SCM_CDR (scm)) { SCM val = SCM_CAR (scm); if (scm_is_string (val)) @@ -180,7 +182,7 @@ load_path_handler (void *data) struct load_closure *lp = data; scm_set_program_arguments (lp->argc, lp->argv, lp->filename); - scm_primitive_load_path (scm_makfrom0str (lp->filename)); + scm_primitive_load_path (scm_from_locale_string (lp->filename)); return SCM_UNDEFINED; } @@ -200,10 +202,10 @@ guile_to_anubis (SCM cell) static ANUBIS_LIST list; list = list_create (); - for (; cell != SCM_EOL; cell = SCM_CDR (cell)) + for (; !scm_is_null (cell); cell = SCM_CDR (cell)) { SCM car = SCM_CAR (cell); - if (SCM_NIMP (car) && SCM_CONSP (car)) + if (scm_is_pair (car)) { ASSOC *asc = xmalloc (sizeof (*asc)); @@ -228,11 +230,11 @@ anubis_to_guile (ANUBIS_LIST list) SCM cell, car, cdr; if (asc->key) - car = scm_makfrom0str (asc->key); + car = scm_from_locale_string (asc->key); else car = SCM_BOOL_F; - cdr = scm_makfrom0str (asc->value); + cdr = scm_from_locale_string (asc->value); cell = scm_cons (scm_cons (car, cdr), SCM_EOL); if (head == SCM_EOL) @@ -282,7 +284,7 @@ list_to_args (ANUBIS_LIST arglist) } } else - val = scm_makfrom0str (p); + val = scm_from_locale_string (p); cell = scm_cons (val, SCM_EOL); @@ -312,23 +314,16 @@ guile_process_proc_handler (void *data) ANUBIS_LIST arglist = clp->arglist; MESSAGE msg = clp->msg; SCM arg_hdr, arg_body; - SCM invlist, rest_arg; + SCM rest_arg; /* Prepare the required arguments */ arg_hdr = anubis_to_guile (message_get_header (msg)); - arg_body = scm_makfrom0str (message_get_body (msg)); + arg_body = scm_from_locale_string (message_get_body (msg)); /* Prepare the optional arguments */ rest_arg = list_to_args (arglist); - invlist = scm_append - (scm_list_2 - (scm_list_3 (clp->procsym, - scm_cons (SCM_IM_QUOTE, arg_hdr), - arg_body), - rest_arg)); - - return scm_primitive_eval (invlist); + return scm_apply_2 (clp->procsym, arg_hdr, arg_body, rest_arg); } void @@ -360,11 +355,11 @@ guile_process_proc (ANUBIS_LIST arglist, MESSAGE msg) if (guile_safe_exec (guile_process_proc_handler, &clos, &res)) return; - if (SCM_IMP (res) && SCM_BOOLP (res)) + if (scm_is_bool (res)) { /* FIXME 1 */ ; } - else if (SCM_NIMP (res) && SCM_CONSP (res)) + else if (scm_is_pair (res)) { SCM ret_hdr = SCM_CAR (res); SCM ret_body = SCM_CDR (res); @@ -373,7 +368,7 @@ guile_process_proc (ANUBIS_LIST arglist, MESSAGE msg) { /* Preserve the headers */ ; } - else if (SCM_NIMP (ret_hdr) && SCM_CONSP (ret_hdr)) + else if (scm_is_pair (ret_hdr)) { /* Replace them */ message_replace_header (msg, guile_to_anubis (ret_hdr)); diff --git a/src/logport.c b/src/logport.c index 82094a0..f1999b4 100644 --- a/src/logport.c +++ b/src/logport.c @@ -2,7 +2,7 @@ Log and info output ports for Guile. This file is part of GNU Anubis. - Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 The Anubis Team. + Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 The Anubis Team. GNU Anubis is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -24,8 +24,12 @@ #ifdef WITH_GUILE -static long scm_tc16_anubis_error_port; -static long scm_tc16_anubis_info_port; +#ifndef HAVE_SCM_T_OFF +typedef off_t scm_t_off; +#endif + +static scm_t_bits scm_tc16_anubis_error_port; +static scm_t_bits scm_tc16_anubis_info_port; typedef void (*log_flush_fn) (int flag, char *, size_t); @@ -63,11 +67,10 @@ _make_anubis_log_port (long type, const char *descr, int flag, dp = scm_gc_malloc (sizeof (struct _anubis_error_port), descr); dp->flag = flag; dp->flush = flush; - port = scm_cell (type, 0); - pt = scm_add_to_port_table (port); - SCM_SETPTAB_ENTRY (port, pt); - pt->rw_random = 0; + port = scm_new_port_table_entry (type); + pt = SCM_PTAB_ENTRY(port); + pt->rw_random = 0; pt->write_buf = scm_gc_malloc (ANUBIS_ERROR_PORT_BUFSIZE, "port buffer"); pt->write_pos = pt->write_buf; pt->write_buf_size = ANUBIS_ERROR_PORT_BUFSIZE; @@ -188,8 +191,8 @@ _anubis_error_port_write (SCM port, const void *data, size_t size) _anubis_error_port_flush (port); } -static off_t -_anubis_error_port_seek (SCM port, off_t offset, int whence) +static scm_t_off +_anubis_error_port_seek (SCM port, scm_t_off offset, int whence) { return -1; } |