mirror of
https://github.com/weechat/weechat.git
synced 2026-07-09 19:23:13 +02:00
api: add argument "bytes" in function string_dyn_concat
This commit is contained in:
+27
-24
@@ -266,7 +266,7 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
}
|
||||
/* add "str_to_add" (if not empty) to "out" */
|
||||
if (str_to_add[0])
|
||||
weechat_string_dyn_concat (out, str_to_add);
|
||||
weechat_string_dyn_concat (out, str_to_add, -1);
|
||||
}
|
||||
|
||||
result = *out;
|
||||
@@ -287,7 +287,7 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
char *
|
||||
irc_color_encode (const char *string, int keep_colors)
|
||||
{
|
||||
char **out, *result, str_to_add[2], utf_char[16];
|
||||
char **out, *result;
|
||||
unsigned char *ptr_string;
|
||||
int length;
|
||||
|
||||
@@ -306,29 +306,30 @@ irc_color_encode (const char *string, int keep_colors)
|
||||
{
|
||||
case 0x02: /* ^B */
|
||||
if (keep_colors)
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_BOLD_STR);
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_BOLD_STR, -1);
|
||||
ptr_string++;
|
||||
break;
|
||||
case 0x03: /* ^C */
|
||||
if (keep_colors)
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_COLOR_STR);
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_COLOR_STR, -1);
|
||||
ptr_string++;
|
||||
if (isdigit (ptr_string[0]))
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
str_to_add[0] = ptr_string[0];
|
||||
str_to_add[1] = '\0';
|
||||
weechat_string_dyn_concat (out, str_to_add);
|
||||
weechat_string_dyn_concat (out,
|
||||
(const char *)ptr_string,
|
||||
1);
|
||||
}
|
||||
ptr_string++;
|
||||
if (isdigit (ptr_string[0]))
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
str_to_add[0] = ptr_string[0];
|
||||
str_to_add[1] = '\0';
|
||||
weechat_string_dyn_concat (out, str_to_add);
|
||||
weechat_string_dyn_concat (
|
||||
out,
|
||||
(const char *)ptr_string,
|
||||
1);
|
||||
}
|
||||
ptr_string++;
|
||||
}
|
||||
@@ -336,24 +337,26 @@ irc_color_encode (const char *string, int keep_colors)
|
||||
if (ptr_string[0] == ',')
|
||||
{
|
||||
if (keep_colors)
|
||||
weechat_string_dyn_concat (out, ",");
|
||||
weechat_string_dyn_concat (out, ",", -1);
|
||||
ptr_string++;
|
||||
if (isdigit (ptr_string[0]))
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
str_to_add[0] = ptr_string[0];
|
||||
str_to_add[1] = '\0';
|
||||
weechat_string_dyn_concat (out, str_to_add);
|
||||
weechat_string_dyn_concat (
|
||||
out,
|
||||
(const char *)ptr_string,
|
||||
1);
|
||||
}
|
||||
ptr_string++;
|
||||
if (isdigit (ptr_string[0]))
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
str_to_add[0] = ptr_string[0];
|
||||
str_to_add[1] = '\0';
|
||||
weechat_string_dyn_concat (out, str_to_add);
|
||||
weechat_string_dyn_concat (
|
||||
out,
|
||||
(const char *)ptr_string,
|
||||
1);
|
||||
}
|
||||
ptr_string++;
|
||||
}
|
||||
@@ -362,31 +365,31 @@ irc_color_encode (const char *string, int keep_colors)
|
||||
break;
|
||||
case 0x0F: /* ^O */
|
||||
if (keep_colors)
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_RESET_STR);
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_RESET_STR, -1);
|
||||
ptr_string++;
|
||||
break;
|
||||
case 0x16: /* ^V */
|
||||
if (keep_colors)
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_REVERSE_STR);
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_REVERSE_STR, -1);
|
||||
ptr_string++;
|
||||
break;
|
||||
case 0x1D: /* ^] */
|
||||
if (keep_colors)
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_ITALIC_STR);
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_ITALIC_STR, -1);
|
||||
ptr_string++;
|
||||
break;
|
||||
case 0x1F: /* ^_ */
|
||||
if (keep_colors)
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_UNDERLINE_STR);
|
||||
weechat_string_dyn_concat (out, IRC_COLOR_UNDERLINE_STR, -1);
|
||||
ptr_string++;
|
||||
break;
|
||||
default:
|
||||
length = weechat_utf8_char_size ((char *)ptr_string);
|
||||
if (length == 0)
|
||||
length = 1;
|
||||
memcpy (utf_char, ptr_string, length);
|
||||
utf_char[length] = '\0';
|
||||
weechat_string_dyn_concat (out, utf_char);
|
||||
weechat_string_dyn_concat (out,
|
||||
(const char *)ptr_string,
|
||||
length);
|
||||
ptr_string += length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,12 +515,12 @@ irc_protocol_cap_print_cb (void *data,
|
||||
str_caps = (char **)data;
|
||||
|
||||
if (*str_caps[0])
|
||||
weechat_string_dyn_concat (str_caps, " ");
|
||||
weechat_string_dyn_concat (str_caps, key);
|
||||
weechat_string_dyn_concat (str_caps, " ", -1);
|
||||
weechat_string_dyn_concat (str_caps, key, -1);
|
||||
if (value)
|
||||
{
|
||||
weechat_string_dyn_concat (str_caps, "=");
|
||||
weechat_string_dyn_concat (str_caps, value);
|
||||
weechat_string_dyn_concat (str_caps, "=", -1);
|
||||
weechat_string_dyn_concat (str_caps, value, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,9 +837,10 @@ IRC_PROTOCOL_CALLBACK(cap)
|
||||
if (caps_supported[i][0] == '-')
|
||||
{
|
||||
if (*str_caps_disabled[0])
|
||||
weechat_string_dyn_concat (str_caps_disabled, " ");
|
||||
weechat_string_dyn_concat (str_caps_disabled, " ", -1);
|
||||
weechat_string_dyn_concat (str_caps_disabled,
|
||||
caps_supported[i] + 1);
|
||||
caps_supported[i] + 1,
|
||||
-1);
|
||||
|
||||
weechat_hashtable_remove (server->cap_list,
|
||||
caps_supported[i] + 1);
|
||||
@@ -847,9 +848,10 @@ IRC_PROTOCOL_CALLBACK(cap)
|
||||
else
|
||||
{
|
||||
if (*str_caps_enabled[0])
|
||||
weechat_string_dyn_concat (str_caps_enabled, " ");
|
||||
weechat_string_dyn_concat (str_caps_enabled, " ", -1);
|
||||
weechat_string_dyn_concat (str_caps_enabled,
|
||||
caps_supported[i]);
|
||||
caps_supported[i],
|
||||
-1);
|
||||
|
||||
weechat_hashtable_set (server->cap_list,
|
||||
caps_supported[i], NULL);
|
||||
|
||||
@@ -5352,18 +5352,22 @@ irc_server_build_autojoin (struct t_irc_server *server)
|
||||
{
|
||||
/* add channel with key and the key */
|
||||
if (*channels_with_key[0])
|
||||
weechat_string_dyn_concat (channels_with_key, ",");
|
||||
weechat_string_dyn_concat (channels_with_key, ptr_channel->name);
|
||||
weechat_string_dyn_concat (channels_with_key, ",", -1);
|
||||
weechat_string_dyn_concat (channels_with_key,
|
||||
ptr_channel->name,
|
||||
-1);
|
||||
if (*keys[0])
|
||||
weechat_string_dyn_concat (keys, ",");
|
||||
weechat_string_dyn_concat (keys, ptr_channel->key);
|
||||
weechat_string_dyn_concat (keys, ",", -1);
|
||||
weechat_string_dyn_concat (keys, ptr_channel->key, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add channel without key */
|
||||
if (*channels_others[0])
|
||||
weechat_string_dyn_concat (channels_others, ",");
|
||||
weechat_string_dyn_concat (channels_others, ptr_channel->name);
|
||||
weechat_string_dyn_concat (channels_others, ",", -1);
|
||||
weechat_string_dyn_concat (channels_others,
|
||||
ptr_channel->name,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5375,13 +5379,13 @@ irc_server_build_autojoin (struct t_irc_server *server)
|
||||
if (*channels_others[0])
|
||||
{
|
||||
if (*channels_with_key[0])
|
||||
weechat_string_dyn_concat (channels_with_key, ",");
|
||||
weechat_string_dyn_concat (channels_with_key, *channels_others);
|
||||
weechat_string_dyn_concat (channels_with_key, ",", -1);
|
||||
weechat_string_dyn_concat (channels_with_key, *channels_others, -1);
|
||||
}
|
||||
if (*keys[0])
|
||||
{
|
||||
weechat_string_dyn_concat (channels_with_key, " ");
|
||||
weechat_string_dyn_concat (channels_with_key, *keys);
|
||||
weechat_string_dyn_concat (channels_with_key, " ", -1);
|
||||
weechat_string_dyn_concat (channels_with_key, *keys, -1);
|
||||
}
|
||||
|
||||
weechat_string_dyn_free (channels_others, 1);
|
||||
|
||||
Reference in New Issue
Block a user