]> jfr.im git - irc/weechat/weechat.git/commitdiff
api: add argument "bytes" in function string_dyn_concat
authorSébastien Helleu <redacted>
Sun, 23 Aug 2020 21:27:57 +0000 (23:27 +0200)
committerSébastien Helleu <redacted>
Sun, 23 Aug 2020 21:27:57 +0000 (23:27 +0200)
26 files changed:
ChangeLog.adoc
doc/en/weechat_plugin_api.en.adoc
doc/fr/weechat_plugin_api.fr.adoc
doc/it/weechat_plugin_api.it.adoc
doc/ja/weechat_plugin_api.ja.adoc
src/core/wee-eval.c
src/core/wee-string.c
src/core/wee-string.h
src/gui/gui-bar-item.c
src/gui/gui-chat.c
src/gui/gui-color.c
src/plugins/buflist/buflist-bar-item.c
src/plugins/buflist/buflist-config.c
src/plugins/fset/fset-bar-item.c
src/plugins/guile/weechat-guile.c
src/plugins/irc/irc-color.c
src/plugins/irc/irc-protocol.c
src/plugins/irc/irc-server.c
src/plugins/lua/weechat-lua.c
src/plugins/perl/weechat-perl.c
src/plugins/python/weechat-python.c
src/plugins/ruby/weechat-ruby.c
src/plugins/script/script-action.c
src/plugins/spell/spell-bar-item.c
src/plugins/weechat-plugin.h
tests/unit/core/test-core-string.cpp

index 89e392c5ca1aa99bc7fe5c2651c53a26881ec516..55b423398b6cda3bf9207de294d34b26ee0edf79 100644 (file)
@@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
 
 New features::
 
