diff options
author | Joram Schrijver <i@joram.io> | 2020-05-22 02:29:31 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-06-07 11:07:03 +0200 |
commit | cac45aab469510bff21fef10cdd1a71b137c1a56 (patch) | |
tree | 17dbd3b98671a82be7dbde583db65aec227c8320 /src/plugins/guile | |
parent | e784a994b5f3759ffcc0d8c581c4ec09170a3067 (diff) | |
download | weechat-cac45aab469510bff21fef10cdd1a71b137c1a56.zip |
guile: fix printing of output to buffer (issue #1098)
The support for Guile 2.2 did not implement the custom port correctly,
and did not configure it to be the default output port. This caused
output from Guile to be printed straight to the TTY, breaking the
WeeChat interface.
Note that the port is unbuffered, so that code like
(display "test")
immediately results in output, without an explicit call to force-output.
Diffstat (limited to 'src/plugins/guile')
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 4 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile.c | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index d35beba86..ebe32dbab 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -4974,7 +4974,9 @@ weechat_guile_api_module_init (void *data) port_type = scm_make_port_type ("weechat_stdout", &weechat_guile_port_fill_input, &weechat_guile_port_write); - guile_port = scm_c_make_port (port_type, 0, 0); + guile_port = scm_c_make_port (port_type, SCM_WRTNG | SCM_BUF0, 0); + scm_set_current_output_port (guile_port); + scm_set_current_error_port (guile_port); #else /* Guile < 2.2 */ scm_t_bits port_type; diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c index 24bedb541..ea1b3a77b 100644 --- a/src/plugins/guile/weechat-guile.c +++ b/src/plugins/guile/weechat-guile.c @@ -1151,11 +1151,10 @@ weechat_guile_port_fill_input (SCM port, SCM dst, size_t start, size_t count) { /* make C compiler happy */ (void) port; - (void) dst; - (void) start; - (void) count; - return ' '; + memset (SCM_BYTEVECTOR_CONTENTS (dst) + start, ' ', count); + + return count; } #else /* Guile < 2.2 */ @@ -1184,7 +1183,7 @@ weechat_guile_port_write (SCM port, SCM src, size_t start, size_t count) /* make C compiler happy */ (void) port; - data = scm_to_locale_string (src); + data = SCM_BYTEVECTOR_CONTENTS (src); data2 = malloc (count + 1); if (!data2) |