From c161d704f7629b78a08e53468e12637be1491436 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 16 Oct 2011 20:12:55 +0200 Subject: [PATCH] core: use value 2 of keep_eol in function string_split to keep separators at end of string --- doc/en/weechat_plugin_api.en.txt | 7 +++++-- doc/fr/weechat_plugin_api.fr.txt | 5 +++++ doc/it/weechat_plugin_api.it.txt | 10 ++++++++-- src/core/wee-string.c | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index 4609253ad..8ce28cac6 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -1036,8 +1036,11 @@ Arguments: * 'string': string to split * 'separators': delimiters used for split -* 'keep_eol': if different from 0, then each argument will contain all string - until end of line (see example below) +* '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 + (_new in version 0.3.6_) * 'num_items_max': maximum number of items created (0 = no limit) * 'num_items': pointer to int which will contain number of items created diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index e6aa327dd..ac6df4928 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -1051,6 +1051,11 @@ Paramètres : * '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 (_nouveau dans la version 0.3.6_) * '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 diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index b92b401bd..f230e5c52 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -1016,8 +1016,14 @@ Argomenti: * 'string': stringa da dividere * 'separators': delimitatori usati per dividere -* 'keep_eol': se diversa da 0, allora ogni argomento conterrà tutte le stringhe - fino a fine riga (consultare l'esempio in basso) +* 'keep_eol': +// TRANSLATION MISSING +** 0: each string will contain one word +// TRANSLATION MISSING +** 1: each string will contain all string until end of line (see example below) +// TRANSLATION MISSING +** 2: same as 1, but do not remove separators at end of string before split + (_new in version 0.3.6_) * 'num_items_max': maximum number of items created (0 = no limit) * 'num_items': pointer to int which will contain number of items created diff --git a/src/core/wee-string.c b/src/core/wee-string.c index 49d9c6bf3..2ffeb583e 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -860,7 +860,7 @@ string_split (const char *string, const char *separators, int keep_eol, if (!string || !string[0] || !separators || !separators[0]) return NULL; - string2 = string_strip (string, 1, 1, separators); + string2 = string_strip (string, 1, (keep_eol == 2) ? 0 : 1, separators); if (!string2 || !string2[0]) return NULL;