+  * api: add argument "bytes" in function string_dyn_concat
   * api: add function string_color_code_size (issue #1547)
   * fset: add option fset.look.auto_refresh (issue #1553)
   * irc: add pointer to irc_nick in focus of bar item "buffer_nicklist" (issue #1535, issue #1538)
index 172e9a9365b0a8c790c45563f2ef39edac5f4adc..f19c29f950b3a3eae08d1a7fd6af69f88125c01e 100644 (file)
@@ -2819,7 +2819,7 @@ This function is not available in scripting API.
 
 ==== string_dyn_concat
 
-_WeeChat ≥ 1.8._
+_WeeChat ≥ 1.8, updated in 3.0._
 
 Concatenate a string to a dynamic string.
 
@@ -2830,13 +2830,16 @@ Prototype:
 
 [source,C]
 ----
-int weechat_string_dyn_concat (char **string, const char *add);
+int weechat_string_dyn_concat (char **string, const char *add, int bytes);
 ----
 
 Arguments:
 
 * _string_: pointer to dynamic string
 * _add_: the string to add
+* _bytes_: max number of bytes in _add_ to concatenate, must be lower or equal
+  to length of _add_ (-1 = automatic: concatenate whole string _add_)
+  _(WeeChat ≥ 3.0)_
 
 Return value:
 
@@ -2849,7 +2852,7 @@ C example:
 char **string = weechat_string_dyn_alloc (256);
 if (weechat_string_dyn_copy (string, "test"))
 {
-    if (weechat_string_dyn_concat (string, "abc"))
+    if (weechat_string_dyn_concat (string, "abc", -1))
     {
         /* ... */
     }
index df275701ea025b6a9b4e25820ed45e4c79590c7e..ed6bf238d60a0c2925b37f1f909777a798aace48 100644 (file)
@@ -2864,7 +2864,7 @@ Cette fonction n'est pas disponible dans l'API script.
 
 ==== string_dyn_concat
 
-_WeeChat ≥ 1.8._
+_WeeChat ≥ 1.8, mis à jour en 3.0._
 
 Concaténer une chaîne dans une chaîne dynamique.
 
@@ -2875,13 +2875,16 @@ Prototype :
 
 [source,C]
 ----
-int weechat_string_dyn_concat (char **string, const char *add);
+int weechat_string_dyn_concat (char **string, const char *add, int bytes);
 ----
 
 Paramètres :
 
 * _string_ : pointeur vers la chaîne dynamique
 * _add_ : la chaîne à ajouter
+* _bytes_ : nombre maximum d'octets de _add_ à concaténer, doit être inférieur
+  ou égal à la longueur de _add_ (-1 = automatique : concaténer la totalité de
+  la chaîne _add_) _(WeeChat ≥ 3.0)_
 
 Valeur de retour :
 
@@ -2894,7 +2897,7 @@ Exemple en C :
 char **string = weechat_string_dyn_alloc (256);
 if (weechat_string_dyn_copy (string, "test"))
 {
-    if (weechat_string_dyn_concat (string, "abc"))
+    if (weechat_string_dyn_concat (string, "abc", -1))
     {
         /* ... */
     }
index 62b85ec7cee2b824d666de1e7b25ddb09abdd6b9..a7588fecae703fbb0669ddf57fc76bfb8ea2c94a 100644 (file)
@@ -2938,7 +2938,8 @@ Questa funzione non è disponibile nelle API per lo scripting.
 
 ==== string_dyn_concat
 
-_WeeChat ≥ 1.8._
+// TRANSLATION MISSING
+_WeeChat ≥ 1.8, updated in 3.0._
 
 // TRANSLATION MISSING
 Concatenate a string to a dynamic string.
@@ -2951,7 +2952,7 @@ Prototipo:
 
 [source,C]
 ----
-int weechat_string_dyn_concat (char **string, const char *add);
+int weechat_string_dyn_concat (char **string, const char *add, int bytes);
 ----
 
 Argomenti:
@@ -2959,6 +2960,9 @@ Argomenti:
 // TRANSLATION MISSING
 * _string_: pointer to dynamic string
 * _add_: the string to add
+* _bytes_: max number of bytes in _add_ to concatenate, must be lower or equal
+  to length of _add_ (-1 = automatic: concatenate whole string _add_)
+  _(WeeChat ≥ 3.0)_
 
 Valore restituito:
 
@@ -2972,7 +2976,7 @@ Esempio in C:
 char **string = weechat_string_dyn_alloc (256);
 if (weechat_string_dyn_copy (string, "test"))
 {
-    if (weechat_string_dyn_concat (string, "abc"))
+    if (weechat_string_dyn_concat (string, "abc", -1))
     {
         /* ... */
     }
index fdd40dea5971d47c721376ff39c805fb88ff798b..0ce3866f41dc900fe07c88b859d69965628a67e7 100644 (file)
@@ -2848,7 +2848,8 @@ else
 
 ==== string_dyn_concat
 
-_WeeChat バージョン 1.8 以上で利用可_
+// TRANSLATION MISSING
+_WeeChat バージョン 1.8 以上で利用可, updated in 3.0_
 
 動的文字列に文字列を連結します。
 
@@ -2859,13 +2860,17 @@ _WeeChat バージョン 1.8 以上で利用可_
 
 [source,C]
 ----
-int weechat_string_dyn_concat (char **string, const char *add);
+int weechat_string_dyn_concat (char **string, const char *add, int bytes);
 ----
 
 引数:
 
 * _string_: 動的文字列へのポインタ
 * _add_: 連結する文字列
+// TRANSLATION MISSING
+* _bytes_: max number of bytes in _add_ to concatenate, must be lower or equal
+  to length of _add_ (-1 = automatic: concatenate whole string _add_)
+  _(WeeChat ≥ 3.0)_
 
 戻り値:
 
@@ -2878,7 +2883,7 @@ C 言語での使用例:
 char **string = weechat_string_dyn_alloc (256);
 if (weechat_string_dyn_copy (string, "test"))
 {
-    if (weechat_string_dyn_concat (string, "abc"))
+    if (weechat_string_dyn_concat (string, "abc", -1))
     {
         /* ... */
     }
index 4d64c641f9732448fbf3e187034defa21093e45f..c36192f096feb6f5317b7ee96126f045ebce3647 100644 (file)
@@ -80,8 +80,8 @@ eval_debug_message (struct t_eval_context *eval_context, char *message, ...)
         return;
 
     if (*(eval_context->debug)[0])
-        string_dyn_concat (eval_context->debug, "\n");
-    string_dyn_concat (eval_context->debug, vbuffer);
+        string_dyn_concat (eval_context->debug, "\n", -1);
+    string_dyn_concat (eval_context->debug, vbuffer, -1);
 
     free (vbuffer);
 }
index 4c41239c3e980778df201f02abc07ebe31d768d4..9dbc2ce50ccac7e0ed9c18da9d62e5662450a7f6 100644 (file)
@@ -3978,6 +3978,10 @@ string_dyn_copy (char **string, const char *new_string)
 /*
  * Concatenates a string to a dynamic string and adjusts its size accordingly.
  *
+ * The parameter "bytes" is the max number of bytes to concatenate
+ * (a terminating null byte '\0' is automatically added); value -1 means
+ * automatic: whole string "add" is concatenated.
+ *
  * The string pointer (*string) is updated with the new allocated string
  * if the string had to be extended, or the same pointer if there was enough
  * size to concatenate the new string.
@@ -3988,7 +3992,7 @@ string_dyn_copy (char **string, const char *new_string)
  */
 
 int
-string_dyn_concat (char **string, const char *add)
+string_dyn_concat (char **string, const char *add, int bytes)
 {
     struct t_string_dyn *ptr_string_dyn;
     char *string_realloc;
@@ -3997,12 +4001,15 @@ string_dyn_concat (char **string, const char *add)
     if (!string || !*string)
         return 0;
 
-    if (!add || !add[0])
+    if (!add || !add[0] || (bytes == 0))
         return 1;
 
     ptr_string_dyn = (struct t_string_dyn *)string;
 
     length_add = strlen (add);
+    if ((bytes >= 0) && (bytes < (int)length_add))
+        length_add = bytes;
+
     new_size = ptr_string_dyn->size + length_add;
 
     if (new_size > ptr_string_dyn->size_alloc)
@@ -4027,8 +4034,9 @@ string_dyn_concat (char **string, const char *add)
     /* concatenate "add" after "string" */
     memmove (ptr_string_dyn->string + ptr_string_dyn->size - 1,
              add,
-             length_add + 1);
+             length_add);
     ptr_string_dyn->size = new_size;
+    ptr_string_dyn->string[new_size - 1] = '\0';
 
     return 1;
 }
index a34dbd041ddc3d7c2935b4c198364d25862ef299..c5451353550c46a512cc02a9e9454d823c744ae9 100644 (file)
@@ -134,7 +134,7 @@ extern const char *string_shared_get (const char *string);
 extern void string_shared_free (const char *string);
 extern char **string_dyn_alloc (int size_alloc);
 extern int string_dyn_copy (char **string, const char *new_string);
-extern int string_dyn_concat (char **string, const char *add);
+extern int string_dyn_concat (char **string, const char *add, int bytes);
 extern char *string_dyn_free (char **string, int free_string);
 extern void string_end ();
 
index 1390cee2a75f9ef71f383ab4be5b7eebb6386587..09de97d028f8fa4cc2cdfc06a2d5bea3a45d9ee6 100644 (file)
@@ -1769,7 +1769,7 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
                 && ptr_group->visible))
         {
             if (*nicklist[0])
-                string_dyn_concat (nicklist, "\n");
+                string_dyn_concat (nicklist, "\n", -1);
 
             if (ptr_nick)
             {
@@ -1777,7 +1777,7 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
                 {
                     for (i = 0; i < ptr_nick->group->level; i++)
                     {
-                        string_dyn_concat (nicklist, " ");
+                        string_dyn_concat (nicklist, " ", -1);
                     }
                 }
                 if (ptr_nick->prefix_color)
@@ -1793,18 +1793,20 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
                                 nicklist,
                                 gui_color_get_custom (
                                     gui_color_get_name (
-                                        CONFIG_COLOR(ptr_option))));
+                                        CONFIG_COLOR(ptr_option))),
+                                -1);
                         }
                     }
                     else
                     {
                         string_dyn_concat (nicklist,
                                            gui_color_get_custom (
-                                               ptr_nick->prefix_color));
+                                               ptr_nick->prefix_color),
+                                           -1);
                     }
                 }
                 if (ptr_nick->prefix)
-                    string_dyn_concat (nicklist, ptr_nick->prefix);
+                    string_dyn_concat (nicklist, ptr_nick->prefix, -1);
                 if (ptr_nick->color)
                 {
                     if (strchr (ptr_nick->color, '.'))
@@ -1818,23 +1820,25 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
                                 nicklist,
                                 gui_color_get_custom (
                                     gui_color_get_name (
-                                        CONFIG_COLOR(ptr_option))));
+                                        CONFIG_COLOR(ptr_option))),
+                                -1);
                         }
                     }
                     else
                     {
                         string_dyn_concat (nicklist,
                                            gui_color_get_custom (
-                                               ptr_nick->color));
+                                               ptr_nick->color),
+                                           -1);
                     }
                 }
