core: replace argument "keep_eol" by "flags" in function string_split (closes #1322)
This commit is contained in:
parent
8aa5f5375e
commit
2b70d71aa1
@ -21,6 +21,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
New features::
|
||||
|
||||
* core: add option "addreplace" in command /filter (issue #1055, issue #1312)
|
||||
* api: replace argument "keep_eol" by "flags" in function string_split (issue #1322)
|
||||
* api: add function command_options (issue #928)
|
||||
* api: add function string_match_list
|
||||
* relay: add option relay.weechat.commands (issue #928)
|
||||
@ -34,6 +35,7 @@ Bug fixes::
|
||||
* irc: quote NICK command argument sent to the server (issue #1319)
|
||||
* php: fix memory leak in functions string_eval_expression, string_eval_path_home, key_bind, hook_process_hashtable, hook_hsignal_send, info_get_hashtable, hdata_update
|
||||
* spell: fix detection of nick followed by the nick completer (issue #1306, issue #1307)
|
||||
* trigger: fix split of hook arguments (issue #1322)
|
||||
|
||||
Build::
|
||||
|
||||
|
@ -1483,6 +1483,8 @@ This function is not available in scripting API.
|
||||
|
||||
==== string_split
|
||||
|
||||
_Updated in 2.5._
|
||||
|
||||
Split a string according to one or more delimiter(s).
|
||||
|
||||
Prototype:
|
||||
@ -1490,22 +1492,38 @@ Prototype:
|
||||
[source,C]
|
||||
----
|
||||
char **weechat_string_split (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max,
|
||||
int *num_items);
|
||||
int flags, int num_items_max, int *num_items);
|
||||
----
|
||||
|
||||
Arguments:
|
||||
|
||||
* _string_: string to split
|
||||
* _separators_: delimiters used for split
|
||||
* _keep_eol_:
|
||||
** 0: each string will contain one word
|
||||
** 1: each string will contain all string until end of line (see example below)
|
||||
** 2: same as 1, but do not remove separators at end of string before split
|
||||
_(WeeChat ≥ 0.3.6)_
|
||||
* _flags_: combination values to change the default behavior; if the value is 0,
|
||||
the default behavior is used (no strip of separators at beginning/end of string,
|
||||
multiple separators are kept as-is so empty strings can be returned);
|
||||
the following flags are accepted:
|
||||
** WEECHAT_STRING_SPLIT_STRIP_LEFT: strip separators on the left
|
||||
(beginning of string)
|
||||
** WEECHAT_STRING_SPLIT_STRIP_RIGHT: strip separators on the right
|
||||
(end of string)
|
||||
** WEECHAT_STRING_SPLIT_COLLAPSE_SEPS: collapse multiple consecutive separators
|
||||
into a single one
|
||||
** WEECHAT_STRING_SPLIT_KEEP_EOL: keep end of line for each value
|
||||
* _num_items_max_: maximum number of items created (0 = no limit)
|
||||
* _num_items_: pointer to int which will contain number of items created
|
||||
|
||||
[NOTE]
|
||||
With WeeChat ≤ 2.4, the _flags_ argument was called _keep_eol_ and took other
|
||||
values, which must be converted like that:
|
||||
[width="100%",cols="1,10",options="header"]
|
||||
|===
|
||||
| keep_eol | flags
|
||||
| 0 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_STRIP_RIGHT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| 1 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_STRIP_RIGHT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS \| WEECHAT_STRING_SPLIT_KEEP_EOL
|
||||
| 2 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS \| WEECHAT_STRING_SPLIT_KEEP_EOL
|
||||
|===
|
||||
|
||||
Return value:
|
||||
|
||||
* array of strings, NULL if problem (must be freed by calling
|
||||
@ -1517,7 +1535,23 @@ C example:
|
||||
----
|
||||
char **argv;
|
||||
int argc;
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 0, 0, &argc);
|
||||
/* result: argv[0] == "abc"
|
||||
argv[1] == "de"
|
||||
argv[2] == ""
|
||||
argv[3] == "fghi"
|
||||
argv[4] = ""
|
||||
argv[5] == NULL
|
||||
argc == 5
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc"
|
||||
argv[1] == "de"
|
||||
argv[2] == "fghi"
|
||||
@ -1526,7 +1560,12 @@ argv = weechat_string_split ("abc de fghi ", " ", 0, 0, &argc);
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 1, 0, &argc);
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc de fghi"
|
||||
argv[1] == "de fghi"
|
||||
argv[2] == "fghi"
|
||||
@ -1535,7 +1574,11 @@ argv = weechat_string_split ("abc de fghi ", " ", 1, 0, &argc);
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 2, 0, &argc);
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc de fghi "
|
||||
argv[1] == "de fghi "
|
||||
argv[2] == "fghi "
|
||||
|
@ -1509,6 +1509,8 @@ Cette fonction n'est pas disponible dans l'API script.
|
||||
|
||||
==== string_split
|
||||
|
||||
_Mis à jour dans la 2.5._
|
||||
|
||||
Découper une chaîne à l'aide de délimiteur(s).
|
||||
|
||||
Prototype :
|
||||
@ -1516,25 +1518,40 @@ Prototype :
|
||||
[source,C]
|
||||
----
|
||||
char **weechat_string_split (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max,
|
||||
int *num_items);
|
||||
int flags, int num_items_max, int *num_items);
|
||||
----
|
||||
|
||||
Paramètres :
|
||||
|
||||
* _string_ : chaîne à découper
|
||||
* _separators_ : délimiteurs utilisés pour le découpage
|
||||
* _keep_eol_ : si différent de 0, alors chaque paramètre contiendra toutes les
|
||||
chaînes jusqu'à la fin de la ligne (voir exemple ci-dessous)
|
||||
** 0 : chaque chaîne contiendra un mot
|
||||
** 1 : chaque chaîne contiendra toute la chaîne jusqu'à la fin de la ligne (voir
|
||||
exemple ci-dessous)
|
||||
** 2 : comme 1, mais ne supprime pas les séparateurs en fin de chaîne avant le
|
||||
découpage _(WeeChat ≥ 0.3.6)_
|
||||
* _flags_ : combinaison de valeurs pour changer le comportement par défaut ;
|
||||
si la valeur est 0, le comportement par défaut est utilisé (pas de suppression
|
||||
des séparateurs en début/fin de chaîne, plusieurs séparateurs consécutifs
|
||||
sont utilisés tels quels donc des chaînes vides peuvent être retournées) ;
|
||||
les "flags" suivants sont acceptés :
|
||||
** WEECHAT_STRING_SPLIT_STRIP_LEFT : supprimer les séparateurs sur la gauche
|
||||
(début de la chaîne)
|
||||
** WEECHAT_STRING_SPLIT_STRIP_RIGHT : supprimer les séparateurs sur la droite
|
||||
(fin de la chaîne)
|
||||
** WEECHAT_STRING_SPLIT_COLLAPSE_SEPS : regrouper plusieurs séparateurs
|
||||
consécutifs en un seul
|
||||
** WEECHAT_STRING_SPLIT_KEEP_EOL : garder la fin de la ligne pour chaque valeur
|
||||
* _num_items_max_ : nombre maximum de chaînes à créer (0 = pas de limite)
|
||||
* _num_items_ : pointeur vers un entier qui contiendra le nombre de chaînes
|
||||
créées
|
||||
|
||||
[NOTE]
|
||||
Avec WeeChat ≤ 2.4, le paramètre _flags_ s'appelait _keep_eol_ et prenait
|
||||
d'autres valeurs, qui doivent être converties comme ceci ;
|
||||
[width="100%",cols="1,10",options="header"]
|
||||
|===
|
||||
| keep_eol | flags
|
||||
| 0 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_STRIP_RIGHT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| 1 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_STRIP_RIGHT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS \| WEECHAT_STRING_SPLIT_KEEP_EOL
|
||||
| 2 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS \| WEECHAT_STRING_SPLIT_KEEP_EOL
|
||||
|===
|
||||
|
||||
Valeur de retour :
|
||||
|
||||
* tableau de chaînes, NULL en cas de problème (doit être supprimé par un appel à
|
||||
@ -1546,7 +1563,23 @@ Exemples en C :
|
||||
----
|
||||
char **argv;
|
||||
int argc;
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 0, 0, &argc);
|
||||
/* résultat : argv[0] == "abc"
|
||||
argv[1] == "de"
|
||||
argv[2] == ""
|
||||
argv[3] == "fghi"
|
||||
argv[4] == ""
|
||||
argv[5] == NULL
|
||||
argc == 5
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
/* résultat : argv[0] == "abc"
|
||||
argv[1] == "de"
|
||||
argv[2] == "fghi"
|
||||
@ -1555,7 +1588,12 @@ argv = weechat_string_split ("abc de fghi ", " ", 0, 0, &argc);
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 1, 0, &argc);
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, &argc);
|
||||
/* résultat : argv[0] == "abc de fghi"
|
||||
argv[1] == "de fghi"
|
||||
argv[2] == "fghi"
|
||||
@ -1564,7 +1602,11 @@ argv = weechat_string_split ("abc de fghi ", " ", 1, 0, &argc);
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 2, 0, &argc);
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, &argc);
|
||||
/* résultat : argv[0] == "abc de fghi "
|
||||
argv[1] == "de fghi "
|
||||
argv[2] == "fghi "
|
||||
|
@ -1554,6 +1554,9 @@ Questa funzione non è disponibile nelle API per lo scripting.
|
||||
|
||||
==== string_split
|
||||
|
||||
// TRANSLATION MISSING
|
||||
_Updated in 2.5._
|
||||
|
||||
Divide una stringa in base a uno o più delimitatori.
|
||||
|
||||
Prototipo:
|
||||
@ -1561,23 +1564,39 @@ Prototipo:
|
||||
[source,C]
|
||||
----
|
||||
char **weechat_string_split (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max,
|
||||
int *num_items);
|
||||
int flags, int num_items_max, int *num_items);
|
||||
----
|
||||
|
||||
Argomenti:
|
||||
|
||||
* _string_: stringa da dividere
|
||||
* _separators_: delimitatori usati per dividere
|
||||
* _keep_eol_:
|
||||
** 0: ogni stringa conterrà una parola
|
||||
** 1: ogni stringa conterrà tutte le stringhe fino a fine riga
|
||||
(consultare il seguente esempio)
|
||||
** 2: come il punto 1, ma non rimuove i delimitatori alla fine della stringa
|
||||
prima della divisione _(WeeChat ≥ 0.3.6)_
|
||||
* _flags_: combination values to change the default behavior; if the value is 0,
|
||||
the default behavior is used (no strip of separators at beginning/end of string,
|
||||
multiple separators are kept as-is so empty strings can be returned);
|
||||
the following flags are accepted:
|
||||
** WEECHAT_STRING_SPLIT_STRIP_LEFT: strip separators on the left
|
||||
(beginning of string)
|
||||
** WEECHAT_STRING_SPLIT_STRIP_RIGHT: strip separators on the right
|
||||
(end of string)
|
||||
** WEECHAT_STRING_SPLIT_COLLAPSE_SEPS: collapse multiple consecutive separators
|
||||
into a single one
|
||||
** WEECHAT_STRING_SPLIT_KEEP_EOL: keep end of line for each value
|
||||
* _num_items_max_: numero massimo di elementi creati (0 = nessun limite)
|
||||
* _num_items_: puntatore ad int che conterrà il numero di elementi creati
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[NOTE]
|
||||
With WeeChat ≤ 2.4, the _flags_ argument was called _keep_eol_ and took other
|
||||
values, which must be converted like that:
|
||||
[width="100%",cols="1,10",options="header"]
|
||||
|===
|
||||
| keep_eol | flags
|
||||
| 0 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_STRIP_RIGHT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| 1 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_STRIP_RIGHT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS \| WEECHAT_STRING_SPLIT_KEEP_EOL
|
||||
| 2 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS \| WEECHAT_STRING_SPLIT_KEEP_EOL
|
||||
|===
|
||||
|
||||
Valore restituito:
|
||||
|
||||
* array di stringhe, NULL se si verifica un problema (deve essere liberata chiamando
|
||||
@ -1589,7 +1608,23 @@ Esempi:
|
||||
----
|
||||
char **argv;
|
||||
int argc;
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 0, 0, &argc);
|
||||
/* result: argv[0] == "abc"
|
||||
argv[1] == "de"
|
||||
argv[2] = ""
|
||||
argv[3] == "fghi"
|
||||
argv[4] = ""
|
||||
argv[5] == NULL
|
||||
argc == 5
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc"
|
||||
argv[1] == "de"
|
||||
argv[2] == "fghi"
|
||||
@ -1598,7 +1633,12 @@ argv = weechat_string_split ("abc de fghi ", " ", 0, 0, &argc);
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 1, 0, &argc);
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc de fghi"
|
||||
argv[1] == "de fghi"
|
||||
argv[2] == "fghi"
|
||||
@ -1607,7 +1647,11 @@ argv = weechat_string_split ("abc de fghi ", " ", 1, 0, &argc);
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 2, 0, &argc);
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc de fghi "
|
||||
argv[1] == "de fghi "
|
||||
argv[2] == "fghi "
|
||||
|
@ -1490,6 +1490,8 @@ if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
|
||||
|
||||
==== string_split
|
||||
|
||||
_WeeChat バージョン 2.5 で更新。_
|
||||
|
||||
1 つ以上の区切り文字に従って文字列を分割。
|
||||
|
||||
プロトタイプ:
|
||||
@ -1497,22 +1499,44 @@ if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
|
||||
[source,C]
|
||||
----
|
||||
char **weechat_string_split (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max,
|
||||
int *num_items);
|
||||
int flags, int num_items_max, int *num_items);
|
||||
----
|
||||
|
||||
引数:
|
||||
|
||||
* _string_: 分割する文字列
|
||||
* _separators_: 分割に使う区切り文字
|
||||
* _keep_eol_:
|
||||
** 0: 区切り文字ごとの文字列に分割
|
||||
** 1: 文字列の最初から区切り文字までの文字列に分割 (下の例を参照)
|
||||
** 2: 1 と同じだが、文字列の最後から区切り文字を削除しない
|
||||
_(WeeChat バージョン 0.3.6 以上で利用可)_
|
||||
// TRANSLATION MISSING
|
||||
* _flags_: combination values to change the default behavior; if the value is 0,
|
||||
the default behavior is used (no strip of separators at beginning/end of string,
|
||||
multiple separators are kept as-is so empty strings can be returned);
|
||||
the following flags are accepted:
|
||||
// TRANSLATION MISSING
|
||||
** WEECHAT_STRING_SPLIT_STRIP_LEFT: strip separators on the left
|
||||
(beginning of string)
|
||||
// TRANSLATION MISSING
|
||||
** WEECHAT_STRING_SPLIT_STRIP_RIGHT: strip separators on the right
|
||||
(end of string)
|
||||
// TRANSLATION MISSING
|
||||
** WEECHAT_STRING_SPLIT_COLLAPSE_SEPS: collapse multiple consecutive separators
|
||||
into a single one
|
||||
// TRANSLATION MISSING
|
||||
** WEECHAT_STRING_SPLIT_KEEP_EOL: keep end of line for each value
|
||||
* _num_items_max_: 分割回数の上限 (0 = 制限なし)
|
||||
* _num_items_: 分割回数を返す整数型変数へのポインタ
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[NOTE]
|
||||
With WeeChat ≤ 2.4, the _flags_ argument was called _keep_eol_ and took other
|
||||
values, which must be converted like that:
|
||||
[width="100%",cols="1,10",options="header"]
|
||||
|===
|
||||
| keep_eol | flags
|
||||
| 0 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_STRIP_RIGHT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| 1 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_STRIP_RIGHT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS \| WEECHAT_STRING_SPLIT_KEEP_EOL
|
||||
| 2 | WEECHAT_STRING_SPLIT_STRIP_LEFT \| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS \| WEECHAT_STRING_SPLIT_KEEP_EOL
|
||||
|===
|
||||
|
||||
戻り値:
|
||||
|
||||
* 文字列の配列、分割に失敗した場合は NULL (使用後には必ず
|
||||
@ -1524,7 +1548,23 @@ C 言語での使用例:
|
||||
----
|
||||
char **argv;
|
||||
int argc;
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 0, 0, &argc);
|
||||
/* result: argv[0] == "abc"
|
||||
argv[1] == "de"
|
||||
argv[2] == ""
|
||||
argv[3] == "fghi"
|
||||
argv[4] == ""
|
||||
argv[5] == NULL
|
||||
argc == 5
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc"
|
||||
argv[1] == "de"
|
||||
argv[2] == "fghi"
|
||||
@ -1533,7 +1573,12 @@ argv = weechat_string_split ("abc de fghi ", " ", 0, 0, &argc);
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 1, 0, &argc);
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc de fghi"
|
||||
argv[1] == "de fghi"
|
||||
argv[2] == "fghi"
|
||||
@ -1542,7 +1587,11 @@ argv = weechat_string_split ("abc de fghi ", " ", 1, 0, &argc);
|
||||
*/
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
argv = weechat_string_split ("abc de fghi ", " ", 2, 0, &argc);
|
||||
argv = weechat_string_split ("abc de fghi ", " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, &argc);
|
||||
/* result: argv[0] == "abc de fghi "
|
||||
argv[1] == "de fghi "
|
||||
argv[2] == "fghi "
|
||||
|
@ -171,9 +171,14 @@ hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
hook_command->cplt_templates_static[i] = strdup (hook_command->cplt_templates[i]);
|
||||
|
||||
/* build arguments for each template */
|
||||
hook_command->cplt_template_args[i] = string_split (hook_command->cplt_templates[i],
|
||||
" ", 0, 0,
|
||||
&(hook_command->cplt_template_num_args[i]));
|
||||
hook_command->cplt_template_args[i] = string_split (
|
||||
hook_command->cplt_templates[i],
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&(hook_command->cplt_template_num_args[i]));
|
||||
if (hook_command->cplt_template_num_args[i] > hook_command->cplt_template_num_args_concat)
|
||||
hook_command->cplt_template_num_args_concat = hook_command->cplt_template_num_args[i];
|
||||
}
|
||||
@ -210,8 +215,14 @@ hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
{
|
||||
if (i < hook_command->cplt_template_num_args[j])
|
||||
{
|
||||
items = string_split (hook_command->cplt_template_args[j][i],
|
||||
"|", 0, 0, &num_items);
|
||||
items = string_split (
|
||||
hook_command->cplt_template_args[j][i],
|
||||
"|",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
for (k = 0; k < num_items; k++)
|
||||
{
|
||||
if (!weelist_search (list, items[k]))
|
||||
@ -338,13 +349,22 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
|
||||
if (hook_command_run_exec (buffer, string) == WEECHAT_RC_OK_EAT)
|
||||
return HOOK_COMMAND_EXEC_OK;
|
||||
|
||||
argv = string_split (string, " ", 0, 0, &argc);
|
||||
argv = string_split (string, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argc == 0)
|
||||
{
|
||||
string_free_split (argv);
|
||||
return HOOK_COMMAND_EXEC_NOT_FOUND;
|
||||
}
|
||||
argv_eol = string_split (string, " ", 1, 0, NULL);
|
||||
argv_eol = string_split (string, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, NULL);
|
||||
|
||||
ptr_command_name = utf8_next_char (argv[0]);
|
||||
length_command_name = strlen (ptr_command_name);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "../wee-infolist.h"
|
||||
#include "../wee-log.h"
|
||||
#include "../wee-string.h"
|
||||
#include "../../plugins/plugin.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -232,7 +233,11 @@ hook_focus_get_data (struct t_hashtable *hashtable_focus1,
|
||||
keys = hashtable_get_string (hashtable1, "keys");
|
||||
if (keys)
|
||||
{
|
||||
list_keys = string_split (keys, ",", 0, 0, &num_keys);
|
||||
list_keys = string_split (keys, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_keys);
|
||||
if (list_keys)
|
||||
{
|
||||
for (i = 0; i < num_keys; i++)
|
||||
|
@ -78,7 +78,12 @@ hook_line (struct t_weechat_plugin *plugin, const char *buffer_type,
|
||||
new_hook_line->buffer_type = gui_buffer_search_type (buffer_type);
|
||||
new_hook_line->buffers = string_split (
|
||||
(buffer_name && buffer_name[0]) ? buffer_name : "*",
|
||||
",", 0, 0, &new_hook_line->num_buffers);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&new_hook_line->num_buffers);
|
||||
new_hook_line->tags_array = string_split_tags (tags,
|
||||
&new_hook_line->tags_count);
|
||||
|
||||
|
@ -4554,8 +4554,11 @@ COMMAND_CALLBACK(plugin)
|
||||
{
|
||||
if (argc > 2)
|
||||
{
|
||||
plugin_argv = string_split (argv_eol[2], " ", 0, 0,
|
||||
&plugin_argc);
|
||||
plugin_argv = string_split (argv_eol[2], " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &plugin_argc);
|
||||
plugin_auto_load (NULL, 1, 1, 1, plugin_argc, plugin_argv);
|
||||
}
|
||||
else
|
||||
@ -4570,8 +4573,11 @@ COMMAND_CALLBACK(plugin)
|
||||
plugin_argc = 0;
|
||||
if (argc > 3)
|
||||
{
|
||||
plugin_argv = string_split (argv_eol[3], " ", 0, 0,
|
||||
&plugin_argc);
|
||||
plugin_argv = string_split (argv_eol[3], " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &plugin_argc);
|
||||
}
|
||||
full_name = util_search_full_lib_name (argv[2], "plugins");
|
||||
plugin_load (full_name, 1, plugin_argc, plugin_argv);
|
||||
@ -4588,8 +4594,12 @@ COMMAND_CALLBACK(plugin)
|
||||
{
|
||||
if (argc > 3)
|
||||
{
|
||||
plugin_argv = string_split (argv_eol[3], " ", 0, 0,
|
||||
&plugin_argc);
|
||||
plugin_argv = string_split (
|
||||
argv_eol[3], " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &plugin_argc);
|
||||
if (strcmp (argv[2], "*") == 0)
|
||||
{
|
||||
plugin_unload_all ();
|
||||
|
@ -964,7 +964,11 @@ completion_list_add_plugins_commands_cb (const void *pointer, void *data,
|
||||
if (!completion->args)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
argv = string_split (completion->args, " ", 0, 0, &argc);
|
||||
argv = string_split (completion->args, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@ -1649,7 +1653,11 @@ completion_list_add_env_value_cb (const void *pointer, void *data,
|
||||
|
||||
if (completion->args)
|
||||
{
|
||||
argv = string_split (completion->args, " ", 0, 0, &argc);
|
||||
argv = string_split (completion->args, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
@ -646,9 +646,14 @@ config_file_new_option (struct t_config_file *config_file,
|
||||
case CONFIG_OPTION_TYPE_INTEGER:
|
||||
if (string_values && string_values[0])
|
||||
{
|
||||
new_option->string_values = string_split (string_values,
|
||||
"|", 0, 0,
|
||||
&argc);
|
||||
new_option->string_values = string_split (
|
||||
string_values,
|
||||
"|",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&argc);
|
||||
if (!new_option->string_values)
|
||||
goto error;
|
||||
}
|
||||
|
@ -439,7 +439,11 @@ config_set_word_chars (const char *str_word_chars,
|
||||
if (!str_word_chars || !str_word_chars[0])
|
||||
return;
|
||||
|
||||
items = string_split (str_word_chars, ",", 0, 0, word_chars_count);
|
||||
items = string_split (str_word_chars, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, word_chars_count);
|
||||
if (!items)
|
||||
{
|
||||
*word_chars_count = 0;
|
||||
@ -688,8 +692,11 @@ config_set_nick_colors ()
|
||||
|
||||
config_nick_colors = string_split (
|
||||
CONFIG_STRING(config_color_chat_nick_colors),
|
||||
",", 0, 0,
|
||||
&config_num_nick_colors);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &config_num_nick_colors);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -721,8 +728,11 @@ config_change_look_nick_color_force (const void *pointer, void *data,
|
||||
hashtable_remove_all (config_hashtable_nick_color_force);
|
||||
}
|
||||
|
||||
items = string_split (CONFIG_STRING(config_look_nick_color_force),
|
||||
";", 0, 0, &num_items);
|
||||
items = string_split (CONFIG_STRING(config_look_nick_color_force), ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -1189,7 +1199,12 @@ config_change_completion_partial_completion_templates (const void *pointer,
|
||||
|
||||
items = string_split (
|
||||
CONFIG_STRING(config_completion_partial_completion_templates),
|
||||
",", 0, 0, &num_items);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -1266,8 +1281,14 @@ config_change_plugin_extension (const void *pointer, void *data,
|
||||
if (CONFIG_STRING(config_plugin_extension)
|
||||
&& CONFIG_STRING(config_plugin_extension)[0])
|
||||
{
|
||||
config_plugin_extensions = string_split (CONFIG_STRING(config_plugin_extension),
|
||||
",", 0, 0, &config_num_plugin_extensions);
|
||||
config_plugin_extensions = string_split (
|
||||
CONFIG_STRING(config_plugin_extension),
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&config_num_plugin_extensions);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1908,7 +1929,11 @@ config_weechat_layout_read_cb (const void *pointer, void *data,
|
||||
|
||||
if (string_strcasecmp (ptr_option_name, "buffer") == 0)
|
||||
{
|
||||
argv = string_split (value, ";", 0, 0, &argc);
|
||||
argv = string_split (value, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
if (argc >= 3)
|
||||
@ -1923,7 +1948,11 @@ config_weechat_layout_read_cb (const void *pointer, void *data,
|
||||
}
|
||||
else if (string_strcasecmp (ptr_option_name, "window") == 0)
|
||||
{
|
||||
argv = string_split (value, ";", 0, 0, &argc);
|
||||
argv = string_split (value, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
if (argc >= 6)
|
||||
@ -2233,8 +2262,17 @@ config_weechat_filter_read_cb (const void *pointer, void *data,
|
||||
|
||||
if (option_name && value && value[0])
|
||||
{
|
||||
argv = string_split (value, ";", 0, 0, &argc);
|
||||
argv_eol = string_split (value, ";", 1, 0, NULL);
|
||||
argv = string_split (value, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
argv_eol = string_split (value, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, NULL);
|
||||
if (argv && argv_eol && (argc >= 4))
|
||||
{
|
||||
gui_filter_new ((string_strcasecmp (argv[0], "on") == 0) ? 1 : 0,
|
||||
|
@ -455,7 +455,12 @@ secure_decrypt_data_not_decrypted (const char *passphrase)
|
||||
|
||||
keys = string_split (hashtable_get_string (secure_hashtable_data_encrypted,
|
||||
"keys"),
|
||||
",", 0, 0, &num_keys);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_keys);
|
||||
if (keys)
|
||||
{
|
||||
for (i = 0; i < num_keys; i++)
|
||||
|
@ -1794,18 +1794,17 @@ string_replace_regex (const char *string, void *regex, const char *replace,
|
||||
* This function must not be called directly (call string_split or
|
||||
* string_split_shared instead).
|
||||
*
|
||||
* According to keep_eol value:
|
||||
* -1: standard split, keep empty items: don't collapse several separators
|
||||
* and items at the beginning/end of string are returned if the string
|
||||
* starts and/or ends with a separator
|
||||
* 0: standard split, ignore empty items: collapse several separators
|
||||
* and strip separators at the beginning/end of string before processing
|
||||
* 1: same as 0 and each argument contains the argument and all the
|
||||
* following arguments
|
||||
* 2: same as 1 and separator is kept at the end of string.
|
||||
* The flags is a combination of flags:
|
||||
* - WEECHAT_STRING_SPLIT_STRIP_LEFT: strip separators on the left
|
||||
* (beginning of string)
|
||||
* - WEECHAT_STRING_SPLIT_STRIP_RIGHT: strip separators on the right
|
||||
* (end of string)
|
||||
* - WEECHAT_STRING_SPLIT_COLLAPSE_SEPS: collapse multiple consecutive
|
||||
* separators into a single one
|
||||
* - WEECHAT_STRING_SPLIT_KEEP_EOL: keep end of line for each value
|
||||
*
|
||||
* Examples:
|
||||
* string_split ("abc de fghi ", " ", -1, 0, &argc)
|
||||
* string_split ("abc de fghi ", " ", 0, 0, &argc)
|
||||
* ==> array[0] == "abc"
|
||||
* array[1] == "de"
|
||||
* array[2] == ""
|
||||
@ -1813,19 +1812,32 @@ string_replace_regex (const char *string, void *regex, const char *replace,
|
||||
* array[4] == ""
|
||||
* array[5] == NULL
|
||||
* argc == 5
|
||||
* string_split ("abc de fghi ", " ", 0, 0, &argc)
|
||||
* string_split ("abc de fghi ", " ",
|
||||
* WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
* | WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
* | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
* 0, &argc)
|
||||
* ==> array[0] == "abc"
|
||||
* array[1] == "de"
|
||||
* array[2] == "fghi"
|
||||
* array[3] == NULL
|
||||
* argc == 3
|
||||
* string_split ("abc de fghi ", " ", 1, 0, &argc)
|
||||
* string_split ("abc de fghi ", " ",
|
||||
* WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
* | WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
* | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
* | WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
* 0, &argc)
|
||||
* ==> array[0] == "abc de fghi"
|
||||
* array[1] == "de fghi"
|
||||
* array[2] == "fghi"
|
||||
* array[3] == NULL
|
||||
* argc == 3
|
||||
* string_split ("abc de fghi ", " ", 2, 0, &argc)
|
||||
* string_split ("abc de fghi ", " ",
|
||||
* WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
* | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
* | WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
* 0, &argc)
|
||||
* ==> array[0] == "abc de fghi "
|
||||
* array[1] == "de fghi "
|
||||
* array[2] == "fghi "
|
||||
@ -1834,7 +1846,7 @@ string_replace_regex (const char *string, void *regex, const char *replace,
|
||||
*/
|
||||
|
||||
char **
|
||||
string_split_internal (const char *string, const char *separators, int keep_eol,
|
||||
string_split_internal (const char *string, const char *separators, int flags,
|
||||
int num_items_max, int *num_items, int shared)
|
||||
{
|
||||
int i, j, count_items;
|
||||
@ -1848,10 +1860,11 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
|
||||
if (!string || !string[0] || !separators || !separators[0])
|
||||
return NULL;
|
||||
|
||||
string2 = string_strip (string,
|
||||
(keep_eol != -1) ? 1 : 0,
|
||||
((keep_eol == 0) || (keep_eol == 1)) ? 1 : 0,
|
||||
separators);
|
||||
string2 = string_strip (
|
||||
string,
|
||||
(flags & WEECHAT_STRING_SPLIT_STRIP_LEFT) ? 1 : 0,
|
||||
(flags & WEECHAT_STRING_SPLIT_STRIP_RIGHT) ? 1 : 0,
|
||||
separators);
|
||||
if (!string2)
|
||||
return NULL;
|
||||
if (!string2[0])
|
||||
@ -1865,12 +1878,7 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
|
||||
i = 1;
|
||||
while ((ptr = strpbrk (ptr, separators)))
|
||||
{
|
||||
if (keep_eol == -1)
|
||||
{
|
||||
ptr++;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
if (flags & WEECHAT_STRING_SPLIT_COLLAPSE_SEPS)
|
||||
{
|
||||
while (ptr[0] && strchr (separators, ptr[0]))
|
||||
{
|
||||
@ -1879,6 +1887,11 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
|
||||
if (ptr[0])
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
count_items = i;
|
||||
|
||||
@ -1900,7 +1913,7 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
|
||||
|
||||
for (i = 0; i < count_items; i++)
|
||||
{
|
||||
if (keep_eol != -1)
|
||||
if (flags & WEECHAT_STRING_SPLIT_COLLAPSE_SEPS)
|
||||
{
|
||||
/* skip separators to find the beginning of item */
|
||||
while (ptr1[0] && strchr (separators, ptr1[0]))
|
||||
@ -1937,7 +1950,7 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
|
||||
{
|
||||
if (ptr2 > ptr1)
|
||||
{
|
||||
if ((keep_eol == 1) || (keep_eol == 2))
|
||||
if (flags & WEECHAT_STRING_SPLIT_KEEP_EOL)
|
||||
{
|
||||
array[i] = (shared) ? (char *)string_shared_get (ptr1) : strdup (ptr1);
|
||||
if (!array[i])
|
||||
@ -1959,8 +1972,11 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
|
||||
array[i] = (char *)str_shared;
|
||||
}
|
||||
}
|
||||
if ((keep_eol == -1) && strchr (separators, ptr2[0]))
|
||||
if (!(flags & WEECHAT_STRING_SPLIT_COLLAPSE_SEPS)
|
||||
&& strchr (separators, ptr2[0]))
|
||||
{
|
||||
ptr2++;
|
||||
}
|
||||
ptr1 = ptr2;
|
||||
}
|
||||
else
|
||||
@ -2003,10 +2019,10 @@ error:
|
||||
*/
|
||||
|
||||
char **
|
||||
string_split (const char *string, const char *separators, int keep_eol,
|
||||
string_split (const char *string, const char *separators, int flags,
|
||||
int num_items_max, int *num_items)
|
||||
{
|
||||
return string_split_internal (string, separators, keep_eol,
|
||||
return string_split_internal (string, separators, flags,
|
||||
num_items_max, num_items, 0);
|
||||
}
|
||||
|
||||
@ -2018,10 +2034,10 @@ string_split (const char *string, const char *separators, int keep_eol,
|
||||
*/
|
||||
|
||||
char **
|
||||
string_split_shared (const char *string, const char *separators, int keep_eol,
|
||||
string_split_shared (const char *string, const char *separators, int flags,
|
||||
int num_items_max, int *num_items)
|
||||
{
|
||||
return string_split_internal (string, separators, keep_eol,
|
||||
return string_split_internal (string, separators, flags,
|
||||
num_items_max, num_items, 1);
|
||||
}
|
||||
|
||||
@ -2429,7 +2445,11 @@ string_split_tags (const char *tags, int *num_tags)
|
||||
|
||||
if (tags)
|
||||
{
|
||||
tags_array_temp = string_split (tags, ",", 0, 0, &tags_count);
|
||||
tags_array_temp = string_split (tags, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &tags_count);
|
||||
if (tags_array_temp && (tags_count > 0))
|
||||
{
|
||||
tags_array = malloc ((tags_count + 1) * sizeof (*tags_array));
|
||||
|
@ -87,9 +87,9 @@ extern char *string_replace_regex (const char *string, void *regex,
|
||||
char *(*callback)(void *data, const char *text),
|
||||
void *callback_data);
|
||||
extern char **string_split (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max, int *num_items);
|
||||
int flags, int num_items_max, int *num_items);
|
||||
extern char **string_split_shared (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max,
|
||||
int flags, int num_items_max,
|
||||
int *num_items);
|
||||
extern char **string_split_shell (const char *string, int *num_items);
|
||||
extern void string_free_split (char **split_string);
|
||||
|
@ -291,7 +291,11 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
|
||||
fields = infolist_fields (infolist);
|
||||
if (fields)
|
||||
{
|
||||
argv = string_split (fields, ",", 0, 0, &argc);
|
||||
argv = string_split (fields, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv && (argc > 0))
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "wee-infolist.h"
|
||||
#include "wee-proxy.h"
|
||||
#include "wee-string.h"
|
||||
#include "../plugins/plugin.h"
|
||||
|
||||
|
||||
#define URL_DEF_CONST(__prefix, __name) \
|
||||
@ -866,7 +867,11 @@ weeurl_get_mask_value (struct t_url_constant *constants,
|
||||
|
||||
mask = 0;
|
||||
|
||||
items = string_split (string_mask, "+", 0, 0, &num_items);
|
||||
items = string_split (string_mask, "+",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -1014,7 +1019,11 @@ weeurl_option_map_cb (void *data,
|
||||
}
|
||||
break;
|
||||
case URL_TYPE_LIST:
|
||||
items = string_split (value, "\n", 0, 0, &num_items);
|
||||
items = string_split (value, "\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
slist = NULL;
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "wee-utf8.h"
|
||||
#include "../gui/gui-chat.h"
|
||||
#include "../gui/gui-window.h"
|
||||
#include "../plugins/plugin.h"
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
@ -205,8 +206,11 @@ util_setrlimit ()
|
||||
int num_items, i;
|
||||
long number;
|
||||
|
||||
items = string_split (CONFIG_STRING(config_startup_sys_rlimit), ",", 0, 0,
|
||||
&num_items);
|
||||
items = string_split (CONFIG_STRING(config_startup_sys_rlimit), ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -858,7 +862,11 @@ util_version_number (const char *version)
|
||||
int num_items, i, version_int[4], index_buf;
|
||||
long number;
|
||||
|
||||
items = string_split (version, ".", 0, 4, &num_items);
|
||||
items = string_split (version, ".",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
4, &num_items);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
version_int[i] = 0;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "../../core/wee-log.h"
|
||||
#include "../../core/wee-string.h"
|
||||
#include "../../core/wee-utf8.h"
|
||||
#include "../../plugins/plugin.h"
|
||||
#include "../gui-bar.h"
|
||||
#include "../gui-bar-item.h"
|
||||
#include "../gui-bar-window.h"
|
||||
@ -486,7 +487,11 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
}
|
||||
}
|
||||
|
||||
items = string_split (content, "\n", 0, 0, &items_count);
|
||||
items = string_split (content, "\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &items_count);
|
||||
if (items_count == 0)
|
||||
{
|
||||
if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
|
||||
|
@ -935,7 +935,12 @@ gui_color_buffer_display ()
|
||||
gui_chat_printf_y (gui_color_buffer, y++,
|
||||
_("Nick colors:"));
|
||||
items = string_split (CONFIG_STRING(config_color_chat_nick_colors),
|
||||
",", 0, 0, &num_items);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
str_line[0] = '\0';
|
||||
@ -1340,7 +1345,11 @@ gui_color_palette_new (int number, const char *value)
|
||||
str_alias = NULL;
|
||||
str_rgb = NULL;
|
||||
|
||||
items = string_split (value, ";", 0, 0, &num_items);
|
||||
items = string_split (value, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
|
@ -840,8 +840,14 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
i, sub);
|
||||
if (ptr_content && ptr_content[0])
|
||||
{
|
||||
split_items[i][sub] = string_split (ptr_content,
|
||||
"\n", 0, 0, NULL);
|
||||
split_items[i][sub] = string_split (
|
||||
ptr_content,
|
||||
"\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
NULL);
|
||||
for (j = 0; split_items[i][sub][j]; j++)
|
||||
{
|
||||
total_items++;
|
||||
|
@ -704,7 +704,11 @@ gui_bar_set_items_array (struct t_gui_bar *bar, const char *items)
|
||||
|
||||
if (items && items[0])
|
||||
{
|
||||
tmp_array = string_split (items, ",", 0, 0, &count);
|
||||
tmp_array = string_split (items, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &count);
|
||||
if (count > 0)
|
||||
{
|
||||
bar->items_count = count;
|
||||
@ -716,8 +720,14 @@ gui_bar_set_items_array (struct t_gui_bar *bar, const char *items)
|
||||
bar->items_suffix = malloc (count * sizeof (*bar->items_suffix));
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
bar->items_array[i] = string_split (tmp_array[i], "+", 0, 0,
|
||||
&(bar->items_subcount[i]));
|
||||
bar->items_array[i] = string_split (
|
||||
tmp_array[i],
|
||||
"+",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&(bar->items_subcount[i]));
|
||||
if (bar->items_subcount[i] > 0)
|
||||
{
|
||||
bar->items_buffer[i] = malloc (bar->items_subcount[i] *
|
||||
|
@ -1019,7 +1019,11 @@ gui_buffer_match_list (struct t_gui_buffer *buffer, const char *string)
|
||||
|
||||
match = 0;
|
||||
|
||||
buffers = string_split (string, ",", 0, 0, NULL);
|
||||
buffers = string_split (string, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, NULL);
|
||||
if (buffers)
|
||||
{
|
||||
match = string_match_list (buffer->full_name,
|
||||
@ -1488,10 +1492,16 @@ gui_buffer_add_highlight_words (struct t_gui_buffer *buffer,
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
current_words = string_split (buffer->highlight_words, ",", 0, 0,
|
||||
¤t_count);
|
||||
add_words = string_split (words_to_add, ",", 0, 0,
|
||||
&add_count);
|
||||
current_words = string_split (buffer->highlight_words, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, ¤t_count);
|
||||
add_words = string_split (words_to_add, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &add_count);
|
||||
|
||||
for (i = 0; i < current_count; i++)
|
||||
{
|
||||
@ -1533,10 +1543,16 @@ gui_buffer_remove_highlight_words (struct t_gui_buffer *buffer,
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
current_words = string_split (buffer->highlight_words, ",", 0, 0,
|
||||
¤t_count);
|
||||
remove_words = string_split (words_to_remove, ",", 0, 0,
|
||||
&remove_count);
|
||||
current_words = string_split (buffer->highlight_words, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, ¤t_count);
|
||||
remove_words = string_split (words_to_remove, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &remove_count);
|
||||
|
||||
for (i = 0; i < current_count; i++)
|
||||
{
|
||||
@ -1697,8 +1713,11 @@ gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
|
||||
|
||||
if (new_hotlist_max_level_nicks && new_hotlist_max_level_nicks[0])
|
||||
{
|
||||
nicks = string_split (new_hotlist_max_level_nicks, ",", 0, 0,
|
||||
&nicks_count);
|
||||
nicks = string_split (new_hotlist_max_level_nicks, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &nicks_count);
|
||||
if (nicks)
|
||||
{
|
||||
for (i = 0; i < nicks_count; i++)
|
||||
@ -1737,7 +1756,11 @@ gui_buffer_add_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
|
||||
if (!buffer || !nicks_to_add)
|
||||
return;
|
||||
|
||||
nicks = string_split (nicks_to_add, ",", 0, 0, &nicks_count);
|
||||
nicks = string_split (nicks_to_add, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &nicks_count);
|
||||
if (nicks)
|
||||
{
|
||||
for (i = 0; i < nicks_count; i++)
|
||||
@ -1774,7 +1797,11 @@ gui_buffer_remove_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
|
||||
if (!buffer || !nicks_to_remove)
|
||||
return;
|
||||
|
||||
nicks = string_split (nicks_to_remove, ",", 0, 0, &nicks_count);
|
||||
nicks = string_split (nicks_to_remove, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &nicks_count);
|
||||
if (nicks)
|
||||
{
|
||||
for (i = 0; i < nicks_count; i++)
|
||||
|
@ -910,8 +910,11 @@ gui_chat_print_lines_waiting_buffer (FILE *f)
|
||||
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
lines = string_split (*gui_chat_lines_waiting_buffer, "\n", 0, 0,
|
||||
&num_lines);
|
||||
lines = string_split (*gui_chat_lines_waiting_buffer, "\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_lines);
|
||||
if (lines)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
|
@ -787,7 +787,11 @@ gui_color_decode_ansi_cb (void *data, const char *text)
|
||||
if (!text2)
|
||||
goto end;
|
||||
|
||||
items = string_split (text2, ";", 0, 0, &num_items);
|
||||
items = string_split (text2, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (!items)
|
||||
goto end;
|
||||
|
||||
|
@ -561,7 +561,12 @@ gui_completion_get_matching_template (struct t_gui_completion *completion,
|
||||
for (i = 0; i < HOOK_COMMAND(hook_command, cplt_num_templates); i++)
|
||||
{
|
||||
items = string_split (HOOK_COMMAND(hook_command, cplt_templates_static)[i],
|
||||
"|", 0, 0, &num_items);
|
||||
"|",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (j = 0; j < num_items; j++)
|
||||
|
@ -395,9 +395,14 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
|
||||
new_filter->enabled = enabled;
|
||||
new_filter->name = strdup (name);
|
||||
new_filter->buffer_name = strdup ((buffer_name) ? buffer_name : "*");
|
||||
new_filter->buffers = string_split (new_filter->buffer_name,
|
||||
",", 0, 0,
|
||||
&new_filter->num_buffers);
|
||||
new_filter->buffers = string_split (
|
||||
new_filter->buffer_name,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&new_filter->num_buffers);
|
||||
new_filter->tags = (tags) ? strdup (tags) : NULL;
|
||||
new_filter->tags_array = string_split_tags (new_filter->tags,
|
||||
&new_filter->tags_count);
|
||||
|
@ -79,7 +79,11 @@ alias_completion_alias_value_cb (const void *pointer, void *data,
|
||||
args = weechat_hook_completion_get_string (completion, "args");
|
||||
if (args)
|
||||
{
|
||||
argv = weechat_string_split (args, " ", 0, 0, &argc);
|
||||
argv = weechat_string_split (args, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
if (argc > 0)
|
||||
|
@ -190,7 +190,11 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
const char *start, *pos;
|
||||
int n, m, argc, length_res, args_count, offset;
|
||||
|
||||
argv = weechat_string_split (user_args, " ", 0, 0, &argc);
|
||||
argv = weechat_string_split (user_args, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
|
||||
res = NULL;
|
||||
length_res = 0;
|
||||
|
@ -165,7 +165,11 @@ buflist_config_hook_signals_refresh ()
|
||||
BUFLIST_CONFIG_SIGNALS_REFRESH_NICK_PREFIX);
|
||||
}
|
||||
|
||||
signals = weechat_string_split (*all_signals, ",", 0, 0, &count);
|
||||
signals = weechat_string_split (*all_signals, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &count);
|
||||
if (signals)
|
||||
{
|
||||
signals_list = weechat_arraylist_new (
|
||||
@ -252,7 +256,12 @@ buflist_config_change_sort (const void *pointer, void *data,
|
||||
|
||||
buflist_config_sort_fields = weechat_string_split (
|
||||
weechat_config_string (buflist_config_look_sort),
|
||||
",", 0, 0, &buflist_config_sort_fields_count);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&buflist_config_sort_fields_count);
|
||||
|
||||
buflist_bar_item_update (0);
|
||||
}
|
||||
|
@ -87,7 +87,11 @@ buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
|
||||
end:
|
||||
/* get list of keys */
|
||||
keys = weechat_hdata_get_string (buflist_hdata_buffer, "var_keys");
|
||||
list_keys = weechat_string_split (keys, ",", 0, 0, &num_keys);
|
||||
list_keys = weechat_string_split (keys, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_keys);
|
||||
if (!list_keys)
|
||||
return info;
|
||||
|
||||
|
@ -53,8 +53,17 @@ exec_buffer_input_cb (const void *pointer, void *data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
argv = weechat_string_split (input_data, " ", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (input_data, " ", 1, 0, NULL);
|
||||
argv = weechat_string_split (input_data, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
argv_eol = weechat_string_split (input_data, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, NULL);
|
||||
|
||||
if (argv && argv_eol)
|
||||
exec_command_run (buffer, argc, argv, argv_eol, 0);
|
||||
|
@ -63,7 +63,12 @@ exec_config_change_command_default_options (const void *pointer, void *data,
|
||||
|
||||
exec_config_cmd_options = weechat_string_split (
|
||||
weechat_config_string (exec_config_command_default_options),
|
||||
" ", 0, 0, &exec_config_cmd_num_options);
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&exec_config_cmd_num_options);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -782,7 +782,11 @@ fset_buffer_display_option_eval (struct t_fset_option *fset_option)
|
||||
NULL);
|
||||
if (line)
|
||||
{
|
||||
lines = weechat_string_split (line, "\r\n", 0, 0, &num_lines);
|
||||
lines = weechat_string_split (line, "\r\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_lines);
|
||||
if (lines)
|
||||
{
|
||||
y = fset_option->index * fset_config_format_option_num_lines[format_number - 1];
|
||||
|
@ -469,7 +469,11 @@ fset_command_run_set_cb (const void *pointer, void *data,
|
||||
|
||||
rc = WEECHAT_RC_OK;
|
||||
|
||||
argv = weechat_string_split (command, " ", 0, 0, &argc);
|
||||
argv = weechat_string_split (command, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
|
||||
if (argc > 2)
|
||||
goto end;
|
||||
|
@ -81,7 +81,12 @@ fset_completion_option_cb (const void *pointer, void *data,
|
||||
WEECHAT_LIST_POS_SORT);
|
||||
words = weechat_string_split (
|
||||
weechat_config_option_get_string (ptr_option, "name"),
|
||||
"_", 0, 0, &num_words);
|
||||
"_",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_words);
|
||||
if (words && (num_words > 1))
|
||||
{
|
||||
for (i = 0; i < num_words; i++)
|
||||
|
@ -153,7 +153,12 @@ fset_config_change_sort_cb (const void *pointer, void *data,
|
||||
|
||||
fset_config_sort_fields = weechat_string_split (
|
||||
weechat_config_string (fset_config_look_sort),
|
||||
",", 0, 0, &fset_config_sort_fields_count);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&fset_config_sort_fields_count);
|
||||
|
||||
if (fset_buffer)
|
||||
{
|
||||
|
@ -497,7 +497,11 @@ irc_color_decode_ansi_cb (void *data, const char *text)
|
||||
if (!text2)
|
||||
goto end;
|
||||
|
||||
items = weechat_string_split (text2, ";", 0, 0, &num_items);
|
||||
items = weechat_string_split (text2, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (!items)
|
||||
goto end;
|
||||
|
||||
|
@ -419,7 +419,11 @@ irc_command_exec_all_channels (struct t_irc_server *server,
|
||||
return;
|
||||
|
||||
channels = (str_channels && str_channels[0]) ?
|
||||
weechat_string_split (str_channels, ",", 0, 0, &num_channels) : NULL;
|
||||
weechat_string_split (str_channels, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_channels) : NULL;
|
||||
|
||||
/* build a list of buffer names where the command will be executed */
|
||||
list_buffers = weechat_list_new ();
|
||||
@ -654,7 +658,11 @@ irc_command_exec_all_servers (int inclusive, const char *str_servers, const char
|
||||
return;
|
||||
|
||||
servers = (str_servers && str_servers[0]) ?
|
||||
weechat_string_split (str_servers, ",", 0, 0, &num_servers) : NULL;
|
||||
weechat_string_split (str_servers, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_servers) : NULL;
|
||||
|
||||
/* build a list of buffer names where the command will be executed */
|
||||
list_buffers = weechat_list_new ();
|
||||
@ -1080,8 +1088,17 @@ irc_command_run_away (const void *pointer, void *data,
|
||||
int argc;
|
||||
char **argv, **argv_eol;
|
||||
|
||||
argv = weechat_string_split (command, " ", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (command, " ", 1, 0, NULL);
|
||||
argv = weechat_string_split (command, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
argv_eol = weechat_string_split (command, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, NULL);
|
||||
|
||||
if (argv && argv_eol)
|
||||
{
|
||||
@ -1549,7 +1566,11 @@ IRC_COMMAND_CALLBACK(ctcp)
|
||||
|
||||
IRC_COMMAND_CHECK_SERVER("ctcp", 1);
|
||||
|
||||
targets = weechat_string_split (argv[arg_target], ",", 0, 0, &num_targets);
|
||||
targets = weechat_string_split (argv[arg_target], ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_targets);
|
||||
if (!targets)
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
@ -1655,8 +1676,11 @@ IRC_COMMAND_CALLBACK(cycle)
|
||||
{
|
||||
channel_name = argv[1];
|
||||
pos_args = argv_eol[2];
|
||||
channels = weechat_string_split (channel_name, ",", 0, 0,
|
||||
&num_channels);
|
||||
channels = weechat_string_split (channel_name, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_channels);
|
||||
if (channels)
|
||||
{
|
||||
for (i = 0; i < num_channels; i++)
|
||||
@ -2504,15 +2528,22 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments,
|
||||
pos_keys++;
|
||||
}
|
||||
if (pos_keys[0])
|
||||
keys = weechat_string_split (pos_keys, ",", 0, 0, &num_keys);
|
||||
keys = weechat_string_split (pos_keys, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_keys);
|
||||
}
|
||||
else
|
||||
new_args = strdup (arguments);
|
||||
|
||||
if (new_args)
|
||||
{
|
||||
channels = weechat_string_split (new_args, ",", 0, 0,
|
||||
&num_channels);
|
||||
channels = weechat_string_split (new_args, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_channels);
|
||||
free (new_args);
|
||||
}
|
||||
|
||||
@ -3260,8 +3291,11 @@ IRC_COMMAND_CALLBACK(msg)
|
||||
|
||||
IRC_COMMAND_CHECK_SERVER("msg", 1);
|
||||
|
||||
targets = weechat_string_split (argv[arg_target], ",", 0, 0,
|
||||
&num_targets);
|
||||
targets = weechat_string_split (argv[arg_target], ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_targets);
|
||||
if (!targets)
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
@ -4056,7 +4090,11 @@ IRC_COMMAND_CALLBACK(query)
|
||||
|
||||
IRC_COMMAND_CHECK_SERVER("query", 1);
|
||||
|
||||
nicks = weechat_string_split (argv[arg_nick], ",", 0, 0, &num_nicks);
|
||||
nicks = weechat_string_split (argv[arg_nick], ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_nicks);
|
||||
if (!nicks)
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
|
||||
|
@ -359,7 +359,12 @@ irc_config_change_look_display_join_message (const void *pointer, void *data,
|
||||
|
||||
items = weechat_string_split (
|
||||
weechat_config_string (irc_config_look_display_join_message),
|
||||
",", 0, 0, &num_items);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -582,7 +587,12 @@ irc_config_change_look_nicks_hide_password (const void *pointer, void *data,
|
||||
if (nicks_hide_password && nicks_hide_password[0])
|
||||
{
|
||||
irc_config_nicks_hide_password = weechat_string_split (
|
||||
nicks_hide_password, ",", 0, 0,
|
||||
nicks_hide_password,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&irc_config_num_nicks_hide_password);
|
||||
}
|
||||
}
|
||||
@ -710,7 +720,12 @@ irc_config_change_color_mirc_remap (const void *pointer, void *data,
|
||||
|
||||
items = weechat_string_split (
|
||||
weechat_config_string (irc_config_color_mirc_remap),
|
||||
";", 0, 0, &num_items);
|
||||
";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -757,7 +772,12 @@ irc_config_change_color_nick_prefixes (const void *pointer, void *data,
|
||||
|
||||
items = weechat_string_split (
|
||||
weechat_config_string (irc_config_color_nick_prefixes),
|
||||
";", 0, 0, &num_items);
|
||||
";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -1023,14 +1043,26 @@ irc_config_check_autojoin (const char *autojoin)
|
||||
if (strstr (string, ", ") || strstr (string, " ,"))
|
||||
goto end;
|
||||
|
||||
items = weechat_string_split (string, " ", 0, 0, &num_items);
|
||||
items = weechat_string_split (string, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (!items || (num_items < 1) || (num_items > 2))
|
||||
goto end;
|
||||
|
||||
channels = weechat_string_split (items[0], ",", 0, 0, &num_channels);
|
||||
channels = weechat_string_split (items[0], ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_channels);
|
||||
|
||||
if (num_items == 2)
|
||||
keys = weechat_string_split (items[1], ",", 0, 0, &num_keys);
|
||||
keys = weechat_string_split (items[1], ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_keys);
|
||||
|
||||
/* error if there are more keys than channels to join */
|
||||
if (num_keys > num_channels)
|
||||
@ -1477,8 +1509,23 @@ irc_config_ignore_read_cb (const void *pointer, void *data,
|
||||
{
|
||||
if (value && value[0])
|
||||
{
|
||||
argv = weechat_string_split (value, ";", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (value, ";", 1, 0, NULL);
|
||||
argv = weechat_string_split (
|
||||
value,
|
||||
";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&argc);
|
||||
argv_eol = weechat_string_split (
|
||||
value,
|
||||
";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0,
|
||||
NULL);
|
||||
if (argv && argv_eol && (argc >= 3))
|
||||
{
|
||||
irc_ignore_new (argv_eol[2], argv[0], argv[1]);
|
||||
|
@ -512,7 +512,11 @@ irc_info_infolist_irc_channel_cb (const void *pointer, void *data,
|
||||
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
argv = weechat_string_split (arguments, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (arguments, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return NULL;
|
||||
|
||||
@ -600,7 +604,11 @@ irc_info_infolist_irc_modelist_cb (const void *pointer, void *data,
|
||||
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
argv = weechat_string_split (arguments, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (arguments, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return NULL;
|
||||
|
||||
@ -697,7 +705,11 @@ irc_info_infolist_irc_modelist_item_cb (const void *pointer, void *data,
|
||||
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
argv = weechat_string_split (arguments, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (arguments, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return NULL;
|
||||
|
||||
@ -805,7 +817,11 @@ irc_info_infolist_irc_nick_cb (const void *pointer, void *data,
|
||||
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
argv = weechat_string_split (arguments, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (arguments, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return NULL;
|
||||
|
||||
|
@ -361,7 +361,14 @@ irc_input_send_cb (const void *pointer, void *data,
|
||||
|
||||
if (options && options[0])
|
||||
{
|
||||
list_options = weechat_string_split (options, ",", 0, 0, &num_options);
|
||||
list_options = weechat_string_split (
|
||||
options,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_options);
|
||||
if (list_options)
|
||||
{
|
||||
for (i = 0; i < num_options; i++)
|
||||
|
@ -779,18 +779,30 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
str = weechat_strndup (arguments, pos - arguments);
|
||||
if (!str)
|
||||
return 0;
|
||||
channels = weechat_string_split (str, ",", 0, 0, &channels_count);
|
||||
channels = weechat_string_split (str, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &channels_count);
|
||||
free (str);
|
||||
while (pos[0] == ' ')
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
if (pos[0])
|
||||
keys = weechat_string_split (pos, ",", 0, 0, &keys_count);
|
||||
keys = weechat_string_split (pos, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &keys_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
channels = weechat_string_split (arguments, ",", 0, 0, &channels_count);
|
||||
channels = weechat_string_split (arguments, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &channels_count);
|
||||
}
|
||||
|
||||
snprintf (msg_to_send, sizeof (msg_to_send), "%s%sJOIN",
|
||||
@ -1042,8 +1054,16 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
}
|
||||
}
|
||||
|
||||
argv = weechat_string_split (message, " ", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (message, " ", 2, 0, NULL);
|
||||
argv = weechat_string_split (message, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
argv_eol = weechat_string_split (message, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, NULL);
|
||||
|
||||
if (argc < 2)
|
||||
goto end;
|
||||
|
@ -130,7 +130,11 @@ irc_mode_channel_update (struct t_irc_server *server,
|
||||
pos_args++;
|
||||
while (pos_args[0] == ' ')
|
||||
pos_args++;
|
||||
argv = weechat_string_split (pos_args, " ", 0, 0, &argc);
|
||||
argv = weechat_string_split (pos_args, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -338,7 +342,11 @@ irc_mode_channel_set (struct t_irc_server *server,
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
if (modes_arguments)
|
||||
argv = weechat_string_split (modes_arguments, " ", 0, 0, &argc);
|
||||
argv = weechat_string_split (modes_arguments, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
|
||||
current_arg = 0;
|
||||
|
||||
|
@ -373,7 +373,11 @@ irc_notify_new_for_server (struct t_irc_server *server)
|
||||
if (!notify || !notify[0])
|
||||
return;
|
||||
|
||||
items = weechat_string_split (notify, ",", 0, 0, &num_items);
|
||||
items = weechat_string_split (notify, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -388,8 +392,14 @@ irc_notify_new_for_server (struct t_irc_server *server)
|
||||
{
|
||||
pos_params++;
|
||||
}
|
||||
params = weechat_string_split (pos_params, "/", 0, 0,
|
||||
&num_params);
|
||||
params = weechat_string_split (
|
||||
pos_params,
|
||||
"/",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_params);
|
||||
if (params)
|
||||
{
|
||||
for (j = 0; j < num_params; j++)
|
||||
@ -827,11 +837,24 @@ irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
if (strcmp (pattern, "ison") == 0)
|
||||
{
|
||||
/* redirection of command "ison" */
|
||||
messages = weechat_string_split (output, "\n", 0, 0, &num_messages);
|
||||
messages = weechat_string_split (
|
||||
output,
|
||||
"\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_messages);
|
||||
if (messages)
|
||||
{
|
||||
nicks_sent = weechat_string_split (ptr_args, " ", 0, 0,
|
||||
&num_nicks_sent);
|
||||
nicks_sent = weechat_string_split (
|
||||
ptr_args,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_nicks_sent);
|
||||
if (!nicks_sent)
|
||||
return WEECHAT_RC_OK;
|
||||
for (ptr_notify = ptr_server->notify_list;
|
||||
@ -857,8 +880,14 @@ irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
}
|
||||
if (pos[0])
|
||||
{
|
||||
nicks_recv = weechat_string_split (pos, " ", 0, 0,
|
||||
&num_nicks_recv);
|
||||
nicks_recv = weechat_string_split (
|
||||
pos,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_nicks_recv);
|
||||
if (nicks_recv)
|
||||
{
|
||||
for (j = 0; j < num_nicks_recv; j++)
|
||||
@ -920,7 +949,14 @@ irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
{
|
||||
away_message_updated = 0;
|
||||
no_such_nick = 0;
|
||||
messages = weechat_string_split (output, "\n", 0, 0, &num_messages);
|
||||
messages = weechat_string_split (
|
||||
output,
|
||||
"\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_messages);
|
||||
if (messages)
|
||||
{
|
||||
for (i = 0; i < num_messages; i++)
|
||||
|
@ -395,8 +395,14 @@ irc_protocol_cap_sync (struct t_irc_server *server, int sasl)
|
||||
strcat (cap_option, "sasl");
|
||||
}
|
||||
cap_req[0] = '\0';
|
||||
caps_requested = weechat_string_split (cap_option, ",", 0, 0,
|
||||
&num_caps_requested);
|
||||
caps_requested = weechat_string_split (
|
||||
cap_option,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_caps_requested);
|
||||
if (caps_requested)
|
||||
{
|
||||
for (i = 0; i < num_caps_requested; i++)
|
||||
@ -506,8 +512,14 @@ IRC_PROTOCOL_CALLBACK(cap)
|
||||
if (ptr_caps[0] == ':')
|
||||
ptr_caps++;
|
||||
|
||||
caps_supported = weechat_string_split (ptr_caps, " ", 0, 0,
|
||||
&num_caps_supported);
|
||||
caps_supported = weechat_string_split (
|
||||
ptr_caps,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_caps_supported);
|
||||
if (caps_supported)
|
||||
{
|
||||
for (i = 0; i < num_caps_supported; i++)
|
||||
@ -582,8 +594,14 @@ IRC_PROTOCOL_CALLBACK(cap)
|
||||
if (ptr_caps[0] == ':')
|
||||
ptr_caps++;
|
||||
|
||||
caps_enabled = weechat_string_split (ptr_caps, " ", 0, 0,
|
||||
&num_caps_enabled);
|
||||
caps_enabled = weechat_string_split (
|
||||
ptr_caps,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_caps_enabled);
|
||||
if (caps_enabled)
|
||||
{
|
||||
for (i = 0; i < num_caps_enabled; i++)
|
||||
@ -637,8 +655,14 @@ IRC_PROTOCOL_CALLBACK(cap)
|
||||
_("%s%s: client capability, enabled: %s"),
|
||||
weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps);
|
||||
sasl_to_do = 0;
|
||||
caps_supported = weechat_string_split (ptr_caps, " ", 0, 0,
|
||||
&num_caps_supported);
|
||||
caps_supported = weechat_string_split (
|
||||
ptr_caps,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_caps_supported);
|
||||
if (caps_supported)
|
||||
{
|
||||
for (i = 0; i < num_caps_supported; i++)
|
||||
@ -701,8 +725,14 @@ IRC_PROTOCOL_CALLBACK(cap)
|
||||
server->buffer, date, NULL,
|
||||
_("%s%s: client capability, now available: %s"),
|
||||
weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps);
|
||||
caps_added = weechat_string_split (ptr_caps, " ", 0, 0,
|
||||
&num_caps_added);
|
||||
caps_added = weechat_string_split (
|
||||
ptr_caps,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_caps_added);
|
||||
if (caps_added)
|
||||
{
|
||||
for (i = 0; i < num_caps_added; i++)
|
||||
@ -741,8 +771,14 @@ IRC_PROTOCOL_CALLBACK(cap)
|
||||
server->buffer, date, NULL,
|
||||
_("%s%s: client capability, removed: %s"),
|
||||
weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps);
|
||||
caps_removed = weechat_string_split (ptr_caps, " ", 0, 0,
|
||||
&num_caps_removed);
|
||||
caps_removed = weechat_string_split (
|
||||
ptr_caps,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_caps_removed);
|
||||
if (caps_removed)
|
||||
{
|
||||
for (i = 0; i < num_caps_removed; i++)
|
||||
@ -5786,7 +5822,12 @@ IRC_PROTOCOL_CALLBACK(730)
|
||||
|
||||
nicks = weechat_string_split ((argv_eol[3][0] == ':') ?
|
||||
argv_eol[3] + 1 : argv_eol[3],
|
||||
",", 0, 0, &num_nicks);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_nicks);
|
||||
if (nicks)
|
||||
{
|
||||
for (i = 0; i < num_nicks; i++)
|
||||
@ -5824,7 +5865,12 @@ IRC_PROTOCOL_CALLBACK(731)
|
||||
|
||||
nicks = weechat_string_split ((argv_eol[3][0] == ':') ?
|
||||
argv_eol[3] + 1 : argv_eol[3],
|
||||
",", 0, 0, &num_nicks);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_nicks);
|
||||
if (nicks)
|
||||
{
|
||||
for (i = 0; i < num_nicks; i++)
|
||||
@ -6064,7 +6110,11 @@ irc_protocol_get_message_tags (const char *tags)
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
items = weechat_string_split (tags, ";", 0, 0, &num_items);
|
||||
items = weechat_string_split (tags, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -6164,7 +6214,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
|
||||
const char *msg_channel)
|
||||
{
|
||||
int i, cmd_found, return_code, argc, decode_color, keep_trailing_spaces;
|
||||
int message_ignored;
|
||||
int message_ignored, flags;
|
||||
char *message_colors_decoded, *pos_space, *tags;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
t_irc_recv_func *cmd_recv_func;
|
||||
@ -6478,9 +6528,18 @@ irc_protocol_recv_command (struct t_irc_server *server,
|
||||
}
|
||||
else
|
||||
message_colors_decoded = NULL;
|
||||
argv = weechat_string_split (message_colors_decoded, " ", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (message_colors_decoded, " ",
|
||||
1 + keep_trailing_spaces, 0, NULL);
|
||||
argv = weechat_string_split (message_colors_decoded, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL;
|
||||
if (keep_trailing_spaces)
|
||||
flags |= WEECHAT_STRING_SPLIT_STRIP_RIGHT;
|
||||
argv_eol = weechat_string_split (message_colors_decoded, " ", flags,
|
||||
0, NULL);
|
||||
|
||||
return_code = (int) (cmd_recv_func) (server,
|
||||
date, nick, address_color,
|
||||
|
@ -422,13 +422,29 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
items[i] = NULL;
|
||||
}
|
||||
if (cmd_start)
|
||||
items[0] = weechat_string_split (cmd_start, ",", 0, 0, &num_items[0]);
|
||||
items[0] = weechat_string_split (cmd_start, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items[0]);
|
||||
if (cmd_stop)
|
||||
items[1] = weechat_string_split (cmd_stop, ",", 0, 0, &num_items[1]);
|
||||
items[1] = weechat_string_split (cmd_stop, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items[1]);
|
||||
if (cmd_extra)
|
||||
items[2] = weechat_string_split (cmd_extra, ",", 0, 0, &num_items[2]);
|
||||
items[2] = weechat_string_split (cmd_extra, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items[2]);
|
||||
if (cmd_filter)
|
||||
items[3] = weechat_string_split (cmd_filter, ",", 0, 0, &num_items[3]);
|
||||
items[3] = weechat_string_split (cmd_filter, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items[3]);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (items[i])
|
||||
@ -793,8 +809,14 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
|
||||
|
||||
if (arguments && arguments[0])
|
||||
{
|
||||
arguments_argv = weechat_string_split (arguments, " ", 0, 0,
|
||||
&arguments_argc);
|
||||
arguments_argv = weechat_string_split (
|
||||
arguments,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&arguments_argc);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -425,7 +425,11 @@ irc_server_eval_fingerprint (struct t_irc_server *server)
|
||||
}
|
||||
|
||||
/* split fingerprint */
|
||||
fingerprints = weechat_string_split (fingerprint_eval, ",", 0, 0, NULL);
|
||||
fingerprints = weechat_string_split (fingerprint_eval, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, NULL);
|
||||
if (!fingerprints)
|
||||
return fingerprint_eval;
|
||||
|
||||
@ -607,7 +611,13 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses)
|
||||
if (!addresses_eval)
|
||||
return 1;
|
||||
server->addresses_array = weechat_string_split (
|
||||
addresses_eval, ",", 0, 0, &server->addresses_count);
|
||||
addresses_eval,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&server->addresses_count);
|
||||
server->ports_array = malloc (
|
||||
server->addresses_count * sizeof (server->ports_array[0]));
|
||||
server->retry_array = malloc (
|
||||
@ -702,7 +712,12 @@ irc_server_set_nicks (struct t_irc_server *server, const char *nicks)
|
||||
/* set new nicks */
|
||||
server->nicks_array = weechat_string_split (
|
||||
(nicks2) ? nicks2 : IRC_SERVER_DEFAULT_NICKS,
|
||||
",", 0, 0, &server->nicks_count);
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&server->nicks_count);
|
||||
|
||||
if (nicks2)
|
||||
free (nicks2);
|
||||
@ -2615,7 +2630,11 @@ irc_server_sendf (struct t_irc_server *server, int flags, const char *tags,
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
items = weechat_string_split (vbuffer, "\n", 0, 0, &items_count);
|
||||
items = weechat_string_split (vbuffer, "\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &items_count);
|
||||
for (i = 0; i < items_count; i++)
|
||||
{
|
||||
/* run modifier "irc_out1_xxx" (like "irc_out_xxx", but before split) */
|
||||
@ -4212,7 +4231,11 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server,
|
||||
}
|
||||
|
||||
/* split good_fingerprints */
|
||||
fingerprints = weechat_string_split (good_fingerprints, ",", 0, 0, NULL);
|
||||
fingerprints = weechat_string_split (good_fingerprints, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, NULL);
|
||||
if (!fingerprints)
|
||||
return 0;
|
||||
|
||||
@ -5121,8 +5144,14 @@ irc_server_autojoin_create_buffers (struct t_irc_server *server)
|
||||
strdup (autojoin);
|
||||
if (autojoin2)
|
||||
{
|
||||
channels = weechat_string_split (autojoin2, ",", 0, 0,
|
||||
&num_channels);
|
||||
channels = weechat_string_split (
|
||||
autojoin2,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_channels);
|
||||
if (channels)
|
||||
{
|
||||
for (i = 0; i < num_channels; i++)
|
||||
|
@ -549,8 +549,14 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
str = weechat_infolist_string (infolist, "join_msg_received");
|
||||
if (str)
|
||||
{
|
||||
items = weechat_string_split (str, ",", 0, 0,
|
||||
&num_items);
|
||||
items = weechat_string_split (
|
||||
str,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -605,8 +611,14 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
str = weechat_infolist_string (infolist, "join_smart_filtered");
|
||||
if (str)
|
||||
{
|
||||
nicks = weechat_string_split (str, ",", 0, 0,
|
||||
&nicks_count);
|
||||
nicks = weechat_string_split (
|
||||
str,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&nicks_count);
|
||||
if (nicks)
|
||||
{
|
||||
for (i = 0; i < nicks_count; i++)
|
||||
|
@ -670,7 +670,11 @@ plugin_api_info_totp_generate_cb (const void *pointer, void *data,
|
||||
if (!arguments || !arguments[0])
|
||||
goto error;
|
||||
|
||||
argv = string_split (arguments, ",", 0, 0, &argc);
|
||||
argv = string_split (arguments, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv || (argc < 1))
|
||||
goto error;
|
||||
|
||||
@ -744,7 +748,11 @@ plugin_api_info_totp_validate_cb (const void *pointer, void *data,
|
||||
if (!arguments || !arguments[0])
|
||||
goto error;
|
||||
|
||||
argv = string_split (arguments, ",", 0, 0, &argc);
|
||||
argv = string_split (arguments, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv || (argc < 2))
|
||||
goto error;
|
||||
|
||||
|
@ -318,8 +318,14 @@ plugin_api_command_options (struct t_weechat_plugin *plugin,
|
||||
ptr_commands = hashtable_get (options, "commands");
|
||||
if (ptr_commands)
|
||||
{
|
||||
new_commands_allowed = string_split (ptr_commands, ",", 0, 0,
|
||||
NULL);
|
||||
new_commands_allowed = string_split (
|
||||
ptr_commands,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
NULL);
|
||||
input_commands_allowed = new_commands_allowed;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,11 @@ plugin_script_api_string_match_list (struct t_weechat_plugin *weechat_plugin,
|
||||
int match;
|
||||
|
||||
list_masks = (masks && masks[0]) ?
|
||||
weechat_string_split (masks, ",", 0, 0, NULL) : NULL;
|
||||
weechat_string_split (masks, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, NULL) : NULL;
|
||||
|
||||
match = weechat_string_match_list (string,
|
||||
(const char **)list_masks,
|
||||
|
@ -1262,7 +1262,11 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
|
||||
}
|
||||
}
|
||||
|
||||
argv = weechat_string_split (ptr_list, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (ptr_list, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
@ -1403,7 +1407,11 @@ plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
ptr_list += 3;
|
||||
}
|
||||
|
||||
argv = weechat_string_split (ptr_list, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (ptr_list, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
@ -1474,7 +1482,11 @@ plugin_script_action_autoload (struct t_weechat_plugin *weechat_plugin,
|
||||
}
|
||||
}
|
||||
|
||||
argv = weechat_string_split (ptr_list, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (ptr_list, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
|
@ -1004,9 +1004,14 @@ plugin_auto_load (char *force_plugin_autoload,
|
||||
|
||||
if (ptr_plugin_autoload && ptr_plugin_autoload[0])
|
||||
{
|
||||
plugin_autoload_array = string_split (ptr_plugin_autoload,
|
||||
",", 0, 0,
|
||||
&plugin_autoload_count);
|
||||
plugin_autoload_array = string_split (
|
||||
ptr_plugin_autoload,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&plugin_autoload_count);
|
||||
}
|
||||
|
||||
/* auto-load plugins in custom path */
|
||||
|
@ -157,7 +157,11 @@ weechat_python_get_python2_bin ()
|
||||
|
||||
if (dir_separator && path)
|
||||
{
|
||||
paths = weechat_string_split (path, ":", 0, 0, &num_paths);
|
||||
paths = weechat_string_split (path, ":",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_paths);
|
||||
if (paths)
|
||||
{
|
||||
for (i = 0; i < num_paths; i++)
|
||||
|
@ -337,7 +337,11 @@ relay_irc_tag_relay_client_id (const char *tags)
|
||||
|
||||
if (tags && tags[0])
|
||||
{
|
||||
argv = weechat_string_split (tags, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (tags, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
@ -561,7 +565,11 @@ relay_irc_hsignal_irc_redir_cb (const void *pointer, void *data,
|
||||
if (!output)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
messages = weechat_string_split (output, "\n", 0, 0, &num_messages);
|
||||
messages = weechat_string_split (output, "\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_messages);
|
||||
if (messages)
|
||||
{
|
||||
for (i = 0; i < num_messages; i++)
|
||||
@ -1347,8 +1355,23 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
|
||||
irc_args = weechat_hashtable_get (hash_parsed, "arguments");
|
||||
if (irc_args)
|
||||
{
|
||||
irc_argv = weechat_string_split (irc_args, " ", 0, 0, &irc_argc);
|
||||
irc_argv_eol = weechat_string_split (irc_args, " ", 1, 0, NULL);
|
||||
irc_argv = weechat_string_split (
|
||||
irc_args,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&irc_argc);
|
||||
irc_argv_eol = weechat_string_split (
|
||||
irc_args,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -340,7 +340,10 @@ relay_client_recv_text (struct t_relay_client *client, const char *data)
|
||||
pos[0] = '\0';
|
||||
|
||||
lines = weechat_string_split (client->partial_message, "\n",
|
||||
0, 0, &num_lines);
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_lines);
|
||||
if (lines)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
|
@ -404,7 +404,11 @@ relay_config_check_irc_backlog_tags (const void *pointer, void *data,
|
||||
return rc;
|
||||
|
||||
/* split tags and check them */
|
||||
tags = weechat_string_split (value, ",", 0, 0, &num_tags);
|
||||
tags = weechat_string_split (value, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_tags);
|
||||
if (tags)
|
||||
{
|
||||
for (i = 0; i < num_tags; i++)
|
||||
@ -448,8 +452,14 @@ relay_config_change_irc_backlog_tags (const void *pointer, void *data,
|
||||
else
|
||||
weechat_hashtable_remove_all (relay_config_hashtable_irc_backlog_tags);
|
||||
|
||||
items = weechat_string_split (weechat_config_string (relay_config_irc_backlog_tags),
|
||||
",", 0, 0, &num_items);
|
||||
items = weechat_string_split (
|
||||
weechat_config_string (relay_config_irc_backlog_tags),
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
|
@ -54,7 +54,11 @@ relay_info_info_relay_client_count_cb (const void *pointer, void *data,
|
||||
protocol = -1;
|
||||
status = -1;
|
||||
|
||||
items = weechat_string_split (arguments, ",", 0, 0, &num_items);
|
||||
items = weechat_string_split (arguments, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
if (num_items > 2)
|
||||
goto end;
|
||||
|
||||
|
@ -583,7 +583,11 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
|
||||
goto end;
|
||||
|
||||
/* split path */
|
||||
list_path = weechat_string_split (pos + 1, "/", 0, 0, &num_path);
|
||||
list_path = weechat_string_split (pos + 1, "/",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_path);
|
||||
if (!list_path)
|
||||
goto end;
|
||||
|
||||
@ -649,7 +653,11 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
|
||||
/* split keys */
|
||||
if (!keys)
|
||||
keys = weechat_hdata_get_string (ptr_hdata, "var_keys");
|
||||
list_keys = weechat_string_split (keys, ",", 0, 0, &num_keys);
|
||||
list_keys = weechat_string_split (keys, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_keys);
|
||||
if (!list_keys)
|
||||
goto end;
|
||||
|
||||
@ -782,7 +790,14 @@ relay_weechat_msg_add_infolist (struct t_relay_weechat_msg *msg,
|
||||
fields = weechat_infolist_fields (ptr_infolist);
|
||||
if (fields)
|
||||
{
|
||||
list_fields = weechat_string_split (fields, ",", 0, 0, &num_fields);
|
||||
list_fields = weechat_string_split (
|
||||
fields,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_fields);
|
||||
if (list_fields)
|
||||
{
|
||||
count_items++;
|
||||
|
@ -1062,15 +1062,22 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(sync)
|
||||
|
||||
RELAY_WEECHAT_PROTOCOL_MIN_ARGS(0);
|
||||
|
||||
buffers = weechat_string_split ((argc > 0) ? argv[0] : "*", ",", 0, 0,
|
||||
&num_buffers);
|
||||
buffers = weechat_string_split ((argc > 0) ? argv[0] : "*", ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_buffers);
|
||||
if (buffers)
|
||||
{
|
||||
add_flags = RELAY_WEECHAT_PROTOCOL_SYNC_ALL;
|
||||
if (argc > 1)
|
||||
{
|
||||
add_flags = 0;
|
||||
flags = weechat_string_split (argv[1], ",", 0, 0, &num_flags);
|
||||
flags = weechat_string_split (argv[1], ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_flags);
|
||||
if (flags)
|
||||
{
|
||||
for (i = 0; i < num_flags; i++)
|
||||
@ -1141,15 +1148,22 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(desync)
|
||||
|
||||
RELAY_WEECHAT_PROTOCOL_MIN_ARGS(0);
|
||||
|
||||
buffers = weechat_string_split ((argc > 0) ? argv[0] : "*", ",", 0, 0,
|
||||
&num_buffers);
|
||||
buffers = weechat_string_split ((argc > 0) ? argv[0] : "*", ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_buffers);
|
||||
if (buffers)
|
||||
{
|
||||
sub_flags = RELAY_WEECHAT_PROTOCOL_SYNC_ALL;
|
||||
if (argc > 1)
|
||||
{
|
||||
sub_flags = 0;
|
||||
flags = weechat_string_split (argv[1], ",", 0, 0, &num_flags);
|
||||
flags = weechat_string_split (argv[1], ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_flags);
|
||||
if (flags)
|
||||
{
|
||||
for (i = 0; i < num_flags; i++)
|
||||
@ -1420,8 +1434,16 @@ relay_weechat_protocol_recv (struct t_relay_client *client, const char *data)
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
argv = weechat_string_split (pos, " ", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (pos, " ", 2, 0, NULL);
|
||||
argv = weechat_string_split (pos, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
argv_eol = weechat_string_split (pos, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; protocol_cb[i].name; i++)
|
||||
|
@ -832,7 +832,11 @@ script_action_show_diff_process_cb (const void *pointer, void *data,
|
||||
{
|
||||
if (out)
|
||||
{
|
||||
lines = weechat_string_split (out, "\n", 0, 0, &num_lines);
|
||||
lines = weechat_string_split (out, "\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_lines);
|
||||
if (lines)
|
||||
{
|
||||
diff_color = weechat_config_boolean (script_config_look_diff_color);
|
||||
@ -867,7 +871,11 @@ script_action_show_diff_process_cb (const void *pointer, void *data,
|
||||
}
|
||||
else if (err)
|
||||
{
|
||||
lines = weechat_string_split (err, "\n", 0, 0, &num_lines);
|
||||
lines = weechat_string_split (err, "\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_lines);
|
||||
if (lines)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
@ -1173,7 +1181,11 @@ script_action_run ()
|
||||
|
||||
script_get_loaded_plugins ();
|
||||
|
||||
actions = weechat_string_split (script_actions, "\n", 0, 0, &num_actions);
|
||||
actions = weechat_string_split (script_actions, "\n",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_actions);
|
||||
if (actions)
|
||||
{
|
||||
for (i = 0; i < num_actions; i++)
|
||||
@ -1202,8 +1214,23 @@ script_action_run ()
|
||||
ptr_action++;
|
||||
}
|
||||
}
|
||||
argv = weechat_string_split (ptr_action, " ", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (ptr_action, " ", 1, 0, &argc);
|
||||
argv = weechat_string_split (
|
||||
ptr_action,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&argc);
|
||||
argv_eol = weechat_string_split (
|
||||
ptr_action,
|
||||
" ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0,
|
||||
&argc);
|
||||
if (argv && argv_eol)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[0], "buffer") == 0)
|
||||
|
@ -256,8 +256,14 @@ script_completion_tags_cb (const void *pointer, void *data,
|
||||
{
|
||||
if (ptr_script->tags)
|
||||
{
|
||||
list_tags = weechat_string_split (ptr_script->tags, ",", 0, 0,
|
||||
&num_tags);
|
||||
list_tags = weechat_string_split (
|
||||
ptr_script->tags,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_tags);
|
||||
if (list_tags)
|
||||
{
|
||||
for (i = 0; i < num_tags; i++)
|
||||
|
@ -113,7 +113,11 @@ script_config_get_diff_command ()
|
||||
result[0] = '\0';
|
||||
if (dir_separator && path)
|
||||
{
|
||||
paths = weechat_string_split (path, ":", 0, 0, &num_paths);
|
||||
paths = weechat_string_split (path, ":",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_paths);
|
||||
if (paths)
|
||||
{
|
||||
for (i = 0; i < num_paths; i++)
|
||||
@ -289,8 +293,14 @@ script_config_hold (const char *name_with_extension)
|
||||
if (hold)
|
||||
{
|
||||
hold[0] = '\0';
|
||||
items = weechat_string_split (weechat_config_string (script_config_scripts_hold),
|
||||
",", 0, 0, &num_items);
|
||||
items = weechat_string_split (
|
||||
weechat_config_string (script_config_scripts_hold),
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
@ -332,8 +342,14 @@ script_config_unhold (const char *name_with_extension)
|
||||
if (hold)
|
||||
{
|
||||
hold[0] = '\0';
|
||||
items = weechat_string_split (weechat_config_string (script_config_scripts_hold),
|
||||
",", 0, 0, &num_items);
|
||||
items = weechat_string_split (
|
||||
weechat_config_string (script_config_scripts_hold),
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
|
@ -934,9 +934,16 @@ script_repo_match_filter (struct t_script_repo *script)
|
||||
if (!script_repo_filter || strcmp (script_repo_filter, "*") == 0)
|
||||
return 1;
|
||||
|
||||
words = weechat_string_split (script_repo_filter, " ", 0, 0, &num_words);
|
||||
tags = weechat_string_split ((script->tags) ? script->tags : "", ",", 0, 0,
|
||||
&num_tags);
|
||||
words = weechat_string_split (script_repo_filter, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_words);
|
||||
tags = weechat_string_split ((script->tags) ? script->tags : "", ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_tags);
|
||||
if (words)
|
||||
{
|
||||
for (i = 0; i < num_words; i++)
|
||||
|
@ -101,7 +101,11 @@ spell_bar_item_suggest (const void *pointer, void *data,
|
||||
if (!str_suggest)
|
||||
return NULL;
|
||||
|
||||
suggestions = weechat_string_split (pos, "/", 0, 0, &num_suggestions);
|
||||
suggestions = weechat_string_split (pos, "/",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_suggestions);
|
||||
if (!suggestions)
|
||||
goto end;
|
||||
|
||||
@ -119,8 +123,14 @@ spell_bar_item_suggest (const void *pointer, void *data,
|
||||
weechat_config_string (
|
||||
spell_config_look_suggestion_delimiter_dict));
|
||||
}
|
||||
suggestions2 = weechat_string_split (suggestions[i], ",", 0, 0,
|
||||
&num_suggestions2);
|
||||
suggestions2 = weechat_string_split (
|
||||
suggestions[i],
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_suggestions2);
|
||||
if (suggestions2)
|
||||
{
|
||||
for (j = 0; j < num_suggestions2; j++)
|
||||
|
@ -94,9 +94,14 @@ spell_config_change_commands (const void *pointer, void *data,
|
||||
value = weechat_config_string (option);
|
||||
if (value && value[0])
|
||||
{
|
||||
spell_commands_to_check = weechat_string_split (value,
|
||||
",", 0, 0,
|
||||
&spell_count_commands_to_check);
|
||||
spell_commands_to_check = weechat_string_split (
|
||||
value,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&spell_count_commands_to_check);
|
||||
if (spell_count_commands_to_check > 0)
|
||||
{
|
||||
spell_length_commands_to_check = malloc (spell_count_commands_to_check *
|
||||
|
@ -99,7 +99,11 @@ spell_speller_check_dictionaries (const char *dict_list)
|
||||
|
||||
if (dict_list)
|
||||
{
|
||||
argv = weechat_string_split (dict_list, ",", 0, 0, &argc);
|
||||
argv = weechat_string_split (dict_list, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
@ -223,7 +227,11 @@ spell_speller_add_dicts_to_hash (struct t_hashtable *hashtable,
|
||||
if (!dict || !dict[0])
|
||||
return;
|
||||
|
||||
dicts = weechat_string_split (dict, ",", 0, 0, &num_dicts);
|
||||
dicts = weechat_string_split (dict, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_dicts);
|
||||
if (dicts)
|
||||
{
|
||||
for (i = 0; i < num_dicts; i++)
|
||||
@ -375,7 +383,11 @@ spell_speller_buffer_new (struct t_gui_buffer *buffer)
|
||||
buffer_dicts = spell_get_dict (buffer);
|
||||
if (buffer_dicts)
|
||||
{
|
||||
dicts = weechat_string_split (buffer_dicts, ",", 0, 0, &num_dicts);
|
||||
dicts = weechat_string_split (buffer_dicts, ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_dicts);
|
||||
if (dicts && (num_dicts > 0))
|
||||
{
|
||||
new_speller_buffer->spellers =
|
||||
|
@ -88,7 +88,14 @@ trigger_buffer_set_filter (const char *filter)
|
||||
}
|
||||
|
||||
if (filter && filter[0])
|
||||
trigger_buffer_filters = weechat_string_split (filter, ",", 0, 0, NULL);
|
||||
trigger_buffer_filters = weechat_string_split (
|
||||
filter,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -733,7 +733,14 @@ trigger_callback_modifier_cb (const void *pointer, void *data,
|
||||
pos2++;
|
||||
if (pos2[0])
|
||||
{
|
||||
tags = weechat_string_split (pos2, ",", 0, 0, &num_tags);
|
||||
tags = weechat_string_split (
|
||||
pos2,
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_tags);
|
||||
length = 1 + strlen (pos2) + 1 + 1;
|
||||
str_tags = malloc (length);
|
||||
if (str_tags)
|
||||
@ -817,8 +824,11 @@ trigger_callback_line_cb (const void *pointer, void *data,
|
||||
|
||||
weechat_hashtable_set (pointers, "buffer", buffer);
|
||||
ptr_value = weechat_hashtable_get (line, "tags");
|
||||
tags = weechat_string_split ((ptr_value) ? ptr_value : "", ",", 0, 0,
|
||||
&num_tags);
|
||||
tags = weechat_string_split ((ptr_value) ? ptr_value : "", ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_tags);
|
||||
|
||||
/* build string with tags and commas around: ",tag1,tag2,tag3," */
|
||||
length = 1 + strlen ((ptr_value) ? ptr_value : "") + 1 + 1;
|
||||
|
@ -682,8 +682,11 @@ trigger_command_trigger (const void *pointer, void *data,
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
items = weechat_string_split (trigger_hook_default_rc[type], ",", 0, 0,
|
||||
&num_items);
|
||||
items = weechat_string_split (trigger_hook_default_rc[type], ",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &num_items);
|
||||
snprintf (input, sizeof (input),
|
||||
"/trigger add name %s \"%s\" \"%s\" \"%s\" \"%s\"%s%s%s",
|
||||
trigger_hook_type_string[type],
|
||||
|
@ -138,7 +138,11 @@ trigger_completion_option_value_cb (const void *pointer, void *data,
|
||||
if (!args)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
argv = weechat_string_split (args, " ", 0, 0, &argc);
|
||||
argv = weechat_string_split (args, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@ -273,7 +277,11 @@ trigger_completion_add_default_for_hook (struct t_gui_completion *completion,
|
||||
if (!args)
|
||||
return;
|
||||
|
||||
argv = weechat_string_split (args, " ", 0, 0, &argc);
|
||||
argv = weechat_string_split (args, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return;
|
||||
|
||||
@ -284,8 +292,14 @@ trigger_completion_add_default_for_hook (struct t_gui_completion *completion,
|
||||
{
|
||||
if (default_strings[type][0] && split && split[0])
|
||||
{
|
||||
items = weechat_string_split (default_strings[type], split,
|
||||
0, 0, &num_items);
|
||||
items = weechat_string_split (
|
||||
default_strings[type],
|
||||
split,
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_items);
|
||||
if (items)
|
||||
{
|
||||
for (i = 0; i < num_items; i++)
|
||||
|
@ -273,10 +273,18 @@ trigger_hook (struct t_trigger *trigger)
|
||||
|
||||
trigger_unhook (trigger);
|
||||
|
||||
argv = weechat_string_split (weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),
|
||||
";", -1, 0, &argc);
|
||||
argv_eol = weechat_string_split (weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),
|
||||
";", 1, 0, NULL);
|
||||
argv = weechat_string_split (
|
||||
weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),
|
||||
";",
|
||||
0,
|
||||
0,
|
||||
&argc);
|
||||
argv_eol = weechat_string_split (
|
||||
weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),
|
||||
";",
|
||||
WEECHAT_STRING_SPLIT_KEEP_EOL,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
switch (weechat_config_integer (trigger->options[TRIGGER_OPTION_HOOK]))
|
||||
{
|
||||
|
@ -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 "20190228-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20190310-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@ -89,6 +89,12 @@ struct timeval;
|
||||
#define WEECHAT_RC_OK_EAT 1
|
||||
#define WEECHAT_RC_ERROR -1
|
||||
|
||||
/* flags for string_split function */
|
||||
#define WEECHAT_STRING_SPLIT_STRIP_LEFT (1 << 0)
|
||||
#define WEECHAT_STRING_SPLIT_STRIP_RIGHT (1 << 1)
|
||||
#define WEECHAT_STRING_SPLIT_COLLAPSE_SEPS (1 << 2)
|
||||
#define WEECHAT_STRING_SPLIT_KEEP_EOL (1 << 3)
|
||||
|
||||
/* return codes for config read functions/callbacks */
|
||||
#define WEECHAT_CONFIG_READ_OK 0
|
||||
#define WEECHAT_CONFIG_READ_MEMORY_ERROR -1
|
||||
@ -316,7 +322,7 @@ struct t_weechat_plugin
|
||||
const char *text),
|
||||
void *callback_data);
|
||||
char **(*string_split) (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max, int *num_items);
|
||||
int flags, int num_items_max, int *num_items);
|
||||
char **(*string_split_shell) (const char *string, int *num_items);
|
||||
void (*string_free_split) (char **split_string);
|
||||
char *(*string_build_with_split_string) (const char **split_string,
|
||||
@ -1213,9 +1219,9 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
__reference_char, \
|
||||
__callback, \
|
||||
__callback_data)
|
||||
#define weechat_string_split(__string, __separator, __eol, __max, \
|
||||
#define weechat_string_split(__string, __separator, __flags, __max, \
|
||||
__num_items) \
|
||||
(weechat_plugin->string_split)(__string, __separator, __eol, \
|
||||
(weechat_plugin->string_split)(__string, __separator, __flags, \
|
||||
__max, __num_items)
|
||||
#define weechat_string_split_shell(__string, __num_items) \
|
||||
(weechat_plugin->string_split_shell)(__string, __num_items)
|
||||
|
@ -538,8 +538,14 @@ xfer_nick_auto_accepted (const char *server, const char *nick)
|
||||
|
||||
rc = 0;
|
||||
|
||||
nicks = weechat_string_split (weechat_config_string (xfer_config_file_auto_accept_nicks),
|
||||
",", 0, 0, &num_nicks);
|
||||
nicks = weechat_string_split (
|
||||
weechat_config_string (xfer_config_file_auto_accept_nicks),
|
||||
",",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0,
|
||||
&num_nicks);
|
||||
if (nicks)
|
||||
{
|
||||
for (i = 0; i < num_nicks; i++)
|
||||
|
@ -29,6 +29,7 @@ extern "C"
|
||||
#include "src/gui/gui-buffer.h"
|
||||
#include "src/gui/gui-chat.h"
|
||||
#include "src/gui/gui-line.h"
|
||||
#include "src/plugins/plugin.h"
|
||||
}
|
||||
|
||||
#define TEST_BUFFER_NAME "test"
|
||||
@ -182,7 +183,11 @@ test_modifier_cb (const void *pointer, void *data,
|
||||
(void) modifier;
|
||||
|
||||
/* split modifier_data, which is: "plugin;name;tags" */
|
||||
items = string_split (modifier_data, ";", 0, 3, &num_items);
|
||||
items = string_split (modifier_data, ";",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
3, &num_items);
|
||||
if (num_items < 2)
|
||||
return NULL;
|
||||
|
||||
|
@ -1008,35 +1008,42 @@ TEST(CoreString, ReplaceWithCallback)
|
||||
TEST(CoreString, Split)
|
||||
{
|
||||
char **argv;
|
||||
int argc;
|
||||
int argc, flags;
|
||||
|
||||
POINTERS_EQUAL(NULL, string_split (NULL, NULL, 0, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split (NULL, "", 0, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split ("", NULL, 0, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split ("", "", 0, 0, NULL));
|
||||
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
|
||||
argc = -1;
|
||||
POINTERS_EQUAL(NULL, string_split (NULL, NULL, 0, 0, &argc));
|
||||
POINTERS_EQUAL(NULL, string_split (NULL, NULL, flags, 0, &argc));
|
||||
LONGS_EQUAL(0, argc);
|
||||
argc = -1;
|
||||
POINTERS_EQUAL(NULL, string_split (NULL, "", 0, 0, &argc));
|
||||
POINTERS_EQUAL(NULL, string_split (NULL, "", flags, 0, &argc));
|
||||
LONGS_EQUAL(0, argc);
|
||||
argc = -1;
|
||||
POINTERS_EQUAL(NULL, string_split ("", NULL, 0, 0, &argc));
|
||||
POINTERS_EQUAL(NULL, string_split ("", NULL, flags, 0, &argc));
|
||||
LONGS_EQUAL(0, argc);
|
||||
argc = -1;
|
||||
POINTERS_EQUAL(NULL, string_split ("", "", 0, 0, &argc));
|
||||
POINTERS_EQUAL(NULL, string_split ("", "", flags, 0, &argc));
|
||||
LONGS_EQUAL(0, argc);
|
||||
argc = -1;
|
||||
POINTERS_EQUAL(NULL, string_split (" ", " ", 0, 0, &argc));
|
||||
POINTERS_EQUAL(NULL, string_split (" ", " ", flags, 0, &argc));
|
||||
LONGS_EQUAL(0, argc);
|
||||
|
||||
/* free split with NULL */
|
||||
string_free_split (NULL);
|
||||
|
||||
/* standard split */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
argc = -1;
|
||||
argv = string_split ("abc de fghi", " ", 0, 0, &argc);
|
||||
argv = string_split ("abc de fghi", " ", flags, 0, &argc);
|
||||
LONGS_EQUAL(3, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc", argv[0]);
|
||||
@ -1046,8 +1053,11 @@ TEST(CoreString, Split)
|
||||
string_free_split (argv);
|
||||
|
||||
/* standard split */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
argc = -1;
|
||||
argv = string_split (" abc de fghi ", " ", 0, 0, &argc);
|
||||
argv = string_split (" abc de fghi ", " ", flags, 0, &argc);
|
||||
LONGS_EQUAL(3, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc", argv[0]);
|
||||
@ -1057,8 +1067,11 @@ TEST(CoreString, Split)
|
||||
string_free_split (argv);
|
||||
|
||||
/* max 2 items */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
argc = -1;
|
||||
argv = string_split (" abc de fghi ", " ", 0, 2, &argc);
|
||||
argv = string_split (" abc de fghi ", " ", flags, 2, &argc);
|
||||
LONGS_EQUAL(2, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc", argv[0]);
|
||||
@ -1066,9 +1079,13 @@ TEST(CoreString, Split)
|
||||
POINTERS_EQUAL(NULL, argv[2]);
|
||||
string_free_split (argv);
|
||||
|
||||
/* keep eol == 1 */
|
||||
/* strip left/right, keep eol for each value */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL;
|
||||
argc = -1;
|
||||
argv = string_split (" abc de fghi ", " ", 1, 0, &argc);
|
||||
argv = string_split (" abc de fghi ", " ", flags, 0, &argc);
|
||||
LONGS_EQUAL(3, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc de fghi", argv[0]);
|
||||
@ -1077,9 +1094,13 @@ TEST(CoreString, Split)
|
||||
POINTERS_EQUAL(NULL, argv[3]);
|
||||
string_free_split (argv);
|
||||
|
||||
/* keep eol == 1 and max 2 items */
|
||||
/* strip left/right, keep eol for each value, max 2 items */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL;
|
||||
argc = -1;
|
||||
argv = string_split (" abc de fghi ", " ", 1, 2, &argc);
|
||||
argv = string_split (" abc de fghi ", " ", flags, 2, &argc);
|
||||
LONGS_EQUAL(2, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc de fghi", argv[0]);
|
||||
@ -1087,9 +1108,12 @@ TEST(CoreString, Split)
|
||||
POINTERS_EQUAL(NULL, argv[2]);
|
||||
string_free_split (argv);
|
||||
|
||||
/* keep eol == 2 */
|
||||
/* strip left, keep eol for each value */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL;
|
||||
argc = -1;
|
||||
argv = string_split (" abc de fghi ", " ", 2, 0, &argc);
|
||||
argv = string_split (" abc de fghi ", " ", flags, 0, &argc);
|
||||
LONGS_EQUAL(3, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc de fghi ", argv[0]);
|
||||
@ -1098,9 +1122,12 @@ TEST(CoreString, Split)
|
||||
POINTERS_EQUAL(NULL, argv[3]);
|
||||
string_free_split (argv);
|
||||
|
||||
/* keep eol == 2 and max 2 items */
|
||||
/* strip left, keep eol for each value, max 2 items */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
|
||||
| WEECHAT_STRING_SPLIT_KEEP_EOL;
|
||||
argc = -1;
|
||||
argv = string_split (" abc de fghi ", " ", 2, 2, &argc);
|
||||
argv = string_split (" abc de fghi ", " ", flags, 2, &argc);
|
||||
LONGS_EQUAL(2, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc de fghi ", argv[0]);
|
||||
@ -1109,8 +1136,11 @@ TEST(CoreString, Split)
|
||||
string_free_split (argv);
|
||||
|
||||
/* standard split with comma separator */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
argc = -1;
|
||||
argv = string_split ("abc,de,fghi", ",", 0, 0, &argc);
|
||||
argv = string_split ("abc,de,fghi", ",", flags, 0, &argc);
|
||||
LONGS_EQUAL(3, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc", argv[0]);
|
||||
@ -1120,8 +1150,11 @@ TEST(CoreString, Split)
|
||||
string_free_split (argv);
|
||||
|
||||
/* standard split with comma separator and empty item (ignore this item) */
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
argc = -1;
|
||||
argv = string_split ("abc,,fghi", ",", 0, 0, &argc);
|
||||
argv = string_split ("abc,,fghi", ",", flags, 0, &argc);
|
||||
LONGS_EQUAL(2, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc", argv[0]);
|
||||
@ -1130,8 +1163,9 @@ TEST(CoreString, Split)
|
||||
string_free_split (argv);
|
||||
|
||||
/* standard split with comma separtor and empty item (keep this item) */
|
||||
flags = 0;
|
||||
argc = -1;
|
||||
argv = string_split ("abc,,fghi", ",", -1, 0, &argc);
|
||||
argv = string_split ("abc,,fghi", ",", flags, 0, &argc);
|
||||
LONGS_EQUAL(3, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc", argv[0]);
|
||||
@ -1141,8 +1175,9 @@ TEST(CoreString, Split)
|
||||
string_free_split (argv);
|
||||
|
||||
/* standard split with comma separtor and empty items (keep them) */
|
||||
flags = 0;
|
||||
argc = -1;
|
||||
argv = string_split (",abc,,fghi,", ",", -1, 0, &argc);
|
||||
argv = string_split (",abc,,fghi,", ",", flags, 0, &argc);
|
||||
LONGS_EQUAL(5, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("", argv[0]);
|
||||
@ -1157,8 +1192,9 @@ TEST(CoreString, Split)
|
||||
* standard split with comma separtor and empty items (keep them),
|
||||
* max 2 items
|
||||
*/
|
||||
flags = 0;
|
||||
argc = -1;
|
||||
argv = string_split (",abc,,fghi,", ",", -1, 2, &argc);
|
||||
argv = string_split (",abc,,fghi,", ",", flags, 2, &argc);
|
||||
LONGS_EQUAL(2, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("", argv[0]);
|
||||
@ -1170,8 +1206,9 @@ TEST(CoreString, Split)
|
||||
* standard split with comma separtor and empty items (keep them),
|
||||
* max 3 items
|
||||
*/
|
||||
flags = 0;
|
||||
argc = -1;
|
||||
argv = string_split (",abc,,fghi,", ",", -1, 3, &argc);
|
||||
argv = string_split (",abc,,fghi,", ",", flags, 3, &argc);
|
||||
LONGS_EQUAL(3, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("", argv[0]);
|
||||
@ -1184,8 +1221,9 @@ TEST(CoreString, Split)
|
||||
* standard split with comma separtor and empty items (keep them),
|
||||
* max 4 items
|
||||
*/
|
||||
flags = 0;
|
||||
argc = -1;
|
||||
argv = string_split (",abc,,fghi,", ",", -1, 4, &argc);
|
||||
argv = string_split (",abc,,fghi,", ",", flags, 4, &argc);
|
||||
LONGS_EQUAL(4, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("", argv[0]);
|
||||
@ -1205,14 +1243,21 @@ TEST(CoreString, Split)
|
||||
TEST(CoreString, SplitShared)
|
||||
{
|
||||
char **argv;
|
||||
int argc;
|
||||
int argc, flags;
|
||||
|
||||
POINTERS_EQUAL(NULL, string_split_shared (NULL, NULL, 0, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split_shared (NULL, "", 0, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split_shared ("", NULL, 0, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split_shared ("", "", 0, 0, NULL));
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
|
||||
argv = string_split_shared (" abc de abc ", " ", 0, 0, &argc);
|
||||
POINTERS_EQUAL(NULL, string_split_shared (NULL, NULL, flags, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split_shared (NULL, "", flags, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split_shared ("", NULL, flags, 0, NULL));
|
||||
POINTERS_EQUAL(NULL, string_split_shared ("", "", flags, 0, NULL));
|
||||
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
argv = string_split_shared (" abc de abc ", " ", flags, 0, &argc);
|
||||
LONGS_EQUAL(3, argc);
|
||||
CHECK(argv);
|
||||
STRCMP_EQUAL("abc", argv[0]);
|
||||
@ -1387,12 +1432,15 @@ TEST(CoreString, SplitTags)
|
||||
TEST(CoreString, SplitBuildWithSplitString)
|
||||
{
|
||||
char **argv, *str;
|
||||
int argc;
|
||||
int argc, flags;
|
||||
|
||||
str = string_build_with_split_string (NULL, NULL);
|
||||
POINTERS_EQUAL(NULL, str);
|
||||
|
||||
argv = string_split (" abc de fghi ", " ", 0, 0, &argc);
|
||||
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS;
|
||||
argv = string_split (" abc de fghi ", " ", flags, 0, &argc);
|
||||
|
||||
str = string_build_with_split_string ((const char **)argv, NULL);
|
||||
STRCMP_EQUAL("abcdefghi", str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user