1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-23 03:16:37 +02:00

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.*)"
This commit is contained in:
Trygve Aaberge
2022-10-22 15:27:06 +02:00
committed by Sébastien Helleu
parent 1bfc8b9cf8
commit ebc63d1b83
28 changed files with 152 additions and 61 deletions
+1 -1
View File
@@ -446,7 +446,7 @@ weechat_python_exec (struct t_plugin_script *script,
{
switch (format[i])
{
case 's': /* string */
case 's': /* string or null */
argv2[i] = argv[i];
if (weechat_utf8_is_valid (argv2[i], -1, NULL))
format2[i] = 's'; /* str */