-                string_dyn_concat (nicklist, ptr_nick->name);
+                string_dyn_concat (nicklist, ptr_nick->name, -1);
             }
             else
             {
                 for (i = 0; i < ptr_group->level - 1; i++)
                 {
-                    string_dyn_concat (nicklist, " ");
+                    string_dyn_concat (nicklist, " ", -1);
                 }
                 if (ptr_group->color)
                 {
@@ -1849,19 +1853,22 @@ gui_bar_item_buffer_nicklist_cb (const void *pointer, void *data,
                                 nicklist,
                                 gui_color_get_custom (
                                     gui_color_get_name (
-                                        CONFIG_COLOR(ptr_option))));
+                                        CONFIG_COLOR(ptr_option))),
+                                -1);
                         }
                     }
                     else
                     {
                         string_dyn_concat (nicklist,
                                            gui_color_get_custom (
-                                               ptr_group->color));
+                                               ptr_group->color),
+                                           -1);
                     }
                 }
                 string_dyn_concat (nicklist,
                                    gui_nicklist_get_group_start (
-                                       ptr_group->name));
+                                       ptr_group->name),
+                                   -1);
             }
         }
         gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
index f70e9bb5021b21594f23961b3f6eacf54818f826..36a7b90136c16937cfd1bc3a93dd17e5674a0247 100644 (file)
@@ -906,9 +906,9 @@ gui_chat_add_line_waiting_buffer (const char *message)
     }
 
     if (*gui_chat_lines_waiting_buffer[0])
-        string_dyn_concat (gui_chat_lines_waiting_buffer, "\n");
+        string_dyn_concat (gui_chat_lines_waiting_buffer, "\n", -1);
 
-    string_dyn_concat (gui_chat_lines_waiting_buffer, message);
+    string_dyn_concat (gui_chat_lines_waiting_buffer, message, -1);
 }
 
 /*
index c487eb68b304d757fe4b80ccc296510c56ee11b4..bc43ac44ee4b3f1970c73b6b8535ef64af2a7d69 100644 (file)
@@ -1192,16 +1192,16 @@ gui_color_add_ansi_flag (char **output, int flag)
     switch (flag)
     {
         case GUI_COLOR_EXTENDED_BOLD_FLAG:
-            string_dyn_concat (output, "\x1B[1m");
+            string_dyn_concat (output, "\x1B[1m", -1);
             break;
         case GUI_COLOR_EXTENDED_REVERSE_FLAG:
-            string_dyn_concat (output, "\x1B[7m");
+            string_dyn_concat (output, "\x1B[7m", -1);
             break;
         case GUI_COLOR_EXTENDED_ITALIC_FLAG:
-            string_dyn_concat (output, "\x1B[3m");
+            string_dyn_concat (output, "\x1B[3m", -1);
             break;
         case GUI_COLOR_EXTENDED_UNDERLINE_FLAG:
-            string_dyn_concat (output, "\x1B[4m");
+            string_dyn_concat (output, "\x1B[4m", -1);
             break;
         case GUI_COLOR_EXTENDED_KEEPATTR_FLAG:
             /* nothing to do here (really? not sure) */
@@ -1284,7 +1284,7 @@ gui_color_encode_ansi (const char *string)
                                     snprintf (str_concat, sizeof (str_concat),
                                               "\x1B[38;5;%dm",
                                               color);
-                                    string_dyn_concat (out, str_concat);
+                                    string_dyn_concat (out, str_concat, -1);
                                 }
                                 ptr_string += 5;
                             }
@@ -1311,7 +1311,7 @@ gui_color_encode_ansi (const char *string)
                                                   "\x1B[%dm",
                                                   (ansi_color < 8) ?
                                                   ansi_color + 30 : ansi_color - 8 + 90);
-                                        string_dyn_concat (out, str_concat);
+                                        string_dyn_concat (out, str_concat, -1);
                                     }
                                 }
                                 ptr_string += 2;
@@ -1335,7 +1335,7 @@ gui_color_encode_ansi (const char *string)
                                     snprintf (str_concat, sizeof (str_concat),
                                               "\x1B[48;5;%dm",
                                               color);
-                                    string_dyn_concat (out, str_concat);
+                                    string_dyn_concat (out, str_concat, -1);
                                 }
                                 ptr_string += 5;
                             }
@@ -1357,7 +1357,7 @@ gui_color_encode_ansi (const char *string)
                                                   "\x1B[%dm",
                                                   (ansi_color < 8) ?
                                                   ansi_color + 40 : ansi_color - 8 + 100);
-                                        string_dyn_concat (out, str_concat);
+                                        string_dyn_concat (out, str_concat, -1);
                                     }
                                 }
                                 ptr_string += 2;
@@ -1386,7 +1386,7 @@ gui_color_encode_ansi (const char *string)
                                     snprintf (str_concat, sizeof (str_concat),
                                               "\x1B[38;5;%dm",
                                               color);
-                                    string_dyn_concat (out, str_concat);
+                                    string_dyn_concat (out, str_concat, -1);
                                 }
                                 ptr_string += 5;
                             }
@@ -1413,7 +1413,7 @@ gui_color_encode_ansi (const char *string)
                                                   "\x1B[%dm",
                                                   (ansi_color < 8) ?
                                                   ansi_color + 30 : ansi_color - 8 + 90);
-                                        string_dyn_concat (out, str_concat);
+                                        string_dyn_concat (out, str_concat, -1);
                                     }
                                 }
                                 ptr_string += 2;
@@ -1443,7 +1443,7 @@ gui_color_encode_ansi (const char *string)
                                         snprintf (str_concat, sizeof (str_concat),
                                                   "\x1B[48;5;%dm",
                                                   color);
-                                        string_dyn_concat (out, str_concat);
+                                        string_dyn_concat (out, str_concat, -1);
                                     }
                                     ptr_string += 5;
                                 }
@@ -1466,7 +1466,7 @@ gui_color_encode_ansi (const char *string)
                                                       "\x1B[%dm",
                                                       (ansi_color < 8) ?
                                                       ansi_color + 40 : ansi_color - 8 + 100);
-                                            string_dyn_concat (out, str_concat);
+                                            string_dyn_concat (out, str_concat, -1);
                                         }
                                     }
                                     ptr_string += 2;
@@ -1489,7 +1489,7 @@ gui_color_encode_ansi (const char *string)
                                 snprintf (str_concat, sizeof (str_concat),
                                           "\x1B[38;5;%dm",
                                           color);
