From 9b5e070e5b9e2d5b6d0b1dd9a43c463d9f4ec5f0 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Fri, 27 Nov 2009 12:35:10 +0100 Subject: [PATCH 1/7] Fix crash when connecting to ssl server if another non-ssl connection is pending --- src/core/wee-hook.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index ac1deb2c1..b5470d703 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -1508,7 +1508,8 @@ hook_connect_gnutls_set_certificates (gnutls_session_t tls_session, while (ptr_hook) { /* looking for the right hook using to the gnutls session pointer */ - if (*(HOOK_CONNECT(ptr_hook, gnutls_sess)) == tls_session) + if (HOOK_CONNECT(ptr_hook, gnutls_sess) + && (*(HOOK_CONNECT(ptr_hook, gnutls_sess)) == tls_session)) { rc = (int) (HOOK_CONNECT(ptr_hook, gnutls_cb)) (ptr_hook->callback_data, tls_session, req_ca, nreq, From 2d5b48d7bb340cd6c201bc3285d172afafa97c93 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Fri, 27 Nov 2009 12:42:32 +0100 Subject: [PATCH 2/7] Update german translations --- po/de.po | 84 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/po/de.po b/po/de.po index 262df07cf..fe0e6c6d7 100644 --- a/po/de.po +++ b/po/de.po @@ -11,7 +11,7 @@ msgstr "" "Project-Id-Version: WeeChat 0.3.1-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "POT-Creation-Date: 2009-11-24 15:30+0100\n" -"PO-Revision-Date: 2009-11-20 17:55+0100\n" +"PO-Revision-Date: 2009-11-26 18:51+0100\n" "Last-Translator: Nils G \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -78,7 +78,7 @@ msgid "Error: missing argument for \"%s\" option\n" msgstr "Fehler: fehlendes Argument für die Option \"%s\"\n" msgid "Error: unable to get HOME directory\n" -msgstr "Fehler: kann das HOME-Verzeichnis nicht ermitteln\n" +msgstr "Fehler: Das HOME-Verzeichnis kann nicht ermittelt werden\n" msgid "Error: not enough memory for home directory\n" msgstr "Fehler: nicht genug Speicher für das HOME-Verzeichnis\n" @@ -89,7 +89,7 @@ msgstr "Fehler: HOME (%s) ist kein Verzeichnis\n" #, c-format msgid "Error: cannot create directory \"%s\"\n" -msgstr "Fehler: kann das Verzeichnis \"%s\" nicht anlegen\n" +msgstr "Fehler: Das Verzeichnis \"%s\" kann nicht anlegt werden.\n" #, c-format msgid "Welcome to %sWeeChat%s, %s" @@ -3076,15 +3076,13 @@ msgstr "" msgid "connect to IRC server(s)" msgstr "Mit IRC-Server(n) verbinden" -#, fuzzy msgid "" "[-all [-nojoin] | servername [servername ...] [-nojoin] | hostname[/port] [-" "option[=value]] [-nooption]]" msgstr "" -"[-all [-nojoin] | Servername [Servername ...] [-nojoin] | Hostname [/port] [-" -"ipv6] [-ssl]]" +"[-all [-nojoin] | Servername [Servername ...] [-nojoin] | Hostname[/port] [-" +"option[=value]] [-nooption]]" -#, fuzzy msgid "" " -all: connect to all servers\n" "servername: internal server name to connect (server must have been created " @@ -3103,15 +3101,23 @@ msgid "" " /connect irc6.oftc.net/6697 -ipv6 -ssl\n" " /connect my.server.org/6697 -ssl -password=test" msgstr "" -" -all: Verbinde mit allen Servern\n" +" -all: Verbindet mit allen Servern\n" "servername: intern genutzter Servername, mit dem verbunden werden soll (Der " "Server muss zuerst mittels \"/server add\" angelegt werden)\n" " -nojoin: betrete (/join) keinen Channel (auch wenn die Funktion \"autojoin" "\" aktiviert sein sollte)\n" " hostname: Hostname, oder IP, eines Servers\n" " port: Port den der Server nutzen soll (Standardport: 6667)\n" -" ipv6: IPv6 Protokoll soll genutzt werden\n" -" ssl: SSL Protokoll soll genutzt werden" +" option: legt die Optionen für den Server fest (die Boolean-Optionen " +"können weggelassen werden)\n" +" nooption: stellt die Boolean Option auf \"off\" (Beispiel: -nossl)\n" +"\n" +"Beispiele:\n" +" /connect freenode\n" +" /connect irc.oftc.net/6667\n" +" /connect irc6.oftc.net/6667 -ipv6\n" +" /connect irc6.oftc.net/6697 -ipv6 -ssl\n" +" /connect my.server.org/6697 -ssl -password=test" msgid "send a CTCP message (Client-To-Client Protocol)" msgstr "CTCP-Nachricht verschicken" @@ -3656,7 +3662,6 @@ msgstr "" msgid "list, add or remove IRC servers" msgstr "Auflisten, Hinzufügen oder Entfernen von IRC-Servern" -#, fuzzy msgid "" "[list [servername]] | [listfull [servername]] | [add servername hostname[/" "port] [-temp] [-option[=value]] [-nooption]] | [copy servername " @@ -3664,11 +3669,10 @@ msgid "" "[del servername] | [deloutq] | [jump] | [raw]" msgstr "" "[list [servername]] | [listfull [servername]] | [add servername hostname[/" -"port] [-auto | -noauto] [-ipv6] [-ssl]] | [copy servername newservername] | " -"[rename servername newservername] | [keep servername] | [del servername] | " -"[deloutq] | [jump] | [raw]" +"port] [-temp] [-option[=value]] [-nooption]] | [copy servername " +"newservername] | [rename servername newservername] | [keep servername] | " +"[del servername] | [deloutq] | [jump] | [raw]" -#, fuzzy msgid "" " list: list servers (no parameter implies this list)\n" " listfull: list servers with detailed info for each server\n" @@ -3703,29 +3707,27 @@ msgstr "" " listfull: listet Server mit detaillierten Informationen über jeden " "einzelnen Server auf\n" " add: erstelle einen neuen Server\n" -"servername: Servername, für interne Nutzung und zur Darstellung\n" +"servername: Servername, dient der internen Nutzung und zur Darstellung\n" " hostname: Name oder IP-Adresse des Servers. Optional kann noch der Port " "festgelegt werden (Standard-Port: 6667)\n" -" auto: erstelle automatisch, beim Start von WeeChat, eine Verbindung " -"zum Server\n" -" noauto: es wird keine Verbindung zum Server, beim Start von WeeChat, " -"hergestellt (Standard)\n" -" ipv6: nutze IPv6 Protokoll\n" -" ssl: nutze SSL Protokoll\n" -" copy: erstelle ein Duplikat vom Server\n" -" rename: benenne einen Server um\n" -" keep: behalte Server in der Konfigurationsdatei (sollte nur bei " -"zeitweiliger Nutzung eines Servers benutzt werden)\n" -" del: entferne einen Server\n" -" deloutq: lösche ausgehende Nachrichten aller Server, die in der " +" temp: erstellt temporären Server (wird nicht gespeichert)\n" +" option: legt die Optionen für den Server fest (die Boolean-Optionen " +"können weggelassen werden)\n" +" nooption: stellt die Boolean Option auf \"off\" (Beispiel: -nossl)\n" +" copy: erstellt eine Kopie des Servers\n" +" rename: benennt den Server um\n" +" keep: behält den Server in der Konfigurationsdatei (ausschließlich für " +"die Nutzung bei temporärem Server)\n" +" del: entfernt einen Server\n" +" deloutq: löscht alle ausgehende Nachrichten, aller Server, die in der " "Warteschlange stehen (dies betrifft alle Nachrichten die WeeChat gerade " "sendet)\n" -" jump: springe zu Server-Buffer\n" -" raw: öffne Buffer mit Roh-IRC-Daten\n" +" jump: springt zum Server-Buffer\n" +" raw: öffnet Buffer mit Roh-IRC-Daten\n" "\n" "Beispiele:\n" " /server listfull\n" -" /server add oftc irc.oftc.net/6697 -ssl\n" +" /server add oftc irc.oftc.net/6697 -ssl -autoconnect\n" " /server add oftc6 irc6.oftc.net/6697 -ipv6 -ssl\n" " /server add freenode2 chat.eu.freenode.net/6667,chat.us.freenode.net/6667\n" " /server copy oftc oftcbis\n" @@ -5001,13 +5003,13 @@ msgid "" "= no backlog)" msgstr "" "maximale Anzahl der Zeilen die aus der Protokoll-Datei dargestellt werden " -"sollen, wenn ein neuer Buffer erstellt wird (0 = kein Darstellung)" +"sollen, wenn ein Buffer geöffnet wird (0 = kein Darstellung)" msgid "" "automatically save content of buffers to files (unless a buffer disables log)" msgstr "" -"Speichert automatisch den Inhalt eines Buffers, in eine Datei (sofern das " -"Protokollieren, für den Buffer, nicht deaktiviert sein sollte)" +"Speichert automatisch den Inhalt eines Buffers in eine Datei (sofern das " +"Protokollieren, für den Buffer nicht deaktiviert sein sollte)" msgid "use only lower case for log filenames" msgstr "Benutze ausschließlich Kleinschreibung für Protokoll-Dateien" @@ -5033,8 +5035,8 @@ msgid "" "replacement char for special chars in filename built with mask (like " "directory delimiter)" msgstr "" -"Ersatzzeichen für Dateinamen, falls diese ein Sonderzeichen beinhalten (z.B. " -"das Trennzeichen bei Verzeichnissen \"/\")" +"Ersatzzeichen für Dateinamen, falls der Dateiname Sonderzeichen beinhaltet " +"(z.B. das Trennzeichen bei Verzeichnissen \"/\")" msgid "write information line in log file when log starts or ends for a buffer" msgstr "" @@ -5591,7 +5593,7 @@ msgid "" "(\"%s\")" msgstr "" "%s%s: Warnung, die Lizenz \"%s\" für das Skript \"%s\" unterscheidet sich " -"von der Lizenz für Erweiterungen (\"%s\")" +"von der Lizenz der Erweiterungen (\"%s\")" #, c-format msgid "%s: error loading script \"%s\" (not enough memory)" @@ -5607,7 +5609,7 @@ msgstr "%s%s: Fehler beim Entfernen des Skripts: %s (%s)" #, c-format msgid "%s: script \"%s\" not found, nothing was removed" -msgstr "%s: Skript \"%s\" nicht gefunden, es wurde nichts entfernt" +msgstr "%s: Skript \"%s\" nicht gefunden. Es wurde nichts entfernt" #, c-format msgid "%s%s: failed to move script %s to %s (%s)" @@ -5659,13 +5661,13 @@ msgid " [C] Cancel" msgstr " [C] abbrechen" msgid "xfer chat" -msgstr "Xfer Chat" +msgstr "Transfer (xfer) Chat" msgid "ETA" msgstr "ETA" msgid "Xfer list" -msgstr "Xfer Liste" +msgstr "Tranfer (xfer) Liste" msgid "waiting" msgstr "warte" @@ -5835,7 +5837,7 @@ msgid "no" msgstr "keine" msgid "No xfer" -msgstr "Kein xfer" +msgstr "Kein Transfer (xfer)" msgid "xfer control" msgstr "Transfer-Steuerung" From 138755d76e64287f3c2be3565df6ce08267b1f60 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Fri, 27 Nov 2009 13:00:43 +0100 Subject: [PATCH 3/7] Check that connect hook was not deleted before call to gnutls callback --- src/core/wee-hook.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index b5470d703..31813426b 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -1508,7 +1508,8 @@ hook_connect_gnutls_set_certificates (gnutls_session_t tls_session, while (ptr_hook) { /* looking for the right hook using to the gnutls session pointer */ - if (HOOK_CONNECT(ptr_hook, gnutls_sess) + if (!ptr_hook->deleted + && HOOK_CONNECT(ptr_hook, gnutls_sess) && (*(HOOK_CONNECT(ptr_hook, gnutls_sess)) == tls_session)) { rc = (int) (HOOK_CONNECT(ptr_hook, gnutls_cb)) From 352217c4444c8136de8b3df6a4ffe2ae6e90f12d Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 28 Nov 2009 10:32:55 +0100 Subject: [PATCH 4/7] Fix color of nick in nicklist when doing /nick if away is enabled (bug #28102) --- src/plugins/irc/irc-nick.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 1a0519b07..638e15a0b 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -322,7 +322,9 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel, "weechat.color.nicklist_prefix%d", prefix_color); weechat_nicklist_add_nick (channel->buffer, ptr_group, - nick->name, "bar_fg", + nick->name, + (nick->flags & IRC_NICK_AWAY) ? + "weechat.color.nicklist_away" : "bar_fg", prefix, str_prefix_color, 1); } From b279a9956605f666c0fda3e409df17c3d203bbf4 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 29 Nov 2009 16:41:08 +0100 Subject: [PATCH 5/7] Support of Ruby >= 1.9.1 (patch #6989) --- ChangeLog | 3 +- cmake/FindRuby.cmake | 25 ++- configure.in | 30 +++- src/plugins/scripts/ruby/CMakeLists.txt | 2 +- src/plugins/scripts/ruby/weechat-ruby.c | 226 +++++++++++++++++------- 5 files changed, 206 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index db908a9bd..94c876084 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ WeeChat ChangeLog ================= FlashCode -v0.3.1-dev, 2009-11-24 +v0.3.1-dev, 2009-11-29 Version 0.3.1 (under dev!) @@ -35,6 +35,7 @@ Version 0.3.1 (under dev!) * irc: improve error management on socket error (recv/send) * irc: improve mask used by command /kickban * xfer: add missing charset decoding/encoding for IRC DCC chat (bug #27482) +* ruby: support of Ruby >= 1.9.1 (patch #6989) * gui: fix message "Day changed to", sometimes displayed at wrong time (bug #26959) * gui: fix bug with URL selection in some terminals (caused by horizontal lines) diff --git a/cmake/FindRuby.cmake b/cmake/FindRuby.cmake index 6f8da1c27..2e25e36dd 100644 --- a/cmake/FindRuby.cmake +++ b/cmake/FindRuby.cmake @@ -35,10 +35,15 @@ FIND_PROGRAM(RUBY_EXECUTABLE IF(RUBY_EXECUTABLE) EXECUTE_PROCESS( - COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['archdir']" + COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['rubyhdrdir'] || Config::CONFIG['archdir']" OUTPUT_VARIABLE RUBY_ARCH_DIR ) + EXECUTE_PROCESS( + COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['arch']" + OUTPUT_VARIABLE RUBY_ARCH + ) + EXECUTE_PROCESS( COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['libdir']" OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH @@ -48,17 +53,27 @@ IF(RUBY_EXECUTABLE) COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['rubylibdir']" OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH ) + + EXECUTE_PROCESS( + COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['ruby_version']" + OUTPUT_VARIABLE RUBY_VERSION + ) # remove the new lines from the output by replacing them with empty strings STRING(REPLACE "\n" "" RUBY_ARCH_DIR "${RUBY_ARCH_DIR}") STRING(REPLACE "\n" "" RUBY_POSSIBLE_LIB_PATH "${RUBY_POSSIBLE_LIB_PATH}") STRING(REPLACE "\n" "" RUBY_RUBY_LIB_PATH "${RUBY_RUBY_LIB_PATH}") + STRING(REPLACE "\n" "" RUBY_ARCH "${RUBY_ARCH}") + STRING(REPLACE "\n" "" RUBY_VERSION "${RUBY_VERSION}") FIND_PATH(RUBY_INCLUDE_PATH NAMES ruby.h PATHS ${RUBY_ARCH_DIR} ) + SET(RUBY_ARCH + "${RUBY_INCLUDE_PATH}/${RUBY_ARCH}") + FIND_LIBRARY(RUBY_LIBRARY NAMES ruby ruby1.6 ruby16 ruby1.8 ruby18 ruby1.9 ruby19 PATHS ${RUBY_POSSIBLE_LIB_PATH} ${RUBY_RUBY_LIB_PATH} @@ -67,11 +82,15 @@ IF(RUBY_EXECUTABLE) IF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH) SET(RUBY_FOUND TRUE) ENDIF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH) - + + IF(${RUBY_VERSION} STREQUAL "1.9.0") + SET(RUBY_FOUND FALSE) + ENDIF(${RUBY_VERSION} STREQUAL "1.9.0") + MARK_AS_ADVANCED( RUBY_EXECUTABLE RUBY_LIBRARY + RUBY_ARCH RUBY_INCLUDE_PATH ) - ENDIF(RUBY_EXECUTABLE) diff --git a/configure.in b/configure.in index 253c71572..b8b0f2d05 100644 --- a/configure.in +++ b/configure.in @@ -529,20 +529,32 @@ if test "x$enable_ruby" = "xyes" ; then not_found="$not_found ruby" else RUBY_VERSION=`$RUBY -rrbconfig -e "puts Config::CONFIG[['ruby_version']]"` - RUBY_INCLUDE=`$RUBY -rrbconfig -e "puts Config::CONFIG[['archdir']]"` - AC_MSG_CHECKING(for Ruby header files) - if test -r "$RUBY_INCLUDE/ruby.h"; then - RUBY_CFLAGS="-I$RUBY_INCLUDE" - else + if test "$RUBY_VERSION" = "1.9.0"; then AC_MSG_WARN([ -*** Ruby header files couldn't be found on your system. -*** Try to install them with your software package manager. +*** Ruby header files have been found, but they're of the version 1.9.0. +*** Ruby 1.9.0 is an unstable release and should not be used in production. +*** Please install Ruby >=1.8.6 or 1.9.1. *** WeeChat will be built without Ruby support.]) enable_ruby="no" not_found="$not_found ruby" + else + RUBY_INCLUDE=`$RUBY -rrbconfig -e "puts Config::CONFIG[['rubyhdrdir']] || Config::CONFIG[['archdir']]"` + RUBY_ARCH=`$RUBY -rrbconfig -e 'print Config::CONFIG[["arch"]]'` + AC_MSG_CHECKING(for Ruby header files) + if test -d "$RUBY_INCLUDE/"; then + M_RUBY_VERSION=`$RUBY -rrbconfig -e "puts Config::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"` + RUBY_CFLAGS="-I$RUBY_INCLUDE/ -I$RUBY_INCLUDE/$RUBY_ARCH -DRUBY_VERSION=$M_RUBY_VERSION" + else + AC_MSG_WARN([ +*** Ruby header files couldn't be found on your system. +*** Try to install them with your software package manager. +*** WeeChat will be built without Ruby support.]) + enable_ruby="no" + not_found="$not_found ruby" + fi + AC_MSG_RESULT(found) + RUBY_LFLAGS=`$RUBY -rrbconfig -e "puts Config::CONFIG[['LIBRUBYARG_SHARED']]"` fi - AC_MSG_RESULT(found) - RUBY_LFLAGS=`$RUBY -rrbconfig -e "puts Config::CONFIG[['LIBRUBYARG_SHARED']]"` fi else not_asked="$not_asked ruby" diff --git a/src/plugins/scripts/ruby/CMakeLists.txt b/src/plugins/scripts/ruby/CMakeLists.txt index cf977a254..98d948322 100644 --- a/src/plugins/scripts/ruby/CMakeLists.txt +++ b/src/plugins/scripts/ruby/CMakeLists.txt @@ -20,7 +20,7 @@ weechat-ruby-api.h) SET_TARGET_PROPERTIES(ruby PROPERTIES PREFIX "") IF(RUBY_FOUND) - INCLUDE_DIRECTORIES(${RUBY_INCLUDE_PATH}) + INCLUDE_DIRECTORIES(${RUBY_INCLUDE_PATH} ${RUBY_ARCH}) TARGET_LINK_LIBRARIES(ruby ${RUBY_LIBRARY} weechat_scripts) ENDIF(RUBY_FOUND) diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index b59b8b213..5cda87a08 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -22,6 +22,10 @@ #undef _ #include +#if defined(RUBY_VERSION) && RUBY_VERSION >=19 +#include +#endif + #include #include #include @@ -31,6 +35,35 @@ #include "weechat-ruby.h" #include "weechat-ruby-api.h" +#ifndef StringValuePtr +#define StringValuePtr(s) STR2CSTR(s) +#endif +#ifndef RARRAY_LEN +#define RARRAY_LEN(s) RARRAY(s)->len +#endif +#ifndef RARRAY_PTR +#define RARRAY_PTR(s) RARRAY(s)->ptr +#endif +#ifndef RSTRING_LEN +#define RSTRING_LEN(s) RSTRING(s)->len +#endif +#ifndef RSTRING_PTR +#define RSTRING_PTR(s) RSTRING(s)->ptr +#endif + +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 +#define rb_errinfo dll_rb_errinfo +#define ruby_errinfo dll_rb_errinfo +#else +#define ruby_errinfo (*dll_ruby_errinfo) +#endif + +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 +static VALUE (*dll_rb_errinfo) (void); +#else +static VALUE *dll_ruby_errinfo; +#endif + WEECHAT_PLUGIN_NAME(RUBY_PLUGIN_NAME); WEECHAT_PLUGIN_DESCRIPTION("Ruby plugin for WeeChat"); @@ -80,12 +113,12 @@ typedef struct protect_call_arg { */ static VALUE -protect_funcall0(VALUE arg) +protect_funcall0 (VALUE arg) { - return rb_funcall2(((protect_call_arg_t *) arg)->recv, - ((protect_call_arg_t *) arg)->mid, - ((protect_call_arg_t *) arg)->argc, - ((protect_call_arg_t *) arg)->argv); + return rb_funcall2 (((protect_call_arg_t *)arg)->recv, + ((protect_call_arg_t *)arg)->mid, + ((protect_call_arg_t *)arg)->argc, + ((protect_call_arg_t *)arg)->argv); } /* @@ -118,7 +151,85 @@ rb_protect_funcall (VALUE recv, ID mid, int *state, int argc, ...) } /* - * weechat_ruby_exec: execute a Ruby script + * weechat_ruby_print_exception: display ruby exception + */ + +int +weechat_ruby_print_exception (VALUE err) +{ + VALUE backtrace; + int i; + int ruby_error; + char* line; + char* cline; + char* err_msg; + char* err_class; + + backtrace = rb_protect_funcall (err, rb_intern("backtrace"), + &ruby_error, 0); + err_msg = STR2CSTR(rb_protect_funcall(err, rb_intern("message"), + &ruby_error, 0)); + err_class = STR2CSTR(rb_protect_funcall(rb_protect_funcall(err, + rb_intern("class"), + &ruby_error, 0), + rb_intern("name"), &ruby_error, 0)); + + if (strcmp (err_class, "SyntaxError") == 0) + { + weechat_printf (NULL, + weechat_gettext ("%s%s: error: %s"), + weechat_prefix ("error"), RUBY_PLUGIN_NAME, + STR2CSTR(rb_inspect(err))); + } + else + { + for (i = 0; i < RARRAY_LEN(backtrace); i++) + { + line = STR2CSTR(RARRAY_PTR(backtrace)[i]); + cline = NULL; + if (i == 0) + { + cline = (char *)calloc (strlen (line) + 2 + strlen (err_msg) + + 3 + strlen (err_class) + 1, + sizeof (char)); + if (cline) + { + strcat (cline, line); + strcat (cline, ": "); + strcat (cline, err_msg); + strcat (cline, " ("); + strcat (cline, err_class); + strcat (cline, ")"); + } + } + else + { + cline = (char *)calloc(strlen (line) + strlen (" from ") + 1, + sizeof (char)); + if (cline) + { + strcat (cline, " from "); + strcat (cline, line); + } + } + if (cline) + { + weechat_printf (NULL, + weechat_gettext ("%s%s: error: %s"), + weechat_prefix ("error"), RUBY_PLUGIN_NAME, + cline); + } + + if (cline) + free (cline); + } + } + + return 0; +} + +/* + * weechat_ruby_exec: call a ruby command */ void * @@ -242,11 +353,8 @@ weechat_ruby_exec (struct t_plugin_script *script, weechat_gettext ("%s%s: unable to run function \"%s\""), weechat_prefix ("error"), RUBY_PLUGIN_NAME, function); - err = rb_inspect(rb_gv_get("$!")); - weechat_printf (NULL, - weechat_gettext ("%s%s: error: \"%s\""), - weechat_prefix ("error"), RUBY_PLUGIN_NAME, - STR2CSTR(err)); + err = rb_gv_get("$!"); + weechat_ruby_print_exception(err); return NULL; } @@ -392,18 +500,13 @@ weechat_ruby_load (const char *filename) if (ruby_retcode == Qnil) { - err = rb_inspect(rb_gv_get("$!")); - weechat_printf (NULL, - weechat_gettext ("%s%s: error: \"%s\""), - weechat_prefix ("error"), RUBY_PLUGIN_NAME, - STR2CSTR(err)); + err = rb_gv_get("$!"); + weechat_ruby_print_exception(err); return 0; } if (NUM2INT(ruby_retcode) != 0) { - VALUE ruby_eval_error; - switch (NUM2INT(ruby_retcode)) { case 1: @@ -432,14 +535,7 @@ weechat_ruby_load (const char *filename) if (NUM2INT(ruby_retcode) == 1 || NUM2INT(ruby_retcode) == 2) { - ruby_eval_error = rb_iv_get(curModule, "@load_eval_file_error"); - if (ruby_eval_error) - { - weechat_printf (NULL, - weechat_gettext ("%s%s: error: %s"), - weechat_prefix ("error"), RUBY_PLUGIN_NAME, - STR2CSTR(ruby_eval_error)); - } + weechat_ruby_print_exception(rb_iv_get(curModule, "@load_eval_file_error")); } return 0; @@ -455,11 +551,8 @@ weechat_ruby_load (const char *filename) "\"weechat_init\" in file \"%s\""), weechat_prefix ("error"), RUBY_PLUGIN_NAME, filename); - err = rb_inspect(rb_gv_get("$!")); - weechat_printf (NULL, - weechat_gettext ("%s%s: error: \"%s\""), - weechat_prefix ("error"), RUBY_PLUGIN_NAME, - STR2CSTR(err)); + err = rb_gv_get("$!"); + weechat_ruby_print_exception(err); if (ruby_current_script != NULL) { @@ -821,42 +914,39 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) "$stderr = WeechatOutputs\n" "\n" "class Module\n" - " @load_eval_file_error = ''\n" "\n" " def load_eval_file (file)\n" " lines = ''\n" - " begin\n" - " f = File.open(file, 'r')\n" - " lines = f.readlines.join\n" - " rescue => e\n" - " @load_eval_file_error = e\n" - " return 1\n" - " end\n" - "\n" - " begin\n" - " module_eval(lines)\n" - " rescue => e\n" - " @load_eval_file_error = e\n" - " return 2\n" - " end\n" - "\n" - " has_init = false\n" - "\n" - " instance_methods.each do |meth|\n" - " if meth == 'weechat_init'\n" - " has_init = true\n" - " end\n" - " module_eval('module_function :' + meth)\n" - " end\n" - "\n" - " unless has_init\n" - " return 3\n" - " end\n" - "\n" - " return 0\n" - " end\n" - "end\n" - }; + " begin\n" + " lines = File.read(file)\n" + " rescue => e\n" + " return 1\n" + " end\n" + "\n" + " begin\n" + " module_eval(lines)\n" + " rescue Exception => e\n" + " @load_eval_file_error = e\n" + " return 2\n" + " end\n" + "\n" + " has_init = false\n" + "\n" + " instance_methods.each do |meth|\n" + " if meth.to_s == 'weechat_init'\n" + " has_init = true\n" + " end\n" + " module_eval('module_function :' + meth)\n" + " end\n" + "\n" + " unless has_init\n" + " return 3\n" + " end\n" + "\n" + " return 0\n" + " end\n" + "end\n" + }; weechat_ruby_plugin = plugin; @@ -865,6 +955,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) /* init stdout/stderr buffer */ ruby_buffer_output[0] = '\0'; +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + RUBY_INIT_STACK; +#endif + ruby_init (); ruby_init_loadpath (); ruby_script ("__weechat_plugin__"); @@ -886,7 +980,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) rb_eval_string_protect(weechat_ruby_code, &ruby_error); if (ruby_error) { - VALUE ruby_error_info = rb_inspect(ruby_errinfo); + VALUE ruby_error_info = rb_inspect((VALUE)ruby_errinfo); weechat_printf (NULL, weechat_gettext ("%s%s: unable to eval WeeChat ruby " "internal code"), @@ -934,7 +1028,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) /* unload all scripts */ weechat_ruby_unload_all (); - ruby_finalize(); + ruby_cleanup (0); return WEECHAT_RC_OK; } From f67cc2018c287d108110bd9ae09745fd48655e50 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 29 Nov 2009 22:12:40 +0100 Subject: [PATCH 6/7] Update list of contributors in doc --- doc/en/weechat_user.en.txt | 14 ++++++-------- doc/fr/weechat_user.fr.txt | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/doc/en/weechat_user.en.txt b/doc/en/weechat_user.en.txt index aa1d1c429..8a4299fe5 100644 --- a/doc/en/weechat_user.en.txt +++ b/doc/en/weechat_user.en.txt @@ -1278,21 +1278,19 @@ Voroskoi:: Marco Paolone:: italian translation -Rudolf Polzer:: - patches +Dmitry Kobylin:: + tcl plugin +Rudolf Polzer:: Jim Ramsay:: +Pistos:: +Gwenn:: +Dominik Honnef:: patches Odin:: SuSE RPM -Pistos:: - patches - -Gwenn:: - patches - [[support]] Support diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt index 9b23449bb..f16c4390a 100644 --- a/doc/fr/weechat_user.fr.txt +++ b/doc/fr/weechat_user.fr.txt @@ -1317,21 +1317,19 @@ Voroskoi:: Marco Paolone:: traduction en italien -Rudolf Polzer:: - patchs +Dmitry Kobylin:: + extension tcl +Rudolf Polzer:: Jim Ramsay:: +Pistos:: +Gwenn:: +Dominik Honnef:: patchs Odin:: RPM pour SuSE -Pistos:: - patchs - -Gwenn:: - patchs - [[support]] Support From 24d7181ecf882a035bdbcca1259934670748250d Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Mon, 30 Nov 2009 15:45:31 +0100 Subject: [PATCH 7/7] Fix typos in french user guide --- doc/fr/weechat_user.fr.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt index f16c4390a..a94e19fb0 100644 --- a/doc/fr/weechat_user.fr.txt +++ b/doc/fr/weechat_user.fr.txt @@ -1016,7 +1016,7 @@ L'extension IRC permet de dialoguer avec d'autres personnes via le protocole IRC. Elle est multi-serveurs, et offre toutes les commandes IRC supportées, y -compris la discussion directe (DCC chat) and le transfert de fichier DCC +compris la discussion directe (DCC chat) et le transfert de fichier DCC (via l'extension xfer, voir <>). Options de ligne de commande @@ -1218,7 +1218,7 @@ Vous obtiendrez les fichiers suivants : Extensions Scripts ~~~~~~~~~~~~~~~~~~ -WeeChat fournit 5 extensions pour scripts : Perl, Python, Ruby, Lua and Tcl. +WeeChat fournit 5 extensions pour scripts : Perl, Python, Ruby, Lua et Tcl. Ces extensions peuvent charger, exécuter et décharger des scripts pour ces langages.