From 9857b44e4ecfcbc1685acc429bd541777ea38afb Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 19 Feb 2013 22:49:59 +0100 Subject: [PATCH] guile: fix arguments given to callbacks (separate arguments instead of one list with arguments inside), guile >= 2.0 is now required (bug #38350) Unfortunately this breaks compatibility with existing guile scripts, but this change is needed to keep consistency with other scripting languages. Now guile >= 2.0 is required, WeeChat can not compile any more with guile 1.8. --- ChangeLog | 2 ++ NEWS | 9 +++++++- cmake/FindGuile.cmake | 2 +- configure.in | 4 ++-- debian/control | 2 +- doc/de/weechat_scripting.de.txt | 4 ++-- doc/de/weechat_user.de.txt | 2 +- doc/en/weechat_scripting.en.txt | 4 ++-- doc/en/weechat_user.en.txt | 2 +- doc/fr/weechat_scripting.fr.txt | 4 ++-- doc/fr/weechat_user.fr.txt | 2 +- doc/it/weechat_scripting.it.txt | 4 ++-- doc/it/weechat_user.it.txt | 2 +- doc/ja/weechat_scripting.ja.txt | 4 ++-- doc/ja/weechat_user.ja.txt | 2 +- doc/pl/weechat_scripting.pl.txt | 4 ++-- src/plugins/guile/weechat-guile.c | 36 +++++++++++++------------------ 17 files changed, 46 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a46887e6..9fc16c297 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,8 @@ Version 0.4.1 (under dev!) * aspell: add completion "aspell_dicts" (list of aspell installed dictionaries) * aspell: add info "aspell_dict" (dictionaries used on a buffer) * aspell: optimization on spellers to improve speed (save state by buffer) +* guile: fix arguments given to callbacks (separate arguments instead of one + list with arguments inside), guile >= 2.0 is now required (bug #38350) * guile: fix crash on calls to callbacks during load of script (bug #38343) * guile: fix compilation with guile 2.0 * irc: fix display of malformed CTCP (without closing char) (bug #38347) diff --git a/NEWS b/NEWS index 0c1f91783..10a936b5d 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,19 @@ WeeChat Release Notes ===================== Sébastien Helleu -v0.4.1-dev, 2013-01-20 +v0.4.1-dev, 2013-02-19 Version 0.4.1 (under dev!) -------------------------- +Important release notes: + +* the way to give arguments for guile callbacks has been fixed: now arguments + are sent individually (instead of a list with all arguments inside). + Therefore, existing guile scripts must be modified accordingly. + Moreover, WeeChat now requires Guile ≥ 2.0 to compile. + Version 0.4.0 (2013-01-20) -------------------------- diff --git a/cmake/FindGuile.cmake b/cmake/FindGuile.cmake index 748d12dca..c1d5daba3 100644 --- a/cmake/FindGuile.cmake +++ b/cmake/FindGuile.cmake @@ -33,5 +33,5 @@ ENDIF(GUILE_FOUND) FIND_PACKAGE(PkgConfig) IF(PKG_CONFIG_FOUND) - pkg_search_module(GUILE guile-2.0 guile-1.8) + pkg_search_module(GUILE guile-2.0) ENDIF(PKG_CONFIG_FOUND) diff --git a/configure.in b/configure.in index 0d466a2ce..5f69da94d 100644 --- a/configure.in +++ b/configure.in @@ -740,7 +740,7 @@ if test "x$enable_guile" = "xyes" ; then if test "x$PKGCONFIG" != "x"; then AC_MSG_CHECKING(for Guile headers and librairies) echo - for v in "2.0" "1.8" ; do + for v in "2.0" ; do pkgconfig_guile_found=`$PKGCONFIG --exists guile-$v 2>/dev/null` if test "x$?" = "x0" ; then GUILE_VERSION=`$PKGCONFIG --modversion guile-$v` @@ -754,7 +754,7 @@ if test "x$enable_guile" = "xyes" ; then if test "x$guile_found" = "xno" ; then AC_MSG_WARN([ -*** Guile couldn't be found on your system. +*** Guile >= 2.0 couldn't be found on your system. *** WeeChat will be built without Guile (scheme) support.]) enable_guile="no" not_found="$not_found guile" diff --git a/debian/control b/debian/control index 4bf789e4a..262b8b16e 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: Emmanuel Bouthenot Build-Depends-Indep: asciidoc (>= 8.5), source-highlight Build-Depends: debhelper (>= 7.0.50), cmake, libncursesw5-dev, ruby1.9.1, ruby1.9.1-dev, libperl-dev, python-dev, libaspell-dev, liblua5.1-0-dev, - tcl8.5-dev, guile-1.8-dev, libcurl4-gnutls-dev, libgcrypt11-dev, libgnutls-dev, + tcl8.5-dev, guile-2.0-dev, libcurl4-gnutls-dev, libgcrypt11-dev, libgnutls-dev, zlib1g-dev, dpkg-dev (>= 1.13.19), pkg-config Standards-Version: 3.9.4 Homepage: http://weechat.org/ diff --git a/doc/de/weechat_scripting.de.txt b/doc/de/weechat_scripting.de.txt index a7f7dd4d6..6b81a9211 100644 --- a/doc/de/weechat_scripting.de.txt +++ b/doc/de/weechat_scripting.de.txt @@ -343,8 +343,8 @@ weechat::hook_timer 1000 0 1 timer_cb test [source,lisp] ---------------------------------------- -(define (timer_cb args) - (weechat:print "" (string-append "timer! data=" (list-ref args 0))) +(define (timer_cb data remaining_calls) + (weechat:print "" (string-append "timer! data=" data)) weechat:WEECHAT_RC_OK ) diff --git a/doc/de/weechat_user.de.txt b/doc/de/weechat_user.de.txt index 42d830e64..521a66468 100644 --- a/doc/de/weechat_user.de.txt +++ b/doc/de/weechat_user.de.txt @@ -101,7 +101,7 @@ welche Pakete optional genutzt werden können. | ruby1.9.1-dev | ≥ 1.8 | | ruby Erweiterung | liblua5.1-0-dev | | | lua Erweiterung | tcl-dev | ≥ 8.5 | | tcl Erweiterung -| guile-1.8-dev | ≥ 1.8 | | guile (scheme) Erweiterung +| guile-2.0-dev | ≥ 2.0 | | guile (scheme) Erweiterung | asciidoc | ≥ 8.5.0 | | erstellt Dokumentation (HTML Dateien) | source-highlight | | | Syntax Highlight für Quelltext in HTML Dokumentation |======================================== diff --git a/doc/en/weechat_scripting.en.txt b/doc/en/weechat_scripting.en.txt index 51a94e2b1..dc8f3e225 100644 --- a/doc/en/weechat_scripting.en.txt +++ b/doc/en/weechat_scripting.en.txt @@ -336,8 +336,8 @@ weechat::hook_timer 1000 0 1 timer_cb test [source,lisp] ---------------------------------------- -(define (timer_cb args) - (weechat:print "" (string-append "timer! data=" (list-ref args 0))) +(define (timer_cb data remaining_calls) + (weechat:print "" (string-append "timer! data=" data)) weechat:WEECHAT_RC_OK ) diff --git a/doc/en/weechat_user.en.txt b/doc/en/weechat_user.en.txt index a87df0a10..590994ca6 100644 --- a/doc/en/weechat_user.en.txt +++ b/doc/en/weechat_user.en.txt @@ -101,7 +101,7 @@ compile WeeChat. | ruby1.9.1-dev | ≥ 1.8 | | ruby plugin | liblua5.1-0-dev | | | lua plugin | tcl-dev | ≥ 8.5 | | tcl plugin -| guile-1.8-dev | ≥ 1.8 | | guile (scheme) plugin +| guile-2.0-dev | ≥ 2.0 | | guile (scheme) plugin | asciidoc | ≥ 8.5.0 | | build documentation (HTML files) | source-highlight | | | syntax highlight for sources in HTML documentation |======================================== diff --git a/doc/fr/weechat_scripting.fr.txt b/doc/fr/weechat_scripting.fr.txt index d7762316f..1b33e352f 100644 --- a/doc/fr/weechat_scripting.fr.txt +++ b/doc/fr/weechat_scripting.fr.txt @@ -345,8 +345,8 @@ weechat::hook_timer 1000 0 1 timer_cb test [source,lisp] ---------------------------------------- -(define (timer_cb args) - (weechat:print "" (string-append "timer! data=" (list-ref args 0))) +(define (timer_cb data remaining_calls) + (weechat:print "" (string-append "timer! data=" data)) weechat:WEECHAT_RC_OK ) diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt index dec97b923..867c12d61 100644 --- a/doc/fr/weechat_user.fr.txt +++ b/doc/fr/weechat_user.fr.txt @@ -103,7 +103,7 @@ compiler WeeChat. | ruby1.9.1-dev | ≥ 1.8 | | extension ruby | liblua5.1-0-dev | | | extension lua | tcl-dev | ≥ 8.5 | | extension tcl -| guile-1.8-dev | ≥ 1.8 | | extension guile (scheme) +| guile-2.0-dev | ≥ 2.0 | | extension guile (scheme) | asciidoc | ≥ 8.5.0 | | construction de la documentation (fichiers HTML) | source-highlight | | | coloration des sources dans la documentation HTML |======================================== diff --git a/doc/it/weechat_scripting.it.txt b/doc/it/weechat_scripting.it.txt index 0117f8894..ff3fe7fc4 100644 --- a/doc/it/weechat_scripting.it.txt +++ b/doc/it/weechat_scripting.it.txt @@ -348,8 +348,8 @@ weechat::hook_timer 1000 0 1 timer_cb test [source,lisp] ---------------------------------------- -(define (timer_cb args) - (weechat:print "" (string-append "timer! data=" (list-ref args 0))) +(define (timer_cb data remaining_calls) + (weechat:print "" (string-append "timer! data=" data)) weechat:WEECHAT_RC_OK ) diff --git a/doc/it/weechat_user.it.txt b/doc/it/weechat_user.it.txt index 5ef4a8873..aaee615ac 100644 --- a/doc/it/weechat_user.it.txt +++ b/doc/it/weechat_user.it.txt @@ -108,7 +108,7 @@ compilare WeeChat. | ruby1.9.1-dev | ≥ 1.8 | | plugin ruby | liblua5.1-0-dev | | | plugin lua | tcl-dev | ≥ 8.5 | | plugin tcl -| guile-1.8-dev | ≥ 1.8 | | plugin guile (scheme) +| guile-2.0-dev | ≥ 2.0 | | plugin guile (scheme) | asciidoc | ≥ 8.5.0 | | compilazione della documentazione (file HTML) | source-highlight | | | evidenziazione della sintassi per i sorgenti nella documentazione HTML |======================================== diff --git a/doc/ja/weechat_scripting.ja.txt b/doc/ja/weechat_scripting.ja.txt index f2cedd5cd..0d821be06 100644 --- a/doc/ja/weechat_scripting.ja.txt +++ b/doc/ja/weechat_scripting.ja.txt @@ -328,8 +328,8 @@ weechat::hook_timer 1000 0 1 timer_cb test [source,lisp] ---------------------------------------- -(define (timer_cb args) - (weechat:print "" (string-append "timer! data=" (list-ref args 0))) +(define (timer_cb data remaining_calls) + (weechat:print "" (string-append "timer! data=" data)) weechat:WEECHAT_RC_OK ) diff --git a/doc/ja/weechat_user.ja.txt b/doc/ja/weechat_user.ja.txt index dc862bdc4..2ead9229f 100644 --- a/doc/ja/weechat_user.ja.txt +++ b/doc/ja/weechat_user.ja.txt @@ -93,7 +93,7 @@ WeeChat は cmake または autotools を使ってコンパイルできます (c | ruby1.9.1-dev | ≥ 1.8 | | ruby プラグイン | liblua5.1-0-dev | | | lua プラグイン | tcl-dev | ≥ 8.5 | | tcl プラグイン -| guile-1.8-dev | | | guile (scheme) プラグイン +| guile-2.0-dev | ≥ 2.0 | | guile (scheme) プラグイン | asciidoc | ≥ 8.5.0 | | 文書の生成 (HTML ファイル) | source-highlight | | | HTML 文書に含まれるソースコードのシンタックスハイライト |======================================== diff --git a/doc/pl/weechat_scripting.pl.txt b/doc/pl/weechat_scripting.pl.txt index 74ee024fa..c046afcab 100644 --- a/doc/pl/weechat_scripting.pl.txt +++ b/doc/pl/weechat_scripting.pl.txt @@ -339,8 +339,8 @@ weechat::hook_timer 1000 0 1 timer_cb test [source,lisp] ---------------------------------------- -(define (timer_cb args) - (weechat:print "" (string-append "timer! data=" (list-ref args 0))) +(define (timer_cb data remaining_calls) + (weechat:print "" (string-append "timer! data=" data)) weechat:WEECHAT_RC_OK ) diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c index 7b5abf3a2..154bcba73 100644 --- a/src/plugins/guile/weechat-guile.c +++ b/src/plugins/guile/weechat-guile.c @@ -53,8 +53,9 @@ char *guile_stdout = NULL; struct t_guile_function { - SCM proc; - SCM args; + SCM proc; /* proc to call */ + SCM *argv; /* arguments for proc */ + size_t nargs; /* length of arguments */ }; /* @@ -109,17 +110,18 @@ weechat_guile_catch (void *procedure, void *data) } /* - * Encapsulates call to scm_call_1 (to give arguments). + * Encapsulates call to scm_call_n (to give arguments). */ SCM -weechat_guile_scm_call_1 (void *proc) +weechat_guile_scm_call_n (void *proc) { struct t_guile_function *guile_function; guile_function = (struct t_guile_function *)proc; - return scm_call_1 (guile_function->proc, guile_function->args); + return scm_call_n (guile_function->proc, + guile_function->argv, guile_function->nargs); } /* @@ -127,7 +129,7 @@ weechat_guile_scm_call_1 (void *proc) */ SCM -weechat_guile_exec_function (const char *function, SCM args) +weechat_guile_exec_function (const char *function, SCM *argv, size_t nargs) { SCM func, func2, value; struct t_guile_function guile_function; @@ -135,11 +137,12 @@ weechat_guile_exec_function (const char *function, SCM args) func = weechat_guile_catch (scm_c_lookup, (void *)function); func2 = weechat_guile_catch (scm_variable_ref, func); - if (args) + if (argv) { guile_function.proc = func2; - guile_function.args = args; - value = weechat_guile_catch (weechat_guile_scm_call_1, &guile_function); + guile_function.argv = argv; + guile_function.nargs = nargs; + value = weechat_guile_catch (weechat_guile_scm_call_n, &guile_function); } else { @@ -255,7 +258,7 @@ weechat_guile_exec (struct t_plugin_script *script, char *format, void **argv) { struct t_plugin_script *old_guile_current_script; - SCM argv_list, rc, old_current_module; + SCM rc, old_current_module; void *argv2[17], *ret_value; int i, argc, *ret_int; @@ -290,20 +293,11 @@ weechat_guile_exec (struct t_plugin_script *script, { argv2[i] = SCM_UNDEFINED; } - argv_list = scm_list_n (argv2[0], argv2[1], - argv2[2], argv2[3], - argv2[4], argv2[5], - argv2[6], argv2[7], - argv2[8], argv2[9], - argv2[10], argv2[11], - argv2[12], argv2[13], - argv2[14], argv2[15], - argv2[16]); - rc = weechat_guile_exec_function (function, argv_list); + rc = weechat_guile_exec_function (function, (SCM *)argv2, argc); } else { - rc = weechat_guile_exec_function (function, NULL); + rc = weechat_guile_exec_function (function, NULL, 0); } ret_value = NULL;