-                                string_dyn_concat (out, str_concat);
+                                string_dyn_concat (out, str_concat, -1);
                             }
                             ptr_string += 5;
                         }
@@ -1515,7 +1515,7 @@ gui_color_encode_ansi (const char *string)
                         break;
                     case GUI_COLOR_RESET_CHAR:
                         ptr_string++;
-                        string_dyn_concat (out, "\x1B[39m\x1B[49m");
+                        string_dyn_concat (out, "\x1B[39m\x1B[49m", -1);
                         break;
                     default:
                         if (isdigit (ptr_string[0]) && isdigit (ptr_string[1]))
@@ -1532,40 +1532,40 @@ gui_color_encode_ansi (const char *string)
                                 bg = gui_color[color]->background;
                                 attrs = gui_color_get_extended_flags (
                                     gui_color[color]->attributes);
-                                string_dyn_concat (out, "\x1B[0m");
+                                string_dyn_concat (out, "\x1B[0m", -1);
                                 if (attrs & GUI_COLOR_EXTENDED_BOLD_FLAG)
-                                    string_dyn_concat (out, "\x1B[1m");
+                                    string_dyn_concat (out, "\x1B[1m", -1);
                                 if (attrs & GUI_COLOR_EXTENDED_REVERSE_FLAG)
-                                    string_dyn_concat (out, "\x1B[7m");
+                                    string_dyn_concat (out, "\x1B[7m", -1);
                                 if (attrs & GUI_COLOR_EXTENDED_ITALIC_FLAG)
-                                    string_dyn_concat (out, "\x1B[3m");
+                                    string_dyn_concat (out, "\x1B[3m", -1);
                                 if (attrs & GUI_COLOR_EXTENDED_UNDERLINE_FLAG)
-                                    string_dyn_concat (out, "\x1B[4m");
+                                    string_dyn_concat (out, "\x1B[4m", -1);
                                 if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
                                     fg &= GUI_COLOR_EXTENDED_MASK;
                                 if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
                                     bg &= GUI_COLOR_EXTENDED_MASK;
                                 if (fg < 0)
                                 {
-                                    string_dyn_concat (out, "\x1B[39m");
+                                    string_dyn_concat (out, "\x1B[39m", -1);
                                 }
                                 else
                                 {
                                     snprintf (str_concat, sizeof (str_concat),
                                               "\x1B[38;5;%dm",
                                               fg);
-                                    string_dyn_concat (out, str_concat);
+                                    string_dyn_concat (out, str_concat, -1);
                                 }
                                 if (bg < 0)
                                 {
-                                    string_dyn_concat (out, "\x1B[49m");
+                                    string_dyn_concat (out, "\x1B[49m", -1);
                                 }
                                 else
                                 {
                                     snprintf (str_concat, sizeof (str_concat),
                                               "\x1B[48;5;%dm",
                                               bg);
-                                    string_dyn_concat (out, str_concat);
+                                    string_dyn_concat (out, str_concat, -1);
                                 }
                             }
                             ptr_string += 2;
@@ -1580,16 +1580,16 @@ gui_color_encode_ansi (const char *string)
                     switch (ptr_string[0])
                     {
                         case GUI_COLOR_ATTR_BOLD_CHAR:
-                            string_dyn_concat (out, "\x1B[1m");
+                            string_dyn_concat (out, "\x1B[1m", -1);
                             break;
                         case GUI_COLOR_ATTR_REVERSE_CHAR:
-                            string_dyn_concat (out, "\x1B[7m");
+                            string_dyn_concat (out, "\x1B[7m", -1);
                             break;
                         case GUI_COLOR_ATTR_ITALIC_CHAR:
-                            string_dyn_concat (out, "\x1B[3m");
+                            string_dyn_concat (out, "\x1B[3m", -1);
                             break;
                         case GUI_COLOR_ATTR_UNDERLINE_CHAR:
-                            string_dyn_concat (out, "\x1B[4m");
+                            string_dyn_concat (out, "\x1B[4m", -1);
                             break;
                     }
                     ptr_string++;
@@ -1602,32 +1602,30 @@ gui_color_encode_ansi (const char *string)
                     switch (ptr_string[0])
                     {
                         case GUI_COLOR_ATTR_BOLD_CHAR:
-                            string_dyn_concat (out, "\x1B[21m");
+                            string_dyn_concat (out, "\x1B[21m", -1);
                             break;
                         case GUI_COLOR_ATTR_REVERSE_CHAR:
-                            string_dyn_concat (out, "\x1B[27m");
+                            string_dyn_concat (out, "\x1B[27m", -1);
                             break;
                         case GUI_COLOR_ATTR_ITALIC_CHAR:
-                            string_dyn_concat (out, "\x1B[23m");
+                            string_dyn_concat (out, "\x1B[23m", -1);
                             break;
                         case GUI_COLOR_ATTR_UNDERLINE_CHAR:
-                            string_dyn_concat (out, "\x1B[24m");
+                            string_dyn_concat (out, "\x1B[24m", -1);
                             break;
                     }
                     ptr_string++;
                 }
                 break;
             case GUI_COLOR_RESET_CHAR:
-                string_dyn_concat (out, "\x1B[0m");
+                string_dyn_concat (out, "\x1B[0m", -1);
                 ptr_string++;
                 break;
             default:
                 length = utf8_char_size ((char *)ptr_string);
                 if (length == 0)
                     length = 1;
-                memcpy (str_concat, ptr_string, length);
-                str_concat[length] = '\0';
-                string_dyn_concat (out, str_concat);
+                string_dyn_concat (out, (const char *)ptr_string, length);
                 ptr_string += length;
                 break;
         }
index e82fc18bceabf4d09e4cc552aaca5f6640a7da2e..01efdda8a20229336261f42eba833b244b224847 100644 (file)
@@ -542,15 +542,19 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
                             weechat_string_dyn_concat (
                                 hotlist,
                                 weechat_config_string (
-                                    buflist_config_format_hotlist_separator));
+                                    buflist_config_format_hotlist_separator),
+                                -1);
                         }
                         weechat_string_dyn_concat (
                             hotlist,
                             weechat_config_string (
-                                buflist_config_format_hotlist_level[j]));
+                                buflist_config_format_hotlist_level[j]),
+                            -1);
                         snprintf (str_hotlist_count, sizeof (str_hotlist_count),
                                   "%d", count);
-                        weechat_string_dyn_concat (hotlist, str_hotlist_count);
+                        weechat_string_dyn_concat (hotlist,
+                                                   str_hotlist_count,
+                                                   -1);
                     }
                 }
                 str_hotlist = *hotlist;
