summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-01-01 18:10:47 +0100
committerSébastien Helleu <flashcode@flashtux.org>2021-01-01 18:10:47 +0100
commit943374f7898cd975a34bfa9df1ba7693be744ef0 (patch)
treefa8cafdd8afa1df8f40347f66bf29dff74059deb
parentcore: add indentation and colors in /eval debug output (diff)
downloadweechat-943374f7898cd975a34bfa9df1ba7693be744ef0.tar.xz
weechat-943374f7898cd975a34bfa9df1ba7693be744ef0.zip
doc: add note about call to "regfree" after call to "string_regcomp" (plugin API reference)
-rw-r--r--doc/en/weechat_plugin_api.en.adoc13
-rw-r--r--doc/fr/weechat_plugin_api.fr.adoc13
-rw-r--r--doc/it/weechat_plugin_api.it.adoc14
-rw-r--r--doc/ja/weechat_plugin_api.ja.adoc14
-rw-r--r--src/core/wee-string.c2
5 files changed, 52 insertions, 4 deletions
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index 03a8982a0..b81440b2b 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -1334,14 +1334,25 @@ Return value:
* same return code as function `regcomp` (0 if OK, other value for error,
see `man regcomp`)
+[NOTE]
+Regular expression _preg_ must be cleaned by calling "regfree" after use,
+if the function returned 0 (OK).
+
C example:
[source,C]
----
regex_t my_regex;
-if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) != 0)
+if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) == 0)
+{
+ /* OK */
+ /* ... */
+ regfree (&my_regex);
+}
+else
{
/* error */
+ /* ... */
}
----
diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc
index b8a740d7e..9aa26db39 100644
--- a/doc/fr/weechat_plugin_api.fr.adoc
+++ b/doc/fr/weechat_plugin_api.fr.adoc
@@ -1355,14 +1355,25 @@ Valeur de retour :
* même code retour que la fonction `regcomp` (0 si ok, autre valeur pour une
erreur, voir `man regcomp`)
+[NOTE]
+L'expression régulière _preg_ doit être nettoyée par un appel à "regfree" après
+utilisation, si la fonction a retourné 0 (OK).
+
Exemple en C :
[source,C]
----
regex_t my_regex;
-if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) != 0)
+if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) == 0)
+{
+ /* OK */
+ /* ... */
+ regfree (&my_regex);
+}
+else
{
/* erreur */
+ /* ... */
}
----
diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc
index f32fe47c5..029a71557 100644
--- a/doc/it/weechat_plugin_api.it.adoc
+++ b/doc/it/weechat_plugin_api.it.adoc
@@ -1400,14 +1400,26 @@ Valore restituito:
* same return code as function `regcomp` (0 if ok, other value for error,
see `man regcomp`)
+[NOTE]
+// TRANSLATION MISSING
+Regular expression _preg_ must be cleaned by calling "regfree" after use,
+if the function returned 0 (OK).
+
Esempio in C:
[source,C]
----
regex_t my_regex;
-if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) != 0)
+if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) == 0)
+{
+ /* OK */
+ /* ... */
+ regfree (&my_regex);
+}
+else
{
/* error */
+ /* ... */
}
----
diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc
index 32c1d4400..91d6f886a 100644
--- a/doc/ja/weechat_plugin_api.ja.adoc
+++ b/doc/ja/weechat_plugin_api.ja.adoc
@@ -1344,14 +1344,26 @@ int weechat_string_regcomp (void *preg, const char *regex, int default_flags)
* `regcomp` 関数と同じ戻り値
(成功の場合は 0、エラーが起きた場合は 0 以外、`man regcomp` を参照)
+[NOTE]
+// TRANSLATION MISSING
+Regular expression _preg_ must be cleaned by calling "regfree" after use,
+if the function returned 0 (OK).
+
C 言語での使用例:
[source,C]
----
regex_t my_regex;
-if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) != 0)
+if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) == 0)
+{
+ /* OK */
+ /* ... */
+ regfree (&my_regex);
+}
+else
{
/* error */
+ /* ... */
}
----
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 9dbc2ce50..3dc565d5f 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -1300,6 +1300,8 @@ string_regex_flags (const char *regex, int default_flags, int *flags)
* Returns:
* 0: successful compilation
* other value: compilation failed
+ *
+ * Note: regex must be freed with regfree after use.
*/
int