summaryrefslogtreecommitdiff
path: root/src/plugins/perl/weechat-perl.c
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2022-10-22 15:27:06 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-12-11 15:13:31 +0100
commitebc63d1b8303a479c9ed347c1152448984fffa67 (patch)
tree0f881dd620a7100d460f795f2644365f231b9b62 /src/plugins/perl/weechat-perl.c
parent1bfc8b9cf8771c1f979f20baffa20c1fe7671726 (diff)
downloadweechat-ebc63d1b8303a479c9ed347c1152448984fffa67.zip
scripts: Send null values to config section callbacks
The callback_read and callback_create_option functions in the scripting APIs always get the value as a string, never as null. This means that if the value is null, there is no way for the script to distinguish this from an empty string for string options. This makes it impossible to properly make options with fallback values, like the irc server and server_default options, as far as I can see. All the scripting languages except Tcl use that language's equivalent for null. For JavaScript which has both null and undefined, null is used. For Tcl, the magic null string defined in commit 197a7a01e is used and the documentation is updated to describe that. I tested this with these scripts: https://gist.github.com/trygveaa/2d49c609addf9773d2ed16e15d1e3447 You can load all of those scripts and see the result with this command (assuming you have the scripts in the current directory): weechat -t -r "/filter add script * * script; /script load $(echo script_config.*)"
Diffstat (limited to 'src/plugins/perl/weechat-perl.c')
-rw-r--r--src/plugins/perl/weechat-perl.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c
index 9967b01a5..ad4a659f0 100644
--- a/src/plugins/perl/weechat-perl.c
+++ b/src/plugins/perl/weechat-perl.c
@@ -363,8 +363,11 @@ weechat_perl_exec (struct t_plugin_script *script,
{
switch (format[i])
{
- case 's': /* string */
- XPUSHs (sv_2mortal(newSVpv((char *)argv[i], 0)));
+ case 's': /* string or null */
+ if (argv[i])
+ XPUSHs (sv_2mortal(newSVpv((char *)argv[i], 0)));
+ else
+ XPUSHs (sv_2mortal(&PL_sv_undef));
break;
case 'i': /* integer */
XPUSHs (sv_2mortal(newSViv(*((int *)argv[i]))));