@@ -606,7 +610,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
         if (weechat_config_boolean (buflist_config_look_add_newline)
             && *buflist[0])
         {
-            if (!weechat_string_dyn_concat (buflist, "\n"))
+            if (!weechat_string_dyn_concat (buflist, "\n", -1))
                 goto error;
         }
 
@@ -618,7 +622,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
             NULL);
 
         /* concatenate string */
-        rc = weechat_string_dyn_concat (buflist, line);
+        rc = weechat_string_dyn_concat (buflist, line, -1);
         free (line);
         if (!rc)
             goto error;
index 111cf996a917da9967176a01089a3dea12e0bbae..5c60f2f441cc5363cf1c260b0a02922f1c72b932 100644 (file)
@@ -151,18 +151,19 @@ buflist_config_hook_signals_refresh ()
     ptr_signals_refresh = weechat_config_string (
         buflist_config_look_signals_refresh);
 
-    weechat_string_dyn_concat (all_signals, BUFLIST_CONFIG_SIGNALS_REFRESH);
+    weechat_string_dyn_concat (all_signals, BUFLIST_CONFIG_SIGNALS_REFRESH, -1);
     if (ptr_signals_refresh && ptr_signals_refresh[0])
     {
-        weechat_string_dyn_concat (all_signals, ",");
-        weechat_string_dyn_concat (all_signals, ptr_signals_refresh);
+        weechat_string_dyn_concat (all_signals, ",", -1);
+        weechat_string_dyn_concat (all_signals, ptr_signals_refresh, -1);
     }
     if (weechat_config_boolean (buflist_config_look_nick_prefix))
     {
-        weechat_string_dyn_concat (all_signals, ",");
+        weechat_string_dyn_concat (all_signals, ",", -1);
         weechat_string_dyn_concat (
             all_signals,
-            BUFLIST_CONFIG_SIGNALS_REFRESH_NICK_PREFIX);
+            BUFLIST_CONFIG_SIGNALS_REFRESH_NICK_PREFIX,
+            -1);
     }
 
     signals = weechat_string_split (*all_signals, ",", NULL,
index bef62d773d57a3263e59e4604b99bdf6f34be3ec..60d04c1a17f3941b9878547febcbdf1bcc0146ab 100644 (file)
@@ -81,8 +81,8 @@ fset_bar_item_fset_cb (const void *pointer, void *data,
     if (!default_and_values)
         return NULL;
 
-    weechat_string_dyn_concat (default_and_values, weechat_color ("bar_fg"));
-    weechat_string_dyn_concat (default_and_values, _("default: "));
+    weechat_string_dyn_concat (default_and_values, weechat_color ("bar_fg"), -1);
+    weechat_string_dyn_concat (default_and_values, _("default: "), -1);
     if (ptr_fset_option->default_value)
     {
         if (ptr_fset_option->type == FSET_OPTION_TYPE_STRING)
@@ -90,29 +90,37 @@ fset_bar_item_fset_cb (const void *pointer, void *data,
             weechat_string_dyn_concat (default_and_values,
                                        weechat_color (
                                            weechat_config_string (
-                                               fset_config_color_help_quotes)));
-            weechat_string_dyn_concat (default_and_values, "\"");
+                                               fset_config_color_help_quotes)),
+                                       -1);
+            weechat_string_dyn_concat (default_and_values, "\"", -1);
         }
         weechat_string_dyn_concat (
             default_and_values,
-            weechat_color (weechat_config_string (fset_config_color_help_default_value)));
+            weechat_color (weechat_config_string (fset_config_color_help_default_value)),
+            -1);
         weechat_string_dyn_concat (default_and_values,
-                                   ptr_fset_option->default_value);
+                                   ptr_fset_option->default_value,
+                                   -1);
         if (ptr_fset_option->type == FSET_OPTION_TYPE_STRING)
         {
             weechat_string_dyn_concat (default_and_values,
                                        weechat_color (
                                            weechat_config_string (
-                                               fset_config_color_help_quotes)));
-            weechat_string_dyn_concat (default_and_values, "\"");
+                                               fset_config_color_help_quotes)),
+                                       -1);
+            weechat_string_dyn_concat (default_and_values, "\"", -1);
         }
     }
     else
     {
         weechat_string_dyn_concat (
             default_and_values,
-            weechat_color (weechat_config_string (fset_config_color_help_default_value)));
-        weechat_string_dyn_concat (default_and_values, FSET_OPTION_VALUE_NULL);
+            weechat_color (weechat_config_string (fset_config_color_help_default_value)),
+            -1);
+        weechat_string_dyn_concat (
+            default_and_values,
+            FSET_OPTION_VALUE_NULL,
+            -1);
     }
 
     if ((ptr_fset_option->string_values && ptr_fset_option->string_values[0])
@@ -131,10 +139,11 @@ fset_bar_item_fset_cb (const void *pointer, void *data,
                 || (ptr_fset_option->type == FSET_OPTION_TYPE_INTEGER))
             {
                 weechat_string_dyn_concat (default_and_values,
-                                           weechat_color ("bar_fg"));
-                weechat_string_dyn_concat (default_and_values, ", ");
-                weechat_string_dyn_concat (default_and_values, _("values:"));
-                weechat_string_dyn_concat (default_and_values, " ");
+                                           weechat_color ("bar_fg"),
+                                           -1);
+                weechat_string_dyn_concat (default_and_values, ", ", -1);
+                weechat_string_dyn_concat (default_and_values, _("values:"), -1);
+                weechat_string_dyn_concat (default_and_values, " ", -1);
                 if (ptr_string_values)
                 {
                     for (i = 0; ptr_string_values[i]; i++)
@@ -142,16 +151,21 @@ fset_bar_item_fset_cb (const void *pointer, void *data,
                         if (i > 0)
                         {
                             weechat_string_dyn_concat (default_and_values,
-                                                       weechat_color ("bar_fg"));
-                            weechat_string_dyn_concat (default_and_values, ", ");
+                                                       weechat_color ("bar_fg"),
+                                                       -1);
+                            weechat_string_dyn_concat (default_and_values,
+                                                       ", ",
+                                                       -1);
                         }
                         weechat_string_dyn_concat (
                             default_and_values,
                             weechat_color (
                                 weechat_config_string (
-                                    fset_config_color_help_values)));
+                                    fset_config_color_help_values)),
+                            -1);
                         weechat_string_dyn_concat (default_and_values,
-                                                   ptr_string_values[i]);
+                                                   ptr_string_values[i],
+                                                   -1);
                     }
                 }
                 else
@@ -160,19 +174,24 @@ fset_bar_item_fset_cb (const void *pointer, void *data,
                         default_and_values,
                         weechat_color (
                             weechat_config_string (
-                                fset_config_color_help_values)));
+                                fset_config_color_help_values)),
+                        -1);
                     weechat_string_dyn_concat (default_and_values,
-                                               ptr_fset_option->min);
+                                               ptr_fset_option->min,
+                                               -1);
                     weechat_string_dyn_concat (default_and_values,
-                                               weechat_color ("bar_fg"));
-                    weechat_string_dyn_concat (default_and_values, " ... ");
+                                               weechat_color ("bar_fg"),
+                                               -1);
+                    weechat_string_dyn_concat (default_and_values, " ... ", -1);
                     weechat_string_dyn_concat (
                         default_and_values,
                         weechat_color (
                             weechat_config_string (
-                                fset_config_color_help_values)));
+                                fset_config_color_help_values)),
+                        -1);
                     weechat_string_dyn_concat (default_and_values,
-                                               ptr_fset_option->max);
+                                               ptr_fset_option->max,
+                                               -1);
                 }
             }
         }
index 4b6406e48f0cf9259e948a127c7f0cdaf7af8458..e1a6484c72449f7921a377181512e3aff944c357 100644 (file)
@@ -1180,13 +1180,13 @@ weechat_guile_port_write (SCM port, SCM src, size_t start, size_t count)
     ptr_data = data2;
     while ((ptr_newline = strchr (ptr_data, '\n')) != NULL)
     {
-        ptr_newline[0] = '\0';
-        weechat_string_dyn_concat (guile_buffer_output, ptr_data);
+        weechat_string_dyn_concat (guile_buffer_output,
+                                   ptr_data,
+                                   ptr_newline - ptr_data);
         weechat_guile_output_flush ();
-        ptr_newline[0] = '\n';
         ptr_data = ++ptr_newline;
     }
-    weechat_string_dyn_concat (guile_buffer_output, ptr_data);
+    weechat_string_dyn_concat (guile_buffer_output, ptr_data, -1);
 
     free (data2);
 
@@ -1212,13 +1212,13 @@ weechat_guile_port_write (SCM port, const void *data, size_t size)
     ptr_data = data2;
     while ((ptr_newline = strchr (ptr_data, '\n')) != NULL)
     {
-        ptr_newline[0] = '\0';
-        weechat_string_dyn_concat (guile_buffer_output, ptr_data);
+        weechat_string_dyn_concat (guile_buffer_output,
+                                   ptr_data,
+                                   ptr_newline - ptr_data);
         weechat_guile_output_flush ();
-        ptr_newline[0] = '\n';
         ptr_data = ++ptr_newline;
     }
-    weechat_string_dyn_concat (guile_buffer_output, ptr_data);
+    weechat_string_dyn_concat (guile_buffer_output, ptr_data, -1);
 
     free (data2);
 }
index 4ec0c9e30324a8616c20d9a10322a00927865ea5..3919c0466ba0f90ac4f6b1d30f36158621e28d01 100644 (file)
@@ -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;
         }
     }
index d20860898791306a3f35acd07b14e423bc4ea17c..dc3fad004e76c3741f9f01239b668ca4ee82534d 100644 (file)
@@ -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);
index e987495180c446f125e8895d7952a71e47a840a9..4e0dbe6c4782cd6308d0d8deff8ab9e84cacde89 100644 (file)
@@ -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);
index df03dc4e5ee851d25912b802eb1998974a2bab52..30c042ac88769fb80e456c73b683b3c9437efdaa 100644 (file)
@@ -258,7 +258,6 @@ int
 weechat_lua_output (lua_State *L)
 {
     const char *msg, *ptr_msg, *ptr_newline;
-    char *message;
 
     if (lua_gettop (L) < 1)
         return 0;
@@ -267,14 +266,13 @@ weechat_lua_output (lua_State *L)
     ptr_msg = msg;
     while ((ptr_newline = strchr (ptr_msg, '\n')) != NULL)
     {
-        message = weechat_strndup (ptr_msg, ptr_newline - ptr_msg);
-        weechat_string_dyn_concat (lua_buffer_output, message);
-        if (message)
-            free (message);
+        weechat_string_dyn_concat (lua_buffer_output,
+                                   ptr_msg,
+                                   ptr_newline - ptr_msg);
         weechat_lua_output_flush ();
         ptr_msg = ++ptr_newline;
     }
-    weechat_string_dyn_concat (lua_buffer_output, ptr_msg);
+    weechat_string_dyn_concat (lua_buffer_output, ptr_msg, -1);
 
     return 0;
 }
index 264921d1c0c1bf94fce441cefe339d09a8f91f81..996a51398b67c0c4c32c2a38a928252348acf08e 100644 (file)
@@ -292,7 +292,7 @@ weechat_perl_output_flush ()
 
 XS (weechat_perl_output)
 {
-    char *msg, *ptr_msg, *ptr_newline, *message;
+    char *msg, *ptr_msg, *ptr_newline;
     dXSARGS;
 
     if (items < 1)
@@ -302,14 +302,13 @@ XS (weechat_perl_output)
     ptr_msg = msg;
     while ((ptr_newline = strchr (ptr_msg, '\n')) != NULL)
     {
-        message = weechat_strndup (ptr_msg, ptr_newline - ptr_msg);
-        weechat_string_dyn_concat (perl_buffer_output, message);
-        if (message)
-            free (message);
+        weechat_string_dyn_concat (perl_buffer_output,
+                                   ptr_msg,
+                                   ptr_newline - ptr_msg);
         weechat_perl_output_flush ();
         ptr_msg = ++ptr_newline;
     }
-    weechat_string_dyn_concat (perl_buffer_output, ptr_msg);
+    weechat_string_dyn_concat (perl_buffer_output, ptr_msg, -1);
 }
 
 /*
index 2515f6f08b55d9a92f6f0e021686e1f4d9a2b958..d9731784d960f1e6be04ad45754cb1683537a022 100644 (file)
@@ -444,13 +444,13 @@ weechat_python_output (PyObject *self, PyObject *args)
         ptr_msg = msg;
         while ((ptr_newline = strchr (ptr_msg, '\n')) != NULL)
         {
-            ptr_newline[0] = '\0';
-            weechat_string_dyn_concat (python_buffer_output, ptr_msg);
+            weechat_string_dyn_concat (python_buffer_output,
+                                       ptr_msg,
+                                       ptr_newline - ptr_msg);
             weechat_python_output_flush ();
-            ptr_newline[0] = '\n';
             ptr_msg = ++ptr_newline;
         }
-        weechat_string_dyn_concat (python_buffer_output, ptr_msg);
+        weechat_string_dyn_concat (python_buffer_output, ptr_msg, -1);
     }
 
     Py_INCREF(Py_None);
index faa2e354c61841b5c02c9a5cad96234635380895..1603610636d3a19b7289a4748b1d83142fb82c98 100644 (file)
@@ -428,24 +428,23 @@ weechat_ruby_output_flush ()
 static VALUE
 weechat_ruby_output (VALUE self, VALUE str)
 {
-    char *msg, *m, *p;
+    char *msg, *ptr_msg, *ptr_newline;
 
     /* make C compiler happy */
     (void) self;
 
     msg = strdup (StringValuePtr (str));
 
-    m = msg;
-    while ((p = strchr (m, '\n')) != NULL)
+    ptr_msg = msg;
+    while ((ptr_newline = strchr (ptr_msg, '\n')) != NULL)
     {
-        *p = '\0';
-        weechat_string_dyn_concat (ruby_buffer_output, m);
+        weechat_string_dyn_concat (ruby_buffer_output,
+                                   ptr_msg,
+                                   ptr_newline - ptr_msg);
         weechat_ruby_output_flush ();
-        *p = '\n';
-        m = ++p;
+        ptr_msg = ++ptr_newline;
     }
-
-    weechat_string_dyn_concat (ruby_buffer_output, m);
+    weechat_string_dyn_concat (ruby_buffer_output, ptr_msg, -1);
 
     if (msg)
         free (msg);
index bb79f45343457a949e8642e7bfa650d7253ccab7..faedbfb84cc43842d2ea169b15cfc4958cb0efff 100644 (file)
@@ -121,25 +121,29 @@ script_action_list_input (int send_to_buffer, int translated)
         {
             if (*buf[0])
             {
-                weechat_string_dyn_concat (buf, ", ");
+                weechat_string_dyn_concat (buf, ", ", -1);
             }
             else
             {
                 weechat_string_dyn_concat (
                     buf,
-                    (translated) ? _("Scripts loaded:") : "Scripts loaded:");
-                weechat_string_dyn_concat (buf, " ");
+                    (translated) ? _("Scripts loaded:") : "Scripts loaded:",
+                    -1);
+                weechat_string_dyn_concat (buf, " ", -1);
             }
             weechat_string_dyn_concat (buf,
                                        weechat_hdata_string (hdata,
                                                              ptr_script,
-                                                             "name"));
-            weechat_string_dyn_concat (buf, ".");
-            weechat_string_dyn_concat (buf, script_extension[i]);
-            weechat_string_dyn_concat (buf, " ");
-            weechat_string_dyn_concat (buf, weechat_hdata_string (hdata,
-                                                                  ptr_script,
-                                                                  "version"));
+                                                             "name"),
+                                       -1);
+            weechat_string_dyn_concat (buf, ".", -1);
+            weechat_string_dyn_concat (buf, script_extension[i], -1);
+            weechat_string_dyn_concat (buf, " ", -1);
+            weechat_string_dyn_concat (buf,
+                                       weechat_hdata_string (hdata,
+                                                             ptr_script,
+                                                             "version"),
+                                       -1);
             ptr_script = weechat_hdata_move (hdata, ptr_script, 1);
         }
     }
@@ -148,7 +152,8 @@ script_action_list_input (int send_to_buffer, int translated)
     {
         weechat_string_dyn_concat (
             buf,
-            (translated) ? _("No scripts loaded") : "No scripts loaded");
+            (translated) ? _("No scripts loaded") : "No scripts loaded",
+            -1);
     }
 
     if (send_to_buffer)
index b0b6e7ed34529838862dd962fbc09f5190bbf957..473e957ba87800d1d13220b10d5e694d565b7a79 100644 (file)
@@ -117,11 +117,13 @@ spell_bar_item_suggest (const void *pointer, void *data,
                 str_suggest,
                 weechat_color (
                     weechat_config_string (
-                        spell_config_color_suggestion_delimiter_dict)));
+                        spell_config_color_suggestion_delimiter_dict)),
+                -1);
             weechat_string_dyn_concat (
                 str_suggest,
                 weechat_config_string (
-                    spell_config_look_suggestion_delimiter_dict));
+                    spell_config_look_suggestion_delimiter_dict),
+                -1);
         }
         suggestions2 = weechat_string_split (
             suggestions[i],
@@ -142,18 +144,21 @@ spell_bar_item_suggest (const void *pointer, void *data,
                         str_suggest,
                         weechat_color (
                             weechat_config_string (
-                                spell_config_color_suggestion_delimiter_word)));
+                                spell_config_color_suggestion_delimiter_word)),
+                        -1);
                     weechat_string_dyn_concat (
                         str_suggest,
                         weechat_config_string (
-                            spell_config_look_suggestion_delimiter_word));
+                            spell_config_look_suggestion_delimiter_word),
+                        -1);
                 }
                 weechat_string_dyn_concat (
                     str_suggest,
                     weechat_color (
                         weechat_config_string (
-                            spell_config_color_suggestion)));
-                weechat_string_dyn_concat (str_suggest, suggestions2[j]);
+                            spell_config_color_suggestion)),
+                    -1);
+                weechat_string_dyn_concat (str_suggest, suggestions2[j], -1);
             }
             weechat_string_free_split (suggestions2);
         }
index b8cf10456eabb48a7db124bafdee79329c96c951..e2ba4cec2546bafd88a70101add4022e2d4a2ef8 100644 (file)
@@ -67,7 +67,7 @@ struct timeval;
  * please change the date with current one; for a second change at same
  * date, increment the 01, otherwise please keep 01.
  */
-#define WEECHAT_PLUGIN_API_VERSION "20200822-01"
+#define WEECHAT_PLUGIN_API_VERSION "20200823-01"
 
 /* macros for defining plugin infos */
 #define WEECHAT_PLUGIN_NAME(__name)                                     \
@@ -350,7 +350,7 @@ struct t_weechat_plugin
                                      struct t_hashtable *options);
     char **(*string_dyn_alloc) (int size_alloc);
     int (*string_dyn_copy) (char **string, const char *new_string);
-    int (*string_dyn_concat) (char **string, const char *add);
+    int (*string_dyn_concat) (char **string, const char *add, int bytes);
     char *(*string_dyn_free) (char **string, int free_string);
 
     /* UTF-8 strings */
@@ -1292,8 +1292,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
     (weechat_plugin->string_dyn_alloc)(__size_alloc)
 #define weechat_string_dyn_copy(__string, __new_string)                 \
     (weechat_plugin->string_dyn_copy)(__string, __new_string)
-#define weechat_string_dyn_concat(__string, __add)                      \
-    (weechat_plugin->string_dyn_concat)(__string, __add)
+#define weechat_string_dyn_concat(__string, __add, __bytes)             \
+    (weechat_plugin->string_dyn_concat)(__string, __add, __bytes)
 #define weechat_string_dyn_free(__string, __free_string)                \
     (weechat_plugin->string_dyn_free)(__string, __free_string)
 
index 9812a2367c02c976094a61e19f7ac022608c7eef..d12b2acea7a0353ddf58ffcfdf3546175dd34557 100644 (file)
@@ -2160,7 +2160,7 @@ TEST(CoreString, Dyn)
     ptr_string_dyn = (struct t_string_dyn *)str;
 
     /* check concat with NULL */
-    LONGS_EQUAL(1, string_dyn_concat (str, NULL));
+    LONGS_EQUAL(1, string_dyn_concat (str, NULL, -1));
     LONGS_EQUAL(1, ptr_string_dyn->size_alloc);
     LONGS_EQUAL(1, ptr_string_dyn->size);
     POINTERS_EQUAL(ptr_string_dyn->string, *str);
@@ -2168,46 +2168,81 @@ TEST(CoreString, Dyn)
     STRCMP_EQUAL("", *str);
 
     /* check concat with an empty string */
-    LONGS_EQUAL(1, string_dyn_concat (str, ""));
+    LONGS_EQUAL(1, string_dyn_concat (str, "", -1));
     LONGS_EQUAL(1, ptr_string_dyn->size_alloc);
     LONGS_EQUAL(1, ptr_string_dyn->size);
     POINTERS_EQUAL(ptr_string_dyn->string, *str);
     STRCMP_EQUAL("", ptr_string_dyn->string);
     STRCMP_EQUAL("", *str);
 
-    /* check concat with some strings */
-    LONGS_EQUAL(1, string_dyn_concat (str, "a"));
+    /* check concat with some strings and automatic length */
+    LONGS_EQUAL(1, string_dyn_concat (str, "a", -1));
     LONGS_EQUAL(2, ptr_string_dyn->size_alloc);
     LONGS_EQUAL(2, ptr_string_dyn->size);
     POINTERS_EQUAL(ptr_string_dyn->string, *str);
     STRCMP_EQUAL("a", ptr_string_dyn->string);
     STRCMP_EQUAL("a", *str);
 
-    LONGS_EQUAL(1, string_dyn_concat (str, "bcd"));
+    LONGS_EQUAL(1, string_dyn_concat (str, "bcd", -1));
     LONGS_EQUAL(5, ptr_string_dyn->size_alloc);
     LONGS_EQUAL(5, ptr_string_dyn->size);
     POINTERS_EQUAL(ptr_string_dyn->string, *str);
     STRCMP_EQUAL("abcd", ptr_string_dyn->string);
     STRCMP_EQUAL("abcd", *str);
 
-    LONGS_EQUAL(1, string_dyn_concat (str, "e"));
+    LONGS_EQUAL(1, string_dyn_concat (str, "e", -1));
     LONGS_EQUAL(7, ptr_string_dyn->size_alloc);
     LONGS_EQUAL(6, ptr_string_dyn->size);
     POINTERS_EQUAL(ptr_string_dyn->string, *str);
     STRCMP_EQUAL("abcde", ptr_string_dyn->string);
     STRCMP_EQUAL("abcde", *str);
 
-    LONGS_EQUAL(1, string_dyn_concat (str, "fg"));
+    LONGS_EQUAL(1, string_dyn_concat (str, "fg", -1));
     LONGS_EQUAL(10, ptr_string_dyn->size_alloc);
     LONGS_EQUAL(8, ptr_string_dyn->size);
     POINTERS_EQUAL(ptr_string_dyn->string, *str);
     STRCMP_EQUAL("abcdefg", ptr_string_dyn->string);
     STRCMP_EQUAL("abcdefg", *str);
 
+    string_dyn_free (str, 1);
+
+    str = string_dyn_alloc (1);
+    ptr_string_dyn = (struct t_string_dyn *)str;
+
+    /* check concat with some strings and fixed length */
+    LONGS_EQUAL(1, string_dyn_copy (str, "abcd"));
+    LONGS_EQUAL(1, string_dyn_concat (str, "xyz", 0));
+    LONGS_EQUAL(5, ptr_string_dyn->size_alloc);
+    LONGS_EQUAL(5, ptr_string_dyn->size);
+    POINTERS_EQUAL(ptr_string_dyn->string, *str);
+    STRCMP_EQUAL("abcd", ptr_string_dyn->string);
+    STRCMP_EQUAL("abcd", *str);
+
+    LONGS_EQUAL(1, string_dyn_concat (str, "xyz", 1));
+    LONGS_EQUAL(7, ptr_string_dyn->size_alloc);
+    LONGS_EQUAL(6, ptr_string_dyn->size);
+    POINTERS_EQUAL(ptr_string_dyn->string, *str);
+    STRCMP_EQUAL("abcdx", ptr_string_dyn->string);
+    STRCMP_EQUAL("abcdx", *str);
+
+    LONGS_EQUAL(1, string_dyn_concat (str, "xyz", 2));
+    LONGS_EQUAL(10, ptr_string_dyn->size_alloc);
+    LONGS_EQUAL(8, ptr_string_dyn->size);
+    POINTERS_EQUAL(ptr_string_dyn->string, *str);
+    STRCMP_EQUAL("abcdxxy", ptr_string_dyn->string);
+    STRCMP_EQUAL("abcdxxy", *str);
+
+    LONGS_EQUAL(1, string_dyn_concat (str, "xyz", 3));
+    LONGS_EQUAL(15, ptr_string_dyn->size_alloc);
+    LONGS_EQUAL(11, ptr_string_dyn->size);
+    POINTERS_EQUAL(ptr_string_dyn->string, *str);
+    STRCMP_EQUAL("abcdxxyxyz", ptr_string_dyn->string);
+    STRCMP_EQUAL("abcdxxyxyz", *str);
+
     str_ptr = *str;
     string_dyn_free (str, 0);
 
-    STRCMP_EQUAL("abcdefg", str_ptr);
+    STRCMP_EQUAL("abcdxxyxyz", str_ptr);
 
     free (str_ptr);
 }